Search in sources :

Example 16 with ArchivedExecutionGraphBuilder

use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.

the class DispatcherTest method testCacheJobExecutionResult.

/**
 * Test that {@link JobResult} is cached when the job finishes.
 */
@Test
public void testCacheJobExecutionResult() throws Exception {
    dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new ExpectedJobIdJobManagerRunnerFactory(jobId, createdJobManagerRunnerLatch));
    final DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
    final JobID failedJobId = new JobID();
    final JobStatus expectedState = JobStatus.FAILED;
    final ExecutionGraphInfo failedExecutionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(failedJobId).setState(expectedState).setFailureCause(new ErrorInfo(new RuntimeException("expected"), 1L)).build());
    dispatcher.completeJobExecution(failedExecutionGraphInfo);
    assertThat(dispatcherGateway.requestJobStatus(failedJobId, TIMEOUT).get(), equalTo(expectedState));
    assertThat(dispatcherGateway.requestExecutionGraphInfo(failedJobId, TIMEOUT).get(), equalTo(failedExecutionGraphInfo));
}
Also used : JobStatus(org.apache.flink.api.common.JobStatus) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ErrorInfo(org.apache.flink.runtime.executiongraph.ErrorInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 17 with ArchivedExecutionGraphBuilder

use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.

the class DispatcherTest method testNoHistoryServerArchiveCreatedForSuspendedJob.

@Test
public void testNoHistoryServerArchiveCreatedForSuspendedJob() throws Exception {
    final CompletableFuture<Void> archiveAttemptFuture = new CompletableFuture<>();
    final CompletableFuture<JobManagerRunnerResult> jobTerminationFuture = new CompletableFuture<>();
    dispatcher = createTestingDispatcherBuilder().setJobManagerRunnerFactory(new FinishingJobManagerRunnerFactory(jobTerminationFuture, () -> {
    })).setHistoryServerArchivist(executionGraphInfo -> {
        archiveAttemptFuture.complete(null);
        return CompletableFuture.completedFuture(null);
    }).build();
    dispatcher.start();
    jobMasterLeaderElectionService.isLeader(UUID.randomUUID());
    DispatcherGateway dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
    JobID jobId = jobGraph.getJobID();
    dispatcherGateway.submitJob(jobGraph, TIMEOUT).get();
    jobTerminationFuture.complete(JobManagerRunnerResult.forSuccess(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.SUSPENDED).build())));
    // wait for job to finish
    dispatcherGateway.requestJobResult(jobId, TIMEOUT).get();
    // sanity check
    assertThat(dispatcherGateway.requestJobStatus(jobId, TIMEOUT).get(), is(JobStatus.SUSPENDED));
    assertThat(archiveAttemptFuture.isDone(), is(false));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) JobManagerRunnerResult(org.apache.flink.runtime.jobmaster.JobManagerRunnerResult) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 18 with ArchivedExecutionGraphBuilder

use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.

the class FileExecutionGraphInfoStoreTest method testExecutionGraphExpiration.

/**
 * Tests that an expired execution graph is removed from the execution graph store.
 */
@Test
public void testExecutionGraphExpiration() throws Exception {
    final File rootDir = temporaryFolder.newFolder();
    final Time expirationTime = Time.milliseconds(1L);
    final ManuallyTriggeredScheduledExecutor scheduledExecutor = new ManuallyTriggeredScheduledExecutor();
    final ManualTicker manualTicker = new ManualTicker();
    try (final FileExecutionGraphInfoStore executionGraphInfoStore = new FileExecutionGraphInfoStore(rootDir, expirationTime, Integer.MAX_VALUE, 10000L, scheduledExecutor, manualTicker)) {
        final ExecutionGraphInfo executionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setState(JobStatus.FINISHED).build());
        executionGraphInfoStore.put(executionGraphInfo);
        // there should one execution graph
        assertThat(executionGraphInfoStore.size(), Matchers.equalTo(1));
        manualTicker.advanceTime(expirationTime.toMilliseconds(), TimeUnit.MILLISECONDS);
        // this should trigger the cleanup after expiration
        scheduledExecutor.triggerScheduledTasks();
        assertThat(executionGraphInfoStore.size(), Matchers.equalTo(0));
        assertThat(executionGraphInfoStore.get(executionGraphInfo.getJobId()), Matchers.nullValue());
        final File storageDirectory = executionGraphInfoStore.getStorageDir();
        // check that the persisted file has been deleted
        assertThat(storageDirectory.listFiles().length, Matchers.equalTo(0));
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) Time(org.apache.flink.api.common.time.Time) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) ManualTicker(org.apache.flink.runtime.util.ManualTicker) File(java.io.File) ManuallyTriggeredScheduledExecutor(org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor) Test(org.junit.Test)

