(KvStateLocation kvStateLocation, Throwable throwable) -> { if (throwable != null) { if (ExceptionUtils.stripCompletionException(throwable) instanceof FlinkJobNotFoundException) {
.exceptionally( (Throwable throwable) -> { throw new CompletionException(new JobSubmissionException(jobGraph.getJobID(), "Failed to submit JobGraph.", ExceptionUtils.stripCompletionException(throwable))); });
@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)); } }
@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)); } }
@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)); } }
@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)); } }
out.println("threadDump= " + generateThreadDump()); throw new AssertionError(error.toString(), ExceptionUtils.stripCompletionException(e));
@Override public String toString() { String physicalSlotDescription = ""; try { physicalSlotDescription = String.valueOf(slotContextFuture.getNow(null)); } catch (Exception e) { physicalSlotDescription = '(' + ExceptionUtils.stripCompletionException(e).getMessage() + ')'; } return "MultiTaskSlot{" + "requestId=" + getSlotRequestId() + ", allocatedRequestId=" + allocatedSlotRequestId + ", groupId=" + getGroupId() + ", physicalSlot=" + physicalSlotDescription + ", children=" + children.values().toString() + '}'; } }
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); } } }
@Override public CompletableFuture<ArchivedExecutionGraph> requestJob(JobID jobId, Time timeout) { final CompletableFuture<JobMasterGateway> jobMasterGatewayFuture = getJobMasterGatewayFuture(jobId); final CompletableFuture<ArchivedExecutionGraph> archivedExecutionGraphFuture = jobMasterGatewayFuture.thenCompose( (JobMasterGateway jobMasterGateway) -> jobMasterGateway.requestJob(timeout)); return archivedExecutionGraphFuture.exceptionally( (Throwable throwable) -> { final ArchivedExecutionGraph serializableExecutionGraph = archivedExecutionGraphStore.get(jobId); // check whether it is a completed job if (serializableExecutionGraph == null) { throw new CompletionException(ExceptionUtils.stripCompletionException(throwable)); } else { return serializableExecutionGraph; } }); }
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); } } }
@Override public CompletableFuture<ArchivedExecutionGraph> requestJob(JobID jobId, Time timeout) { final CompletableFuture<JobMasterGateway> jobMasterGatewayFuture = getJobMasterGatewayFuture(jobId); final CompletableFuture<ArchivedExecutionGraph> archivedExecutionGraphFuture = jobMasterGatewayFuture.thenCompose( (JobMasterGateway jobMasterGateway) -> jobMasterGateway.requestJob(timeout)); return archivedExecutionGraphFuture.exceptionally( (Throwable throwable) -> { final ArchivedExecutionGraph serializableExecutionGraph = archivedExecutionGraphStore.get(jobId); // check whether it is a completed job if (serializableExecutionGraph == null) { throw new CompletionException(ExceptionUtils.stripCompletionException(throwable)); } else { return serializableExecutionGraph; } }); }
@Override public CompletableFuture<ArchivedExecutionGraph> requestJob(JobID jobId, Time timeout) { final CompletableFuture<JobMasterGateway> jobMasterGatewayFuture = getJobMasterGatewayFuture(jobId); final CompletableFuture<ArchivedExecutionGraph> archivedExecutionGraphFuture = jobMasterGatewayFuture.thenCompose( (JobMasterGateway jobMasterGateway) -> jobMasterGateway.requestJob(timeout)); return archivedExecutionGraphFuture.exceptionally( (Throwable throwable) -> { final ArchivedExecutionGraph serializableExecutionGraph = archivedExecutionGraphStore.get(jobId); // check whether it is a completed job if (serializableExecutionGraph == null) { throw new CompletionException(ExceptionUtils.stripCompletionException(throwable)); } else { return serializableExecutionGraph; } }); }
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); } } }
@Override public CompletableFuture<JobStatus> requestJobStatus(JobID jobId, Time timeout) { final CompletableFuture<JobMasterGateway> jobMasterGatewayFuture = getJobMasterGatewayFuture(jobId); final CompletableFuture<JobStatus> jobStatusFuture = jobMasterGatewayFuture.thenCompose( (JobMasterGateway jobMasterGateway) -> jobMasterGateway.requestJobStatus(timeout)); return jobStatusFuture.exceptionally( (Throwable throwable) -> { final JobDetails jobDetails = archivedExecutionGraphStore.getAvailableJobDetails(jobId); // check whether it is a completed job if (jobDetails == null) { throw new CompletionException(ExceptionUtils.stripCompletionException(throwable)); } else { return jobDetails.getStatus(); } }); }
private Tuple2<ResponseBody, HttpResponseStatus> errorResponse(Throwable throwable) { Throwable error = ExceptionUtils.stripCompletionException(throwable); if (error instanceof RestHandlerException) { final RestHandlerException rhe = (RestHandlerException) error; log.error("Exception occurred in REST handler.", rhe); return Tuple2.of(new ErrorResponseBody(rhe.getMessage()), rhe.getHttpResponseStatus()); } else { log.error("Implementation error: Unhandled exception.", error); String stackTrace = String.format("<Exception on server side:%n%s%nEnd of exception on server side>", ExceptionUtils.stringifyException(throwable)); return Tuple2.of( new ErrorResponseBody(Arrays.asList("Internal server error.", stackTrace)), HttpResponseStatus.INTERNAL_SERVER_ERROR); } }
@Override public CompletableFuture<JobStatus> requestJobStatus(JobID jobId, Time timeout) { final CompletableFuture<JobMasterGateway> jobMasterGatewayFuture = getJobMasterGatewayFuture(jobId); final CompletableFuture<JobStatus> jobStatusFuture = jobMasterGatewayFuture.thenCompose( (JobMasterGateway jobMasterGateway) -> jobMasterGateway.requestJobStatus(timeout)); return jobStatusFuture.exceptionally( (Throwable throwable) -> { final JobDetails jobDetails = archivedExecutionGraphStore.getAvailableJobDetails(jobId); // check whether it is a completed job if (jobDetails == null) { throw new CompletionException(ExceptionUtils.stripCompletionException(throwable)); } else { return jobDetails.getStatus(); } }); }
@Override public CompletableFuture<JobStatus> requestJobStatus(JobID jobId, Time timeout) { final CompletableFuture<JobMasterGateway> jobMasterGatewayFuture = getJobMasterGatewayFuture(jobId); final CompletableFuture<JobStatus> jobStatusFuture = jobMasterGatewayFuture.thenCompose( (JobMasterGateway jobMasterGateway) -> jobMasterGateway.requestJobStatus(timeout)); return jobStatusFuture.exceptionally( (Throwable throwable) -> { final JobDetails jobDetails = archivedExecutionGraphStore.getAvailableJobDetails(jobId); // check whether it is a completed job if (jobDetails == null) { throw new CompletionException(ExceptionUtils.stripCompletionException(throwable)); } else { return jobDetails.getStatus(); } }); }
@Override public String toString() { String logicalSlotString = "(pending)"; try { LogicalSlot slot = singleLogicalSlotFuture.getNow(null); if (slot != null) { logicalSlotString = "(requestId=" + slot.getSlotRequestId() + ", allocationId=" + slot.getAllocationId() + ')'; } } catch (Exception e) { logicalSlotString = '(' + ExceptionUtils.stripCompletionException(e).getMessage() + ')'; } return "SingleTaskSlot{" + "logicalSlot=" + logicalSlotString + ", request=" + getSlotRequestId() + ", group=" + getGroupId() + '}'; } }
@Override public void onAddedJobGraph(final JobID jobId) { final CompletableFuture<SubmittedJobGraph> recoveredJob = getRpcService().execute( () -> submittedJobGraphStore.recoverJobGraph(jobId)); final CompletableFuture<Acknowledge> submissionFuture = recoveredJob.thenComposeAsync( (SubmittedJobGraph submittedJobGraph) -> submitJob(submittedJobGraph.getJobGraph(), RpcUtils.INF_TIMEOUT), getMainThreadExecutor()); submissionFuture.whenComplete( (Acknowledge acknowledge, Throwable throwable) -> { if (throwable != null) { onFatalError( new DispatcherException( String.format("Could not start the added job %s", jobId), ExceptionUtils.stripCompletionException(throwable))); } }); }