Search in sources :

Example 1 with TestingCleanupRunnerFactory

use of org.apache.flink.runtime.dispatcher.cleanup.TestingCleanupRunnerFactory in project flink by apache.

the class MiniDispatcherTest method setup.

@Before
public void setup() throws Exception {
    highAvailabilityServices = new TestingHighAvailabilityServicesBuilder().build();
    testingJobManagerRunnerFactory = new TestingJobMasterServiceLeadershipRunnerFactory();
    testingCleanupRunnerFactory = new TestingCleanupRunnerFactory();
}
Also used : TestingCleanupRunnerFactory(org.apache.flink.runtime.dispatcher.cleanup.TestingCleanupRunnerFactory) TestingHighAvailabilityServicesBuilder(org.apache.flink.runtime.highavailability.TestingHighAvailabilityServicesBuilder) Before(org.junit.Before)

Example 2 with TestingCleanupRunnerFactory

use of org.apache.flink.runtime.dispatcher.cleanup.TestingCleanupRunnerFactory in project flink by apache.

the class DispatcherTest method testJobCleanupWithoutRecoveredJobGraph.

@Test
public void testJobCleanupWithoutRecoveredJobGraph() throws Exception {
    final JobID jobIdOfRecoveredDirtyJobs = new JobID();
    final TestingJobMasterServiceLeadershipRunnerFactory jobManagerRunnerFactory = new TestingJobMasterServiceLeadershipRunnerFactory();
    final TestingCleanupRunnerFactory cleanupRunnerFactory = new TestingCleanupRunnerFactory();
    final OneShotLatch dispatcherBootstrapLatch = new OneShotLatch();
    dispatcher = createTestingDispatcherBuilder().setJobManagerRunnerFactory(jobManagerRunnerFactory).setCleanupRunnerFactory(cleanupRunnerFactory).setRecoveredDirtyJobs(Collections.singleton(new JobResult.Builder().jobId(jobIdOfRecoveredDirtyJobs).applicationStatus(ApplicationStatus.SUCCEEDED).netRuntime(1).build())).setDispatcherBootstrapFactory((ignoredDispatcherGateway, ignoredScheduledExecutor, ignoredFatalErrorHandler) -> {
        dispatcherBootstrapLatch.trigger();
        return new NoOpDispatcherBootstrap();
    }).build();
    dispatcher.start();
    dispatcherBootstrapLatch.await();
    final TestingJobManagerRunner cleanupRunner = cleanupRunnerFactory.takeCreatedJobManagerRunner();
    assertThat("The CleanupJobManagerRunner has the wrong job ID attached.", cleanupRunner.getJobID(), is(jobIdOfRecoveredDirtyJobs));
    assertThat("No JobMaster should have been started.", jobManagerRunnerFactory.getQueueSize(), is(0));
}
Also used : JobResult(org.apache.flink.runtime.jobmaster.JobResult) TestingCleanupRunnerFactory(org.apache.flink.runtime.dispatcher.cleanup.TestingCleanupRunnerFactory) OneShotLatch(org.apache.flink.core.testutils.OneShotLatch) TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) JobID(org.apache.flink.api.common.JobID) Test(org.junit.Test)

Example 3 with TestingCleanupRunnerFactory

use of org.apache.flink.runtime.dispatcher.cleanup.TestingCleanupRunnerFactory in project flink by apache.

the class DefaultDispatcherRunnerITCase method leaderChange_withBlockingJobManagerTermination_doesNotAffectNewLeader.

/**
 * See FLINK-11843. This is a probabilistic test which needs to be executed several times to
 * fail.
 */
@Test
public void leaderChange_withBlockingJobManagerTermination_doesNotAffectNewLeader() throws Exception {
    final TestingJobMasterServiceLeadershipRunnerFactory jobManagerRunnerFactory = new TestingJobMasterServiceLeadershipRunnerFactory(1);
    final TestingCleanupRunnerFactory cleanupRunnerFactory = new TestingCleanupRunnerFactory();
    dispatcherRunnerFactory = DefaultDispatcherRunnerFactory.createSessionRunner(new TestingDispatcherFactory(jobManagerRunnerFactory, cleanupRunnerFactory));
    jobGraphStore = new SingleJobJobGraphStore(jobGraph);
    try (final DispatcherRunner dispatcherRunner = createDispatcherRunner()) {
        // initial run
        dispatcherLeaderElectionService.isLeader(UUID.randomUUID()).get();
        final TestingJobManagerRunner testingJobManagerRunner = jobManagerRunnerFactory.takeCreatedJobManagerRunner();
        dispatcherLeaderElectionService.notLeader();
        LOG.info("Re-grant leadership first time.");
        dispatcherLeaderElectionService.isLeader(UUID.randomUUID());
        // give the Dispatcher some time to recover jobs
        Thread.sleep(1L);
        dispatcherLeaderElectionService.notLeader();
        LOG.info("Re-grant leadership second time.");
        final UUID leaderSessionId = UUID.randomUUID();
        final CompletableFuture<UUID> leaderFuture = dispatcherLeaderElectionService.isLeader(leaderSessionId);
        assertThat(leaderFuture.isDone(), is(false));
        LOG.info("Complete the termination of the first job manager runner.");
        testingJobManagerRunner.completeTerminationFuture();
        assertThat(leaderFuture.get(TIMEOUT.toMilliseconds(), TimeUnit.MILLISECONDS), is(equalTo(leaderSessionId)));
        // Wait for job to recover...
        final DispatcherGateway leaderGateway = rpcServiceResource.getTestingRpcService().connect(dispatcherLeaderElectionService.getAddress(), DispatcherId.fromUuid(leaderSessionId), DispatcherGateway.class).get();
        assertEquals(jobGraph.getJobID(), Iterables.getOnlyElement(leaderGateway.listJobs(TIMEOUT).get()));
    }
}
Also used : TestingJobMasterServiceLeadershipRunnerFactory(org.apache.flink.runtime.dispatcher.TestingJobMasterServiceLeadershipRunnerFactory) SingleJobJobGraphStore(org.apache.flink.runtime.dispatcher.SingleJobJobGraphStore) TestingCleanupRunnerFactory(org.apache.flink.runtime.dispatcher.cleanup.TestingCleanupRunnerFactory) TestingJobManagerRunner(org.apache.flink.runtime.jobmaster.TestingJobManagerRunner) UUID(java.util.UUID) DispatcherGateway(org.apache.flink.runtime.dispatcher.DispatcherGateway) Test(org.junit.Test)

Aggregations

TestingCleanupRunnerFactory (org.apache.flink.runtime.dispatcher.cleanup.TestingCleanupRunnerFactory)3 TestingJobManagerRunner (org.apache.flink.runtime.jobmaster.TestingJobManagerRunner)2 Test (org.junit.Test)2 UUID (java.util.UUID)1 JobID (org.apache.flink.api.common.JobID)1 OneShotLatch (org.apache.flink.core.testutils.OneShotLatch)1 DispatcherGateway (org.apache.flink.runtime.dispatcher.DispatcherGateway)1 SingleJobJobGraphStore (org.apache.flink.runtime.dispatcher.SingleJobJobGraphStore)1 TestingJobMasterServiceLeadershipRunnerFactory (org.apache.flink.runtime.dispatcher.TestingJobMasterServiceLeadershipRunnerFactory)1 TestingHighAvailabilityServicesBuilder (org.apache.flink.runtime.highavailability.TestingHighAvailabilityServicesBuilder)1 JobResult (org.apache.flink.runtime.jobmaster.JobResult)1 Before (org.junit.Before)1