use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.
the class ExceptionHistoryEntry method create.
/**
* Creates an {@code ExceptionHistoryEntry} based on the provided {@code Execution}.
*
* @param failedExecution the failed {@code Execution}.
* @param taskName the name of the task.
* @return The {@code ExceptionHistoryEntry}.
* @throws NullPointerException if {@code null} is passed as one of the parameters.
* @throws IllegalArgumentException if the passed {@code Execution} does not provide a {@link
* Execution#getFailureInfo() failureInfo}.
*/
public static ExceptionHistoryEntry create(AccessExecution failedExecution, String taskName) {
Preconditions.checkNotNull(failedExecution, "No Execution is specified.");
Preconditions.checkNotNull(taskName, "No task name is specified.");
Preconditions.checkArgument(failedExecution.getFailureInfo().isPresent(), "The selected Execution " + failedExecution.getAttemptId() + " didn't fail.");
final ErrorInfo failure = failedExecution.getFailureInfo().get();
return new ExceptionHistoryEntry(failure.getException(), failure.getTimestamp(), taskName, failedExecution.getAssignedResourceLocation());
}
use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.
the class JobResult method createFrom.
/**
* Creates the {@link JobResult} from the given {@link AccessExecutionGraph} which must be in a
* globally terminal state.
*
* @param accessExecutionGraph to create the JobResult from
* @return JobResult of the given AccessExecutionGraph
*/
public static JobResult createFrom(AccessExecutionGraph accessExecutionGraph) {
final JobID jobId = accessExecutionGraph.getJobID();
final JobStatus jobStatus = accessExecutionGraph.getState();
checkArgument(jobStatus.isTerminalState(), "The job " + accessExecutionGraph.getJobName() + '(' + jobId + ") is not in a " + "terminal state. It is in state " + jobStatus + '.');
final JobResult.Builder builder = new JobResult.Builder();
builder.jobId(jobId);
builder.applicationStatus(ApplicationStatus.fromJobStatus(accessExecutionGraph.getState()));
final long netRuntime = accessExecutionGraph.getStatusTimestamp(jobStatus) - accessExecutionGraph.getStatusTimestamp(JobStatus.INITIALIZING);
// guard against clock changes
final long guardedNetRuntime = Math.max(netRuntime, 0L);
builder.netRuntime(guardedNetRuntime);
builder.accumulatorResults(accessExecutionGraph.getAccumulatorsSerialized());
if (jobStatus == JobStatus.FAILED) {
final ErrorInfo errorInfo = accessExecutionGraph.getFailureInfo();
checkNotNull(errorInfo, "No root cause is found for the job failure.");
builder.serializedThrowable(errorInfo.getException());
}
return builder.build();
}
use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.
the class ExceptionHistoryEntryTest method testCreate.
@Test
public void testCreate() {
final Throwable failure = new RuntimeException("Expected exception");
final long timestamp = System.currentTimeMillis();
final TaskManagerLocation taskManagerLocation = new LocalTaskManagerLocation();
final AccessExecution execution = TestingAccessExecution.newBuilder().withErrorInfo(new ErrorInfo(failure, timestamp)).withTaskManagerLocation(taskManagerLocation).build();
final String taskName = "task name";
final ExceptionHistoryEntry entry = ExceptionHistoryEntry.create(execution, taskName);
assertThat(entry.getException().deserializeError(ClassLoader.getSystemClassLoader()), is(failure));
assertThat(entry.getTimestamp(), is(timestamp));
assertThat(entry.getFailingTaskName(), is(taskName));
assertThat(entry.getTaskManagerLocation(), isArchivedTaskManagerLocation(taskManagerLocation));
assertThat(entry.isGlobal(), is(false));
}
use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.
the class StopWithSavepointTest method testRestartingOnUpdateTaskExecutionStateWithRestart.
@Test
public void testRestartingOnUpdateTaskExecutionStateWithRestart() throws Exception {
try (MockStopWithSavepointContext ctx = new MockStopWithSavepointContext()) {
StateTrackingMockExecutionGraph executionGraph = new StateTrackingMockExecutionGraph();
StopWithSavepoint sws = createStopWithSavepoint(ctx, executionGraph);
ctx.setStopWithSavepoint(sws);
ctx.setHowToHandleFailure(failure -> FailureResult.canRestart(failure, Duration.ZERO));
ctx.setExpectRestarting(assertNonNull());
Exception exception = new RuntimeException();
TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
executionGraph.registerExecution(execution);
TaskExecutionStateTransition taskExecutionStateTransition = ExecutingTest.createFailingStateTransition(execution.getAttemptId(), exception);
assertThat(sws.updateTaskExecutionState(taskExecutionStateTransition), is(true));
}
}
use of org.apache.flink.runtime.executiongraph.ErrorInfo in project flink by apache.
the class StopWithSavepointTest method testRestartOnTaskFailureAfterSavepointCompletion.
@Test
public void testRestartOnTaskFailureAfterSavepointCompletion() throws Exception {
try (MockStopWithSavepointContext ctx = new MockStopWithSavepointContext()) {
CheckpointScheduling mockStopWithSavepointOperations = new MockCheckpointScheduling();
CompletableFuture<String> savepointFuture = new CompletableFuture<>();
StateTrackingMockExecutionGraph executionGraph = new StateTrackingMockExecutionGraph();
StopWithSavepoint sws = createStopWithSavepoint(ctx, mockStopWithSavepointOperations, executionGraph, savepointFuture);
ctx.setStopWithSavepoint(sws);
ctx.setHowToHandleFailure(failure -> FailureResult.canRestart(failure, Duration.ZERO));
ctx.setExpectRestarting(assertNonNull());
// 1. complete savepoint future
savepointFuture.complete(SAVEPOINT_PATH);
ctx.triggerExecutors();
// 2. fail task
Exception exception = new RuntimeException();
TestingAccessExecution execution = TestingAccessExecution.newBuilder().withExecutionState(ExecutionState.FAILED).withErrorInfo(new ErrorInfo(exception, System.currentTimeMillis())).build();
executionGraph.registerExecution(execution);
TaskExecutionStateTransition taskExecutionStateTransition = ExecutingTest.createFailingStateTransition(execution.getAttemptId(), exception);
assertThat(sws.updateTaskExecutionState(taskExecutionStateTransition), is(true));
}
}
Aggregations