Java Code Examples for org.apache.flink.util.ExceptionUtils#stripCompletionException()
The following examples show how to use
org.apache.flink.util.ExceptionUtils#stripCompletionException() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: JarDeleteHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testFailedDelete() throws Exception { makeJarDirReadOnly(); final HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> request = createRequest(TEST_JAR_NAME); try { jarDeleteHandler.handleRequest(request, restfulGateway).get(); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getMessage(), containsString("Failed to delete jar")); assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR)); } }
Example 2
Source File: JarUploadHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testFailedUpload() throws Exception { final Path uploadedFile = jarDir.resolve("Kafka010Example.jar"); final HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request = createRequest(uploadedFile); try { jarUploadHandler.handleRequest(request, mockDispatcherGateway).get(); fail("Expected exception not thrown."); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getMessage(), containsString("Could not move uploaded jar file")); assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR)); } }
Example 3
Source File: JobExecutionResultHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 6 votes |
@Test public void testPropagateFlinkJobNotFoundExceptionAsRestHandlerException() throws Exception { final TestingRestfulGateway testingRestfulGateway = TestingRestfulGateway.newBuilder() .setRequestJobStatusFunction( jobId -> FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId)) ) .build(); try { jobExecutionResultHandler.handleRequest( testRequest, testingRestfulGateway).get(); fail("Expected exception not thrown"); } catch (final ExecutionException e) { final Throwable cause = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(cause, instanceOf(RestHandlerException.class)); assertThat( ((RestHandlerException) cause).getHttpResponseStatus(), equalTo(HttpResponseStatus.NOT_FOUND)); } }
Example 4
Source File: JarDeleteHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testFailedDelete() throws Exception { makeJarDirReadOnly(); final HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> request = createRequest(TEST_JAR_NAME); try { jarDeleteHandler.handleRequest(request, restfulGateway).get(); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getMessage(), containsString("Failed to delete jar")); assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR)); } }
Example 5
Source File: JarUploadHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testFailedUpload() throws Exception { final Path uploadedFile = jarDir.resolve("Kafka010Example.jar"); final HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request = createRequest(uploadedFile); try { jarUploadHandler.handleRequest(request, mockDispatcherGateway).get(); fail("Expected exception not thrown."); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getMessage(), containsString("Could not move uploaded jar file")); assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR)); } }
Example 6
Source File: JarUploadHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testFailedUpload() throws Exception { final Path uploadedFile = jarDir.resolve("Kafka010Example.jar"); final HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request = createRequest(uploadedFile); try { jarUploadHandler.handleRequest(request, mockDispatcherGateway).get(); fail("Expected exception not thrown."); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getMessage(), containsString("Could not move uploaded jar file")); assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.INTERNAL_SERVER_ERROR)); } }
Example 7
Source File: JobExecutionResultHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testPropagateFlinkJobNotFoundExceptionAsRestHandlerException() throws Exception { final TestingRestfulGateway testingRestfulGateway = TestingRestfulGateway.newBuilder() .setRequestJobStatusFunction( jobId -> FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId)) ) .build(); try { jobExecutionResultHandler.handleRequest( testRequest, testingRestfulGateway).get(); fail("Expected exception not thrown"); } catch (final ExecutionException e) { final Throwable cause = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(cause, instanceOf(RestHandlerException.class)); assertThat( ((RestHandlerException) cause).getHttpResponseStatus(), equalTo(HttpResponseStatus.NOT_FOUND)); } }
Example 8
Source File: JobExecutionResultHandlerTest.java From flink with Apache License 2.0 | 6 votes |
@Test public void testPropagateFlinkJobNotFoundExceptionAsRestHandlerException() throws Exception { final TestingRestfulGateway testingRestfulGateway = new TestingRestfulGateway.Builder() .setRequestJobStatusFunction( jobId -> FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId)) ) .build(); try { jobExecutionResultHandler.handleRequest( testRequest, testingRestfulGateway).get(); fail("Expected exception not thrown"); } catch (final ExecutionException e) { final Throwable cause = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(cause, instanceOf(RestHandlerException.class)); assertThat( ((RestHandlerException) cause).getHttpResponseStatus(), equalTo(HttpResponseStatus.NOT_FOUND)); } }
Example 9
Source File: DefaultScheduler.java From flink with Apache License 2.0 | 5 votes |
private static Throwable maybeWrapWithNoResourceAvailableException(final Throwable failure) { final Throwable strippedThrowable = ExceptionUtils.stripCompletionException(failure); if (strippedThrowable instanceof TimeoutException) { return new NoResourceAvailableException("Could not allocate the required slot within slot request timeout. " + "Please make sure that the cluster has enough resources.", failure); } else { return failure; } }
Example 10
Source File: JarDeleteHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testDeleteUnknownJar() throws Exception { final HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> request = createRequest("doesnotexist.jar"); try { jarDeleteHandler.handleRequest(request, restfulGateway).get(); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getMessage(), containsString("File doesnotexist.jar does not exist in")); assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.BAD_REQUEST)); } }
Example 11
Source File: JobExecutionResultHandler.java From flink with Apache License 2.0 | 5 votes |
private static CompletionException propagateException(final Throwable throwable) { final Throwable cause = ExceptionUtils.stripCompletionException(throwable); if (cause instanceof FlinkJobNotFoundException) { throw new CompletionException(new RestHandlerException( throwable.getMessage(), HttpResponseStatus.NOT_FOUND, throwable)); } else { throw new CompletionException(throwable); } }
Example 12
Source File: SessionDispatcherLeaderProcess.java From flink with Apache License 2.0 | 5 votes |
private Void filterOutDuplicateJobSubmissionException(Throwable throwable) { final Throwable strippedException = ExceptionUtils.stripCompletionException(throwable); if (strippedException instanceof DuplicateJobSubmissionException) { final DuplicateJobSubmissionException duplicateJobSubmissionException = (DuplicateJobSubmissionException) strippedException; log.debug("Ignore recovered job {} because the job is currently being executed.", duplicateJobSubmissionException.getJobID(), duplicateJobSubmissionException); return null; } else { throw new CompletionException(throwable); } }
Example 13
Source File: CheckpointCoordinator.java From flink with Apache License 2.0 | 5 votes |
/** * The trigger request is failed. * NOTE, it must be invoked if trigger request is failed. * * @param checkpoint the pending checkpoint which is failed. It could be null if it's failed * prematurely without a proper initialization. * @param throwable the reason of trigger failure */ private void onTriggerFailure(@Nullable PendingCheckpoint checkpoint, Throwable throwable) { // beautify the stack trace a bit throwable = ExceptionUtils.stripCompletionException(throwable); try { coordinatorsToCheckpoint.forEach(OperatorCoordinatorCheckpointContext::abortCurrentTriggering); if (checkpoint != null && !checkpoint.isDiscarded()) { int numUnsuccessful = numUnsuccessfulCheckpointsTriggers.incrementAndGet(); LOG.warn( "Failed to trigger checkpoint {} for job {}. ({} consecutive failed attempts so far)", checkpoint.getCheckpointId(), job, numUnsuccessful, throwable); final CheckpointException cause = getCheckpointException( CheckpointFailureReason.TRIGGER_CHECKPOINT_FAILURE, throwable); synchronized (lock) { abortPendingCheckpoint(checkpoint, cause); } } } finally { isTriggering = false; executeQueuedRequest(); } }
Example 14
Source File: JarUploadHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testRejectNonJarFiles() throws Exception { final Path uploadedFile = Files.createFile(jarDir.resolve("katrin.png")); final HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request = createRequest(uploadedFile); try { jarUploadHandler.handleRequest(request, mockDispatcherGateway).get(); fail("Expected exception not thrown."); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.BAD_REQUEST)); } }
Example 15
Source File: JarDeleteHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDeleteUnknownJar() throws Exception { final HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> request = createRequest("doesnotexist.jar"); try { jarDeleteHandler.handleRequest(request, restfulGateway).get(); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getMessage(), containsString("File doesnotexist.jar does not exist in")); assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.BAD_REQUEST)); } }
Example 16
Source File: JobExecutionResultHandler.java From flink with Apache License 2.0 | 5 votes |
private static CompletionException propagateException(final Throwable throwable) { final Throwable cause = ExceptionUtils.stripCompletionException(throwable); if (cause instanceof FlinkJobNotFoundException) { throw new CompletionException(new RestHandlerException( throwable.getMessage(), HttpResponseStatus.NOT_FOUND, throwable)); } else { throw new CompletionException(throwable); } }
Example 17
Source File: JarUploadHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testRejectNonJarFiles() throws Exception { final Path uploadedFile = Files.createFile(jarDir.resolve("katrin.png")); final HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request = createRequest(uploadedFile); try { jarUploadHandler.handleRequest(request, mockDispatcherGateway).get(); fail("Expected exception not thrown."); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.BAD_REQUEST)); } }
Example 18
Source File: JarDeleteHandlerTest.java From flink with Apache License 2.0 | 5 votes |
@Test public void testDeleteUnknownJar() throws Exception { final HandlerRequest<EmptyRequestBody, JarDeleteMessageParameters> request = createRequest("doesnotexist.jar"); try { jarDeleteHandler.handleRequest(request, restfulGateway).get(); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getMessage(), containsString("File doesnotexist.jar does not exist in")); assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.BAD_REQUEST)); } }
Example 19
Source File: JobExecutionResultHandler.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
private static CompletionException propagateException(final Throwable throwable) { final Throwable cause = ExceptionUtils.stripCompletionException(throwable); if (cause instanceof FlinkJobNotFoundException) { throw new CompletionException(new RestHandlerException( throwable.getMessage(), HttpResponseStatus.NOT_FOUND, throwable)); } else { throw new CompletionException(throwable); } }
Example 20
Source File: JarUploadHandlerTest.java From Flink-CEPplus with Apache License 2.0 | 5 votes |
@Test public void testRejectNonJarFiles() throws Exception { final Path uploadedFile = Files.createFile(jarDir.resolve("katrin.png")); final HandlerRequest<EmptyRequestBody, EmptyMessageParameters> request = createRequest(uploadedFile); try { jarUploadHandler.handleRequest(request, mockDispatcherGateway).get(); fail("Expected exception not thrown."); } catch (final ExecutionException e) { final Throwable throwable = ExceptionUtils.stripCompletionException(e.getCause()); assertThat(throwable, instanceOf(RestHandlerException.class)); final RestHandlerException restHandlerException = (RestHandlerException) throwable; assertThat(restHandlerException.getHttpResponseStatus(), equalTo(HttpResponseStatus.BAD_REQUEST)); } }