Search in sources :

Example 1 with ErrorInfo

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());
}
Also used : ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo)

Example 2 with ErrorInfo

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();
}
Also used : JobStatus(org.apache.flink.api.common.JobStatus) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) JobID(org.apache.flink.api.common.JobID)

Example 3 with ErrorInfo

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));
}
Also used : AccessExecution(org.apache.flink.runtime.executiongraph.AccessExecution) TaskManagerLocation(org.apache.flink.runtime.taskmanager.TaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) ArchivedTaskManagerLocationMatcher.isArchivedTaskManagerLocation(org.apache.flink.runtime.scheduler.exceptionhistory.ArchivedTaskManagerLocationMatcher.isArchivedTaskManagerLocation) LocalTaskManagerLocation(org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) Test(org.junit.Test)

Example 4 with ErrorInfo

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));
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) FlinkException(org.apache.flink.util.FlinkException) Test(org.junit.Test)

Example 5 with ErrorInfo

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));
    }
}
Also used : TestingAccessExecution(org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution) TaskExecutionStateTransition(org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) FlinkException(org.apache.flink.util.FlinkException) CompletableFuture(java.util.concurrent.CompletableFuture) CheckpointScheduling(org.apache.flink.runtime.checkpoint.CheckpointScheduling) Test(org.junit.Test)

Aggregations

ErrorInfo (org.apache.flink.runtime.executiongraph.ErrorInfo)27 Test (org.junit.Test)17 JobID (org.apache.flink.api.common.JobID)9 TaskExecutionStateTransition (org.apache.flink.runtime.executiongraph.TaskExecutionStateTransition)8 TestingAccessExecution (org.apache.flink.runtime.scheduler.exceptionhistory.TestingAccessExecution)8 ArchivedExecutionGraphBuilder (org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)7 FlinkException (org.apache.flink.util.FlinkException)7 JobStatus (org.apache.flink.api.common.JobStatus)5 CompletableFuture (java.util.concurrent.CompletableFuture)4 ArchivedExecutionGraph (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph)4 ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)4 RootExceptionHistoryEntry (org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry)4 Duration (java.time.Duration)3 Deadline (org.apache.flink.api.common.time.Deadline)3 JobExecutionException (org.apache.flink.runtime.client.JobExecutionException)3 ArchivedExecutionVertex (org.apache.flink.runtime.executiongraph.ArchivedExecutionVertex)3 LocalTaskManagerLocation (org.apache.flink.runtime.taskmanager.LocalTaskManagerLocation)3 File (java.io.File)2 IOException (java.io.IOException)2 ArrayList (java.util.ArrayList)2