use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class ExecutionGraphInfoStoreTestUtils method generateTerminalExecutionGraphInfos.
/**
* Generate a specified of ExecutionGraphInfo.
*
* @param number the given number
* @return the result ExecutionGraphInfo collection
*/
static Collection<ExecutionGraphInfo> generateTerminalExecutionGraphInfos(int number) {
final Collection<ExecutionGraphInfo> executionGraphInfos = new ArrayList<>(number);
for (int i = 0; i < number; i++) {
final JobStatus state = GLOBALLY_TERMINAL_JOB_STATUS.get(ThreadLocalRandom.current().nextInt(GLOBALLY_TERMINAL_JOB_STATUS.size()));
executionGraphInfos.add(new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setState(state).build()));
}
return executionGraphInfos;
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class MemoryExecutionGraphInfoStoreTest method assertPutJobGraphWithStatus.
private void assertPutJobGraphWithStatus(JobStatus jobStatus) throws IOException {
final ExecutionGraphInfo dummyExecutionGraphInfo = new ExecutionGraphInfo(new ArchivedExecutionGraphBuilder().setState(jobStatus).build());
try (final MemoryExecutionGraphInfoStore executionGraphStore = createMemoryExecutionGraphInfoStore()) {
// check that the graph store is empty
assertThat(executionGraphStore.size(), Matchers.equalTo(0));
executionGraphStore.put(dummyExecutionGraphInfo);
// check that we have persisted the given execution graph
assertThat(executionGraphStore.size(), Matchers.equalTo(1));
assertThat(executionGraphStore.get(dummyExecutionGraphInfo.getJobId()), new ExecutionGraphInfoStoreTestUtils.PartialExecutionGraphInfoMatcher(dummyExecutionGraphInfo));
}
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class MemoryExecutionGraphInfoStoreTest method testStoredJobsOverview.
/**
* Tests that we obtain the correct jobs overview.
*/
@Test
public void testStoredJobsOverview() throws IOException {
final int numberExecutionGraphs = 10;
final Collection<ExecutionGraphInfo> executionGraphInfos = generateTerminalExecutionGraphInfos(numberExecutionGraphs);
final List<JobStatus> jobStatuses = executionGraphInfos.stream().map(ExecutionGraphInfo::getArchivedExecutionGraph).map(ArchivedExecutionGraph::getState).collect(Collectors.toList());
final JobsOverview expectedJobsOverview = JobsOverview.create(jobStatuses);
try (final MemoryExecutionGraphInfoStore executionGraphInfoStore = createMemoryExecutionGraphInfoStore()) {
for (ExecutionGraphInfo executionGraphInfo : executionGraphInfos) {
executionGraphInfoStore.put(executionGraphInfo);
}
assertThat(executionGraphInfoStore.getStoredJobsOverview(), Matchers.equalTo(expectedJobsOverview));
}
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class MemoryExecutionGraphInfoStoreTest method testExecutionGraphExpiration.
/**
* Tests that an expired execution graph is removed from the execution graph store.
*/
@Test
public void testExecutionGraphExpiration() throws Exception {
final Time expirationTime = Time.milliseconds(1L);
final ManuallyTriggeredScheduledExecutor scheduledExecutor = new ManuallyTriggeredScheduledExecutor();
final ManualTicker manualTicker = new ManualTicker();
try (final MemoryExecutionGraphInfoStore executionGraphInfoStore = new MemoryExecutionGraphInfoStore(expirationTime, Integer.MAX_VALUE, 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());
// check that the store is empty
assertThat(executionGraphInfoStore.size(), Matchers.equalTo(0));
}
}
use of org.apache.flink.runtime.scheduler.ExecutionGraphInfo in project flink by apache.
the class Dispatcher method requestExecutionGraphInfo.
@Override
public CompletableFuture<ExecutionGraphInfo> requestExecutionGraphInfo(JobID jobId, Time timeout) {
Function<Throwable, ExecutionGraphInfo> checkExecutionGraphStoreOnException = throwable -> {
// check whether it is a completed job
final ExecutionGraphInfo executionGraphInfo = executionGraphInfoStore.get(jobId);
if (executionGraphInfo == null) {
throw new CompletionException(ExceptionUtils.stripCompletionException(throwable));
} else {
return executionGraphInfo;
}
};
Optional<JobManagerRunner> maybeJob = getJobManagerRunner(jobId);
return maybeJob.map(job -> job.requestJob(timeout)).orElse(FutureUtils.completedExceptionally(new FlinkJobNotFoundException(jobId))).exceptionally(checkExecutionGraphStoreOnException);
}
Aggregations