use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class SessionDispatcherLeaderProcessTest method testRecoveryWithoutJobGraphButDirtyJobResult.
@Test
public void testRecoveryWithoutJobGraphButDirtyJobResult() throws Exception {
final JobResult dirtyJobResult = TestingJobResultStore.createSuccessfulJobResult(new JobID());
testJobRecovery(Collections.emptyList(), Collections.singleton(dirtyJobResult), actualRecoveredJobGraphs -> assertThat(actualRecoveredJobGraphs).isEmpty(), actualRecoveredDirtyJobResults -> assertThat(actualRecoveredDirtyJobResults).singleElement().isEqualTo(dirtyJobResult));
}
use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class JobDispatcherLeaderProcessFactoryFactoryTest method testJobGraphWithMatchingDirtyJobResult.
@Test
public void testJobGraphWithMatchingDirtyJobResult() throws IOException {
final JobGraph jobGraph = JobGraphTestUtils.emptyJobGraph();
final JobResult jobResult = TestingJobResultStore.createSuccessfulJobResult(jobGraph.getJobID());
final JobDispatcherLeaderProcessFactory factory = createDispatcherLeaderProcessFactoryFromTestInstance(jobGraph, jobResult, temporaryFolder);
assertThat(factory.getJobGraph()).isNull();
assertThat(factory.getRecoveredDirtyJobResult()).isEqualTo(jobResult);
}
use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class JobDispatcherLeaderProcessFactoryFactoryTest method testJobGraphWithNotMatchingDirtyJobResult.
@Test
public void testJobGraphWithNotMatchingDirtyJobResult() throws IOException {
final JobGraph jobGraph = JobGraphTestUtils.emptyJobGraph();
final JobResult jobResult = TestingJobResultStore.createSuccessfulJobResult(new JobID());
final JobDispatcherLeaderProcessFactory factory = createDispatcherLeaderProcessFactoryFromTestInstance(jobGraph, jobResult, temporaryFolder);
assertThat(factory.getJobGraph()).isEqualTo(jobGraph);
assertThat(factory.getRecoveredDirtyJobResult()).isNull();
}
use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class ZooKeeperDefaultDispatcherRunnerTest method testResourceCleanupUnderLeadershipChange.
/**
* See FLINK-11665.
*/
@Test
public void testResourceCleanupUnderLeadershipChange() throws Exception {
final TestingRpcService rpcService = testingRpcServiceResource.getTestingRpcService();
final TestingLeaderElectionService dispatcherLeaderElectionService = new TestingLeaderElectionService();
final CuratorFramework client = ZooKeeperUtils.startCuratorFramework(configuration, fatalErrorHandler).asCuratorFramework();
try (final TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServicesBuilder().setDispatcherLeaderElectionService(dispatcherLeaderElectionService).setJobMasterLeaderRetrieverFunction(jobId -> ZooKeeperUtils.createLeaderRetrievalService(client)).build()) {
final PartialDispatcherServices partialDispatcherServices = new PartialDispatcherServices(configuration, highAvailabilityServices, CompletableFuture::new, blobServer, new TestingHeartbeatServices(), UnregisteredMetricGroups::createUnregisteredJobManagerMetricGroup, new MemoryExecutionGraphInfoStore(), fatalErrorHandler, VoidHistoryServerArchivist.INSTANCE, null, ForkJoinPool.commonPool(), new DispatcherOperationCaches());
final DefaultDispatcherRunnerFactory defaultDispatcherRunnerFactory = DefaultDispatcherRunnerFactory.createSessionRunner(SessionDispatcherFactory.INSTANCE);
try (final DispatcherRunner dispatcherRunner = createDispatcherRunner(rpcService, dispatcherLeaderElectionService, new JobPersistenceComponentFactory() {
@Override
public JobGraphStore createJobGraphStore() {
return createZooKeeperJobGraphStore(client);
}
@Override
public JobResultStore createJobResultStore() {
return new EmbeddedJobResultStore();
}
}, partialDispatcherServices, defaultDispatcherRunnerFactory)) {
// initial run
DispatcherGateway dispatcherGateway = grantLeadership(dispatcherLeaderElectionService);
final JobGraph jobGraph = createJobGraphWithBlobs();
LOG.info("Initial job submission {}.", jobGraph.getJobID());
dispatcherGateway.submitJob(jobGraph, TESTING_TIMEOUT).get();
dispatcherLeaderElectionService.notLeader();
// recovering submitted jobs
LOG.info("Re-grant leadership first time.");
dispatcherGateway = grantLeadership(dispatcherLeaderElectionService);
LOG.info("Cancel recovered job {}.", jobGraph.getJobID());
// cancellation of the job should remove everything
final CompletableFuture<JobResult> jobResultFuture = dispatcherGateway.requestJobResult(jobGraph.getJobID(), TESTING_TIMEOUT);
dispatcherGateway.cancelJob(jobGraph.getJobID(), TESTING_TIMEOUT).get();
// a successful cancellation should eventually remove all job information
final JobResult jobResult = jobResultFuture.get();
assertThat(jobResult.getApplicationStatus(), is(ApplicationStatus.CANCELED));
dispatcherLeaderElectionService.notLeader();
// check that the job has been removed from ZooKeeper
final JobGraphStore submittedJobGraphStore = createZooKeeperJobGraphStore(client);
CommonTestUtils.waitUntilCondition(() -> submittedJobGraphStore.getJobIds().isEmpty(), Deadline.fromNow(VERIFICATION_TIMEOUT), 20L);
}
}
// check resource clean up
assertThat(clusterHaStorageDir.listFiles(), is(emptyArray()));
}
use of org.apache.flink.runtime.jobmaster.JobResult in project flink by apache.
the class MiniDispatcherTest method testJobResultRetrieval.
/**
* Tests that the {@link MiniDispatcher} only terminates in {@link
* ClusterEntrypoint.ExecutionMode#NORMAL} after it has served the {@link
* org.apache.flink.runtime.jobmaster.JobResult} once.
*/
@Test
public void testJobResultRetrieval() throws Exception {
final MiniDispatcher miniDispatcher = createMiniDispatcher(ClusterEntrypoint.ExecutionMode.NORMAL);
miniDispatcher.start();
try {
// wait until we have submitted the job
final TestingJobManagerRunner testingJobManagerRunner = testingJobManagerRunnerFactory.takeCreatedJobManagerRunner();
testingJobManagerRunner.completeResultFuture(executionGraphInfo);
assertFalse(miniDispatcher.getTerminationFuture().isDone());
final DispatcherGateway dispatcherGateway = miniDispatcher.getSelfGateway(DispatcherGateway.class);
final CompletableFuture<JobResult> jobResultFuture = dispatcherGateway.requestJobResult(jobGraph.getJobID(), timeout);
final JobResult jobResult = jobResultFuture.get();
assertThat(jobResult.getJobId(), is(jobGraph.getJobID()));
} finally {
RpcUtils.terminateRpcEndpoint(miniDispatcher, timeout);
}
}
Aggregations