org.apache.flink.runtime.dispatcher.SessionDispatcherFactory Java Examples

The following examples show how to use org.apache.flink.runtime.dispatcher.SessionDispatcherFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultDispatcherRunnerITCase.java    From flink with Apache License 2.0 6 votes vote down vote up
@Before
public void setup() {
	dispatcherRunnerFactory = DefaultDispatcherRunnerFactory.createSessionRunner(SessionDispatcherFactory.INSTANCE);
	jobGraph = createJobGraph();
	dispatcherLeaderElectionService = new TestingLeaderElectionService();
	fatalErrorHandler = new TestingFatalErrorHandler();
	jobGraphStore = TestingJobGraphStore.newBuilder().build();

	partialDispatcherServices = new PartialDispatcherServices(
		new Configuration(),
		new TestingHighAvailabilityServicesBuilder().build(),
		CompletableFuture::new,
		blobServerResource.getBlobServer(),
		new TestingHeartbeatServices(),
		UnregisteredMetricGroups::createUnregisteredJobManagerMetricGroup,
		new MemoryArchivedExecutionGraphStore(),
		fatalErrorHandler,
		VoidHistoryServerArchivist.INSTANCE,
		null);
}
 
Example #2
Source File: DefaultDispatcherResourceManagerComponentFactory.java    From flink with Apache License 2.0 5 votes vote down vote up
public static DefaultDispatcherResourceManagerComponentFactory createSessionComponentFactory(
		ResourceManagerFactory<?> resourceManagerFactory) {
	return new DefaultDispatcherResourceManagerComponentFactory(
		DefaultDispatcherRunnerFactory.createSessionRunner(SessionDispatcherFactory.INSTANCE),
		resourceManagerFactory,
		SessionRestEndpointFactory.INSTANCE);
}
 
Example #3
Source File: ApplicationClusterEntryPoint.java    From flink with Apache License 2.0 5 votes vote down vote up
@Override
protected DispatcherResourceManagerComponentFactory createDispatcherResourceManagerComponentFactory(final Configuration configuration) {
	return new DefaultDispatcherResourceManagerComponentFactory(
			new DefaultDispatcherRunnerFactory(
					ApplicationDispatcherLeaderProcessFactoryFactory
							.create(configuration, SessionDispatcherFactory.INSTANCE, program)),
			resourceManagerFactory,
			JobRestEndpointFactory.INSTANCE);
}
 
Example #4
Source File: SessionDispatcherResourceManagerComponentFactory.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
public SessionDispatcherResourceManagerComponentFactory(@Nonnull ResourceManagerFactory<?> resourceManagerFactory) {
	this(SessionDispatcherFactory.INSTANCE, resourceManagerFactory);
}
 
Example #5
Source File: SessionDispatcherResourceManagerComponentFactory.java    From flink with Apache License 2.0 4 votes vote down vote up
public SessionDispatcherResourceManagerComponentFactory(@Nonnull ResourceManagerFactory<?> resourceManagerFactory) {
	this(SessionDispatcherFactory.INSTANCE, resourceManagerFactory);
}
 
Example #6
Source File: ZooKeeperDefaultDispatcherRunnerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * 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);
	try (final TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServicesBuilder()
			.setRunningJobsRegistry(new ZooKeeperRunningJobsRegistry(client, configuration))
			.setDispatcherLeaderElectionService(dispatcherLeaderElectionService)
			.setJobMasterLeaderRetrieverFunction(jobId -> ZooKeeperUtils.createLeaderRetrievalService(client, configuration))
			.build()) {

		final PartialDispatcherServices partialDispatcherServices = new PartialDispatcherServices(
			configuration,
			highAvailabilityServices,
			CompletableFuture::new,
			blobServer,
			new TestingHeartbeatServices(),
			UnregisteredMetricGroups::createUnregisteredJobManagerMetricGroup,
			new MemoryArchivedExecutionGraphStore(),
			fatalErrorHandler,
			VoidHistoryServerArchivist.INSTANCE,
			null);

		final JobGraph jobGraph = createJobGraphWithBlobs();

		final DefaultDispatcherRunnerFactory defaultDispatcherRunnerFactory = DefaultDispatcherRunnerFactory.createSessionRunner(SessionDispatcherFactory.INSTANCE);

		try (final DispatcherRunner dispatcherRunner = createDispatcherRunner(
			rpcService,
			dispatcherLeaderElectionService,
			() -> createZooKeeperJobGraphStore(client),
			partialDispatcherServices,
			defaultDispatcherRunnerFactory)) {

			// initial run
			DispatcherGateway dispatcherGateway = grantLeadership(dispatcherLeaderElectionService);

			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 ZooKeeperJobGraphStore submittedJobGraphStore = createZooKeeperJobGraphStore(client);

			CommonTestUtils.waitUntilCondition(() -> submittedJobGraphStore.getJobIds().isEmpty(), Deadline.fromNow(VERIFICATION_TIMEOUT), 20L);
		}
	}

	// check resource clean up
	assertThat(clusterHaStorageDir.listFiles(), is(emptyArray()));
}