Example 19 with ArchivedExecutionGraphBuilder

use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.

the class FileExecutionGraphInfoStoreTest method assertPutJobGraphWithStatus.

private void assertPutJobGraphWithStatus(JobStatus jobStatus) throws IOException {
    final ExecutionGraphInfo dummyExecutionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setState(jobStatus).build());
    final File rootDir = temporaryFolder.newFolder();
    try (final FileExecutionGraphInfoStore executionGraphStore = createDefaultExecutionGraphInfoStore(rootDir)) {
        final File storageDirectory = executionGraphStore.getStorageDir();
        // check that the storage directory is empty
        assertThat(storageDirectory.listFiles().length, Matchers.equalTo(0));
        executionGraphStore.put(dummyExecutionGraphInfo);
        // check that we have persisted the given execution graph
        assertThat(storageDirectory.listFiles().length, Matchers.equalTo(1));
        assertThat(executionGraphStore.get(dummyExecutionGraphInfo.getJobId()), new ExecutionGraphInfoStoreTestUtils.PartialExecutionGraphInfoMatcher(dummyExecutionGraphInfo));
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) File(java.io.File)

Example 20 with ArchivedExecutionGraphBuilder

use of org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder in project flink by apache.

the class JobExceptionsHandlerTest method testNoExceptions.

@Test
public void testNoExceptions() throws HandlerRequestException {
    final ExecutionGraphInfo executionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().build());
    final HandlerRequest<EmptyRequestBody> request = createRequest(executionGraphInfo.getJobId(), 10);
    final JobExceptionsInfoWithHistory response = testInstance.handleRequest(request, executionGraphInfo);
    assertThat(response.getRootException(), is(nullValue()));
    assertThat(response.getRootTimestamp(), is(nullValue()));
    assertFalse(response.isTruncated());
    assertThat(response.getAllExceptions(), empty());
    assertThat(response.getExceptionHistory().getEntries(), empty());
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) EmptyRequestBody(org.apache.flink.runtime.rest.messages.EmptyRequestBody) JobExceptionsInfoWithHistory(org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory) Test(org.junit.Test)

Aggregations

ArchivedExecutionGraphBuilder (org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)29 ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)23 Test (org.junit.Test)22 JobID (org.apache.flink.api.common.JobID)12 CompletableFuture (java.util.concurrent.CompletableFuture)8 Time (org.apache.flink.api.common.time.Time)6 ErrorInfo (org.apache.flink.runtime.executiongraph.ErrorInfo)6 FlinkException (org.apache.flink.util.FlinkException)6 JobStatus (org.apache.flink.api.common.JobStatus)5 TestingJobManagerRunner (org.apache.flink.runtime.jobmaster.TestingJobManagerRunner)5 File (java.io.File)4 ArrayList (java.util.ArrayList)4 ExecutionException (java.util.concurrent.ExecutionException)4 ArchivedExecutionGraph (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph)4 ArrayDeque (java.util.ArrayDeque)3 Arrays (java.util.Arrays)3 TimeUnit (java.util.concurrent.TimeUnit)3 Configuration (org.apache.flink.configuration.Configuration)3 BlobServer (org.apache.flink.runtime.blob.BlobServer)3 IOException (java.io.IOException)2