use of org.apache.flink.util.FlinkException in project flink by apache.
the class Dispatcher method jobReachedTerminalState.
protected CleanupJobState jobReachedTerminalState(ExecutionGraphInfo executionGraphInfo) {
final ArchivedExecutionGraph archivedExecutionGraph = executionGraphInfo.getArchivedExecutionGraph();
final JobStatus terminalJobStatus = archivedExecutionGraph.getState();
Preconditions.checkArgument(terminalJobStatus.isTerminalState(), "Job %s is in state %s which is not terminal.", archivedExecutionGraph.getJobID(), terminalJobStatus);
// the failureInfo contains the reason for why job was failed/suspended, but for
// finished/canceled jobs it may contain the last cause of a restart (if there were any)
// for finished/canceled jobs we don't want to print it because it is misleading
final boolean isFailureInfoRelatedToJobTermination = terminalJobStatus == JobStatus.SUSPENDED || terminalJobStatus == JobStatus.FAILED;
if (archivedExecutionGraph.getFailureInfo() != null && isFailureInfoRelatedToJobTermination) {
log.info("Job {} reached terminal state {}.\n{}", archivedExecutionGraph.getJobID(), terminalJobStatus, archivedExecutionGraph.getFailureInfo().getExceptionAsString().trim());
} else {
log.info("Job {} reached terminal state {}.", archivedExecutionGraph.getJobID(), terminalJobStatus);
}
archiveExecutionGraph(executionGraphInfo);
if (terminalJobStatus.isGloballyTerminalState()) {
final JobID jobId = executionGraphInfo.getJobId();
try {
if (jobResultStore.hasCleanJobResultEntry(jobId)) {
log.warn("Job {} is already marked as clean but clean up was triggered again.", jobId);
} else if (!jobResultStore.hasDirtyJobResultEntry(jobId)) {
jobResultStore.createDirtyResult(new JobResultEntry(JobResult.createFrom(executionGraphInfo.getArchivedExecutionGraph())));
log.info("Job {} has been registered for cleanup in the JobResultStore after reaching a terminal state.", jobId);
}
} catch (IOException e) {
fatalErrorHandler.onFatalError(new FlinkException(String.format("The job %s couldn't be marked as pre-cleanup finished in JobResultStore.", jobId), e));
}
}
return terminalJobStatus.isGloballyTerminalState() ? CleanupJobState.GLOBAL : CleanupJobState.LOCAL;
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class SessionDispatcherLeaderProcessTest method onAddedJobGraph_failingRecovery_propagatesTheFailure.
@Test
public void onAddedJobGraph_failingRecovery_propagatesTheFailure() throws Exception {
final FlinkException expectedFailure = new FlinkException("Expected failure");
jobGraphStore = TestingJobGraphStore.newBuilder().setRecoverJobGraphFunction((ignoredA, ignoredB) -> {
throw expectedFailure;
}).build();
try (final SessionDispatcherLeaderProcess dispatcherLeaderProcess = createDispatcherLeaderProcess()) {
dispatcherLeaderProcess.start();
// wait first for the dispatcher service to be created
dispatcherLeaderProcess.getDispatcherGateway().get();
jobGraphStore.putJobGraph(JOB_GRAPH);
dispatcherLeaderProcess.onAddedJobGraph(JOB_GRAPH.getJobID());
assertThat(fatalErrorHandler.getErrorFuture()).succeedsWithin(100, TimeUnit.MILLISECONDS).extracting(FlinkAssertions::chainOfCauses, STREAM_THROWABLE).contains(expectedFailure);
assertThat(dispatcherLeaderProcess.getState()).isEqualTo(SessionDispatcherLeaderProcess.State.STOPPED);
fatalErrorHandler.clearError();
}
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class SessionDispatcherLeaderProcessTest method unexpectedDispatcherServiceTerminationWhileRunning_callsFatalErrorHandler.
@Test
public void unexpectedDispatcherServiceTerminationWhileRunning_callsFatalErrorHandler() {
final CompletableFuture<Void> terminationFuture = new CompletableFuture<>();
dispatcherServiceFactory = createFactoryBasedOnGenericSupplier(() -> TestingDispatcherGatewayService.newBuilder().setTerminationFuture(terminationFuture).build());
final SessionDispatcherLeaderProcess dispatcherLeaderProcess = createDispatcherLeaderProcess();
dispatcherLeaderProcess.start();
final FlinkException expectedFailure = new FlinkException("Expected test failure.");
terminationFuture.completeExceptionally(expectedFailure);
final Throwable error = fatalErrorHandler.getErrorFuture().join();
assertThat(error).getRootCause().isEqualTo(expectedFailure);
fatalErrorHandler.clearError();
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class SessionDispatcherLeaderProcessTest method recoverJobs_withRecoveryFailure_failsFatally.
@Test
public void recoverJobs_withRecoveryFailure_failsFatally() throws Exception {
final FlinkException testException = new FlinkException("Test exception");
jobGraphStore = TestingJobGraphStore.newBuilder().setRecoverJobGraphFunction((ignoredA, ignoredB) -> {
throw testException;
}).setInitialJobGraphs(Collections.singleton(JOB_GRAPH)).build();
runJobRecoveryFailureTest(testException);
}
use of org.apache.flink.util.FlinkException in project flink by apache.
the class SessionDispatcherLeaderProcessTest method recoverJobs_withJobIdRecoveryFailure_failsFatally.
@Test
public void recoverJobs_withJobIdRecoveryFailure_failsFatally() throws Exception {
final FlinkException testException = new FlinkException("Test exception");
jobGraphStore = TestingJobGraphStore.newBuilder().setJobIdsFunction(ignored -> {
throw testException;
}).build();
runJobRecoveryFailureTest(testException);
}
Aggregations