Search in sources :

Example 41 with ExecutionGraphInfo

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;
}
Also used : JobStatus(org.apache.flink.api.common.JobStatus) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArrayList(java.util.ArrayList) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)

Example 42 with ExecutionGraphInfo

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));
    }
}
Also used : ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) ArchivedExecutionGraphBuilder(org.apache.flink.runtime.rest.handler.legacy.utils.ArchivedExecutionGraphBuilder)

Example 43 with ExecutionGraphInfo

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));
    }
}
Also used : JobStatus(org.apache.flink.api.common.JobStatus) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) JobsOverview(org.apache.flink.runtime.messages.webmonitor.JobsOverview) Test(org.junit.Test)

Example 44 with ExecutionGraphInfo

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));
    }
}
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) ManuallyTriggeredScheduledExecutor(org.apache.flink.util.concurrent.ManuallyTriggeredScheduledExecutor) Test(org.junit.Test)

Example 45 with ExecutionGraphInfo

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);
}
Also used : JobSubmissionException(org.apache.flink.runtime.client.JobSubmissionException) Tuple2(org.apache.flink.api.java.tuple.Tuple2) ClusterOptions(org.apache.flink.configuration.ClusterOptions) JobGraph(org.apache.flink.runtime.jobgraph.JobGraph) RpcServiceUtils(org.apache.flink.runtime.rpc.RpcServiceUtils) ExceptionUtils(org.apache.flink.util.ExceptionUtils) AsynchronousJobOperationKey(org.apache.flink.runtime.rest.handler.job.AsynchronousJobOperationKey) ClusterOverview(org.apache.flink.runtime.messages.webmonitor.ClusterOverview) ResourceSpec(org.apache.flink.api.common.operators.ResourceSpec) FunctionUtils(org.apache.flink.util.function.FunctionUtils) Map(java.util.Map) PermanentlyFencedRpcEndpoint(org.apache.flink.runtime.rpc.PermanentlyFencedRpcEndpoint) Checkpoints(org.apache.flink.runtime.checkpoint.Checkpoints) Preconditions.checkNotNull(org.apache.flink.util.Preconditions.checkNotNull) JobGraphWriter(org.apache.flink.runtime.jobmanager.JobGraphWriter) JobsOverview(org.apache.flink.runtime.messages.webmonitor.JobsOverview) HighAvailabilityServices(org.apache.flink.runtime.highavailability.HighAvailabilityServices) DispatcherResourceCleanerFactory(org.apache.flink.runtime.dispatcher.cleanup.DispatcherResourceCleanerFactory) JobDetails(org.apache.flink.runtime.messages.webmonitor.JobDetails) Collection(java.util.Collection) GatewayRetriever(org.apache.flink.runtime.webmonitor.retriever.GatewayRetriever) Set(java.util.Set) CompletionException(java.util.concurrent.CompletionException) FlinkJobTerminatedWithoutCancellationException(org.apache.flink.runtime.messages.FlinkJobTerminatedWithoutCancellationException) Preconditions(org.apache.flink.util.Preconditions) Collectors(java.util.stream.Collectors) Acknowledge(org.apache.flink.runtime.messages.Acknowledge) HeartbeatServices(org.apache.flink.runtime.heartbeat.HeartbeatServices) MetricNames(org.apache.flink.runtime.metrics.MetricNames) MetricGroup(org.apache.flink.metrics.MetricGroup) List(java.util.List) SerializedValue(org.apache.flink.util.SerializedValue) CoordinationRequest(org.apache.flink.runtime.operators.coordination.CoordinationRequest) FlinkJobNotFoundException(org.apache.flink.runtime.messages.FlinkJobNotFoundException) JobManagerSharedServices(org.apache.flink.runtime.jobmaster.JobManagerSharedServices) OperatorID(org.apache.flink.runtime.jobgraph.OperatorID) Optional(java.util.Optional) JobResultStore(org.apache.flink.runtime.highavailability.JobResultStore) ResourceCleanerFactory(org.apache.flink.runtime.dispatcher.cleanup.ResourceCleanerFactory) Time(org.apache.flink.api.common.time.Time) ResourceManagerGateway(org.apache.flink.runtime.resourcemanager.ResourceManagerGateway) ClusterEntryPointExceptionUtils(org.apache.flink.runtime.entrypoint.ClusterEntryPointExceptionUtils) FlinkException(org.apache.flink.util.FlinkException) SavepointFormatType(org.apache.flink.core.execution.SavepointFormatType) BlobServer(org.apache.flink.runtime.blob.BlobServer) JobVertex(org.apache.flink.runtime.jobgraph.JobVertex) DefaultJobManagerJobMetricGroupFactory(org.apache.flink.runtime.jobmaster.factories.DefaultJobManagerJobMetricGroupFactory) CoordinationResponse(org.apache.flink.runtime.operators.coordination.CoordinationResponse) HashMap(java.util.HashMap) CompletableFuture(java.util.concurrent.CompletableFuture) JobStatus(org.apache.flink.api.common.JobStatus) Function(java.util.function.Function) ArrayList(java.util.ArrayList) JobMasterGateway(org.apache.flink.runtime.jobmaster.JobMasterGateway) HashSet(java.util.HashSet) JobResult(org.apache.flink.runtime.jobmaster.JobResult) RpcService(org.apache.flink.runtime.rpc.RpcService) CleanupRunnerFactory(org.apache.flink.runtime.dispatcher.cleanup.CleanupRunnerFactory) ResourceOverview(org.apache.flink.runtime.resourcemanager.ResourceOverview) FutureUtils(org.apache.flink.util.concurrent.FutureUtils) FatalErrorHandler(org.apache.flink.runtime.rpc.FatalErrorHandler) ResourceID(org.apache.flink.runtime.clusterframework.types.ResourceID) ThrowingConsumer(org.apache.flink.util.function.ThrowingConsumer) Nonnull(javax.annotation.Nonnull) Nullable(javax.annotation.Nullable) ArchivedExecutionGraph(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraph) JobManagerRunnerResult(org.apache.flink.runtime.jobmaster.JobManagerRunnerResult) Executor(java.util.concurrent.Executor) OperationResult(org.apache.flink.runtime.rest.handler.async.OperationResult) ApplicationStatus(org.apache.flink.runtime.clusterframework.ApplicationStatus) Configuration(org.apache.flink.configuration.Configuration) ThreadDumpInfo(org.apache.flink.runtime.rest.messages.ThreadDumpInfo) IOException(java.io.IOException) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) VisibleForTesting(org.apache.flink.annotation.VisibleForTesting) JobResultEntry(org.apache.flink.runtime.highavailability.JobResultEntry) MultipleJobsDetails(org.apache.flink.runtime.messages.webmonitor.MultipleJobsDetails) JobID(org.apache.flink.api.common.JobID) ResourceCleaner(org.apache.flink.runtime.dispatcher.cleanup.ResourceCleaner) JobManagerRunner(org.apache.flink.runtime.jobmaster.JobManagerRunner) Collections(java.util.Collections) DuplicateJobSubmissionException(org.apache.flink.runtime.client.DuplicateJobSubmissionException) JobManagerMetricGroup(org.apache.flink.runtime.metrics.groups.JobManagerMetricGroup) ExecutionGraphInfo(org.apache.flink.runtime.scheduler.ExecutionGraphInfo) CompletionException(java.util.concurrent.CompletionException) FlinkJobNotFoundException(org.apache.flink.runtime.messages.FlinkJobNotFoundException) JobManagerRunner(org.apache.flink.runtime.jobmaster.JobManagerRunner)

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