Search in sources :

Example 1 with ArchivedExecutionGraphBuilder

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

the class DispatcherTest method testCancellationOfNonCanceledTerminalJobFailsWithAppropriateException.

@Test
public void testCancellationOfNonCanceledTerminalJobFailsWithAppropriateException() throws Exception {
    final CompletableFuture<JobManagerRunnerResult> jobTerminationFuture = new CompletableFuture<>();
    dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new FinishingJobManagerRunnerFactory(jobTerminationFuture, () -> {
    }));
    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.FINISHED).build())));
    // wait for job to finish
    dispatcherGateway.requestJobResult(jobId, TIMEOUT).get();
    // sanity check
    assertThat(dispatcherGateway.requestJobStatus(jobId, TIMEOUT).get(), is(JobStatus.FINISHED));
    final CompletableFuture<Acknowledge> cancelFuture = dispatcherGateway.cancelJob(jobId, TIMEOUT);
    assertThat(cancelFuture, FlinkMatchers.futureWillCompleteExceptionally(FlinkJobTerminatedWithoutCancellationException.class, Duration.ofHours(8)));
}
Also used : CompletableFuture(java.util.concurrent.CompletableFuture) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) JobManagerRunnerResult(org.apache.flink.runtime.jobmaster.JobManagerRunnerResult) FlinkJobTerminatedWithoutCancellationException(org.apache.flink.runtime.messages.FlinkJobTerminatedWithoutCancellationException) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 2 with ArchivedExecutionGraphBuilder

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

the class FileExecutionGraphInfoStoreTest method testCloseCleansUp.

/**
 * Tests that all persisted files are cleaned up after closing the store.
 */
@Test
public void testCloseCleansUp() throws IOException {
    final File rootDir = temporaryFolder.newFolder();
    assertThat(rootDir.listFiles().length, Matchers.equalTo(0));
    try (final FileExecutionGraphInfoStore executionGraphInfoStore = createDefaultExecutionGraphInfoStore(rootDir)) {
        assertThat(rootDir.listFiles().length, Matchers.equalTo(1));
        final File storageDirectory = executionGraphInfoStore.getStorageDir();
        assertThat(storageDirectory.listFiles().length, Matchers.equalTo(0));
        executionGraphInfoStore.put(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setState(JobStatus.FINISHED).build()));
        assertThat(storageDirectory.listFiles().length, Matchers.equalTo(1));
    }
    assertThat(rootDir.listFiles().length, Matchers.equalTo(0));
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) File(java.io.File) Test(org.junit.Test)

Example 3 with ArchivedExecutionGraphBuilder

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

the class FileExecutionGraphInfoStoreTest method testCacheLoading.

/**
 * Tests that evicted {@link ExecutionGraphInfo} are loaded from disk again.
 */
@Test
public void testCacheLoading() throws IOException {
    final File rootDir = temporaryFolder.newFolder();
    try (final FileExecutionGraphInfoStore executionGraphInfoStore = new FileExecutionGraphInfoStore(rootDir, Time.hours(1L), Integer.MAX_VALUE, 100L << 10, TestingUtils.defaultScheduledExecutor(), Ticker.systemTicker())) {
        final LoadingCache<JobID, ExecutionGraphInfo> executionGraphInfoCache = executionGraphInfoStore.getExecutionGraphInfoCache();
        Collection<ExecutionGraphInfo> executionGraphInfos = new ArrayList<>(64);
        boolean continueInserting = true;
        // insert execution graphs until the first one got evicted
        while (continueInserting) {
            // has roughly a size of 1.4 KB
            final ExecutionGraphInfo executionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setState(JobStatus.FINISHED).build());
            executionGraphInfoStore.put(executionGraphInfo);
            executionGraphInfos.add(executionGraphInfo);
            continueInserting = executionGraphInfoCache.size() == executionGraphInfos.size();
        }
        final File storageDirectory = executionGraphInfoStore.getStorageDir();
        assertThat(storageDirectory.listFiles().length, Matchers.equalTo(executionGraphInfos.size()));
        for (ExecutionGraphInfo executionGraphInfo : executionGraphInfos) {
            assertThat(executionGraphInfoStore.get(executionGraphInfo.getJobId()), matchesPartiallyWith(executionGraphInfo));
        }
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArrayList(java.util.ArrayList) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) File(java.io.File) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 4 with ArchivedExecutionGraphBuilder

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

the class DispatcherTest method testCancellationOfCanceledTerminalDoesNotThrowException.

@Test
public void testCancellationOfCanceledTerminalDoesNotThrowException() throws Exception {
    final CompletableFuture<JobManagerRunnerResult> jobTerminationFuture = new CompletableFuture<>();
    dispatcher = createAndStartDispatcher(heartbeatServices, haServices, new FinishingJobManagerRunnerFactory(jobTerminationFuture, () -> {
    }));
    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.CANCELED).build())));
    // wait for job to finish
    dispatcherGateway.requestJobResult(jobId, TIMEOUT).get();
    // sanity check
    assertThat(dispatcherGateway.requestJobStatus(jobId, TIMEOUT).get(), is(JobStatus.CANCELED));
    dispatcherGateway.cancelJob(jobId, TIMEOUT).get();
}
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 5 with ArchivedExecutionGraphBuilder

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

the class DispatcherResourceCleanupTest method testGlobalCleanupWhenJobFinishedWhileClosingDispatcher.

@Test
public void testGlobalCleanupWhenJobFinishedWhileClosingDispatcher() throws Exception {
    final TestingJobManagerRunner testingJobManagerRunner = TestingJobManagerRunner.newBuilder().setBlockingTermination(true).setJobId(jobId).build();
    final Queue<JobManagerRunner> jobManagerRunners = new ArrayDeque<>(Arrays.asList(testingJobManagerRunner));
    startDispatcher(new QueueJobManagerRunnerFactory(jobManagerRunners));
    submitJobAndWait();
    final CompletableFuture<Void> dispatcherTerminationFuture = dispatcher.closeAsync();
    testingJobManagerRunner.getCloseAsyncCalledLatch().await();
    testingJobManagerRunner.completeResultFuture(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setJobID(jobId).setState(JobStatus.FINISHED).build()));
    testingJobManagerRunner.completeTerminationFuture();
    // check that no exceptions have been thrown
    dispatcherTerminationFuture.get();
    assertGlobalCleanupTriggered(jobId);
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder) TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) JobManagerRunner(org.apache.flink.runtime.jobmaster.JobManagerRunner) ArrayDeque(java.util.ArrayDeque) 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