Search in sources :

Example 1 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo 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 ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.

the class FileExecutionGraphInfoStoreTest method testAvailableJobDetails.

/**
 * Tests that we obtain the correct collection of available job details.
 */
@Test
public void testAvailableJobDetails() throws IOException {
    final int numberExecutionGraphs = 10;
    final Collection<ExecutionGraphInfo> executionGraphInfos = generateTerminalExecutionGraphInfos(numberExecutionGraphs);
    final Collection<JobDetails> jobDetails = generateJobDetails(executionGraphInfos);
    final File rootDir = temporaryFolder.newFolder();
    try (final FileExecutionGraphInfoStore executionGraphInfoStore = createDefaultExecutionGraphInfoStore(rootDir)) {
        for (ExecutionGraphInfo executionGraphInfo : executionGraphInfos) {
            executionGraphInfoStore.put(executionGraphInfo);
        }
        assertThat(executionGraphInfoStore.getAvailableJobDetails(), Matchers.containsInAnyOrder(jobDetails.toArray()));
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) File(java.io.File) ExecutionGraphInfoStoreTestUtils.generateJobDetails(org.apache.flink.runtime.dispatcher.ExecutionGraphInfoStoreTestUtils.generateJobDetails) JobDetails(org.apache.flink.runtime.messages.webmonitor.JobDetails) Test(org.junit.Test)

Example 3 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo 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 4 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo 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 5 with ExecutionGraphInfo

use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.

the class FileExecutionGraphInfoStoreTest method testMaximumCapacity.

/**
 * Tests that the size of {@link FileExecutionGraphInfoStore} is no more than the configured max
 * capacity and the old execution graphs will be purged if the total added number exceeds the
 * max capacity.
 */
@Test
public void testMaximumCapacity() throws IOException {
    final File rootDir = temporaryFolder.newFolder();
    final int maxCapacity = 10;
    final int numberExecutionGraphs = 10;
    final Collection<ExecutionGraphInfo> oldExecutionGraphInfos = generateTerminalExecutionGraphInfos(numberExecutionGraphs);
    final Collection<ExecutionGraphInfo> newExecutionGraphInfos = generateTerminalExecutionGraphInfos(numberExecutionGraphs);
    final Collection<JobDetails> jobDetails = generateJobDetails(newExecutionGraphInfos);
    try (final FileExecutionGraphInfoStore executionGraphInfoStore = new FileExecutionGraphInfoStore(rootDir, Time.hours(1L), maxCapacity, 10000L, TestingUtils.defaultScheduledExecutor(), Ticker.systemTicker())) {
        for (ExecutionGraphInfo executionGraphInfo : oldExecutionGraphInfos) {
            executionGraphInfoStore.put(executionGraphInfo);
            // no more than the configured maximum capacity
            assertTrue(executionGraphInfoStore.size() <= maxCapacity);
        }
        for (ExecutionGraphInfo executionGraphInfo : newExecutionGraphInfos) {
            executionGraphInfoStore.put(executionGraphInfo);
            // equals to the configured maximum capacity
            assertEquals(maxCapacity, executionGraphInfoStore.size());
        }
        // the older execution graphs are purged
        assertThat(executionGraphInfoStore.getAvailableJobDetails(), Matchers.containsInAnyOrder(jobDetails.toArray()));
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) File(java.io.File) ExecutionGraphInfoStoreTestUtils.generateJobDetails(org.apache.flink.runtime.dispatcher.ExecutionGraphInfoStoreTestUtils.generateJobDetails) JobDetails(org.apache.flink.runtime.messages.webmonitor.JobDetails) Test(org.junit.Test)

Aggregations

ExecutionGraphInfo (org.apache.flink.runtime.scheduler.ExecutionGraphInfo)45 Test (org.junit.Test)33 ArchivedExecutionGraphBuilder (org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)23 Time (org.apache.flink.api.common.time.Time)12 CompletableFuture (java.util.concurrent.CompletableFuture)11 JobID (org.apache.flink.api.common.JobID)11 JobStatus (org.apache.flink.api.common.JobStatus)9 FlinkException (org.apache.flink.util.FlinkException)8 File (java.io.File)7 TestingJobManagerRunner (org.apache.flink.runtime.jobmaster.TestingJobManagerRunner)7 ArrayList (java.util.ArrayList)6 ArchivedExecutionGraph (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph)6 FlinkJobNotFoundException (org.apache.flink.runtime.messages.FlinkJobNotFoundException)6 EmptyRequestBody (org.apache.flink.runtime.rest.messages.EmptyRequestBody)6 JobGraph (org.apache.flink.runtime.jobgraph.JobGraph)5 JobManagerRunner (org.apache.flink.runtime.jobmaster.JobManagerRunner)5 Acknowledge (org.apache.flink.runtime.messages.Acknowledge)5 JobExceptionsInfoWithHistory (org.apache.flink.runtime.rest.messages.JobExceptionsInfoWithHistory)5 RootExceptionHistoryEntry (org.apache.flink.runtime.scheduler.exceptionhistory.RootExceptionHistoryEntry)5 ExceptionUtils (org.apache.flink.util.ExceptionUtils)5