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)));
}
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));
}
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));
}
}
}
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();
}
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);
}
Aggregations