Java Code Examples for org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups#createUnregisteredJobManagerMetricGroup()

The following examples show how to use org.apache.flink.runtime.metrics.groups.UnregisteredMetricGroups#createUnregisteredJobManagerMetricGroup() . 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: DispatcherResourceCleanupTest.java    From flink with Apache License 2.0 6 votes vote down vote up
private void startDispatcher(JobManagerRunnerFactory jobManagerRunnerFactory) throws Exception {
	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
	final HeartbeatServices heartbeatServices = new HeartbeatServices(1000L, 1000L);
	final MemoryArchivedExecutionGraphStore archivedExecutionGraphStore = new MemoryArchivedExecutionGraphStore();
	dispatcher = new TestingDispatcher(
		rpcService,
		DispatcherId.generate(),
		new DefaultDispatcherBootstrap(Collections.emptyList()),
		new DispatcherServices(
			configuration,
			highAvailabilityServices,
			() -> CompletableFuture.completedFuture(resourceManagerGateway),
			blobServer,
			heartbeatServices,
			archivedExecutionGraphStore,
			testingFatalErrorHandlerResource.getFatalErrorHandler(),
			VoidHistoryServerArchivist.INSTANCE,
			null,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
			jobGraphWriter,
			jobManagerRunnerFactory));

	dispatcher.start();

	dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);
}
 
Example 2
Source File: DispatcherHATest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
private HATestingDispatcher createDispatcher(
	HighAvailabilityServices highAvailabilityServices,
	@Nonnull Queue<DispatcherId> fencingTokens,
	JobManagerRunnerFactory jobManagerRunnerFactory) throws Exception {
	final Configuration configuration = new Configuration();

	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
	return new HATestingDispatcher(
		rpcService,
		UUID.randomUUID().toString(),
		configuration,
		highAvailabilityServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		new BlobServer(configuration, new VoidBlobStore()),
		new HeartbeatServices(1000L, 1000L),
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		new MemoryArchivedExecutionGraphStore(),
		jobManagerRunnerFactory,
		testingFatalErrorHandler,
		fencingTokens);
}
 
Example 3
Source File: ZooKeeperHADispatcherTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
private TestingDispatcher createDispatcher(HighAvailabilityServices highAvailabilityServices, JobManagerRunnerFactory jobManagerRunnerFactory) throws Exception {
	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
	return new TestingDispatcher(
		rpcService,
		Dispatcher.DISPATCHER_NAME + '_' + name.getMethodName() + UUID.randomUUID(),
		configuration,
		highAvailabilityServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		blobServer,
		new HeartbeatServices(1000L, 1000L),
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		new MemoryArchivedExecutionGraphStore(),
		jobManagerRunnerFactory,
		testingFatalErrorHandler);
}
 
Example 4
Source File: DispatcherTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
private TestingDispatcher createDispatcher(HeartbeatServices heartbeatServices, TestingHighAvailabilityServices haServices, JobManagerRunnerFactory jobManagerRunnerFactory) throws Exception {
	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
	return new TestingDispatcher(
		rpcService,
		Dispatcher.DISPATCHER_NAME + '_' + name.getMethodName(),
		configuration,
		haServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		blobServer,
		heartbeatServices,
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		new MemoryArchivedExecutionGraphStore(),
		jobManagerRunnerFactory,
		fatalErrorHandler);
}
 
Example 5
Source File: MiniDispatcherTest.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
@Nonnull
private MiniDispatcher createMiniDispatcher(ClusterEntrypoint.ExecutionMode executionMode) throws Exception {
	return new MiniDispatcher(
		rpcService,
		UUID.randomUUID().toString(),
		configuration,
		highAvailabilityServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		blobServer,
		heartbeatServices,
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		archivedExecutionGraphStore,
		testingJobManagerRunnerFactory,
		testingFatalErrorHandler,
		VoidHistoryServerArchivist.INSTANCE,
		jobGraph,
		executionMode);
}
 
Example 6
Source File: MiniDispatcherTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private MiniDispatcher createMiniDispatcher(ClusterEntrypoint.ExecutionMode executionMode) throws Exception {
	return new MiniDispatcher(
		rpcService,
		UUID.randomUUID().toString(),
		configuration,
		highAvailabilityServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		blobServer,
		heartbeatServices,
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		archivedExecutionGraphStore,
		testingJobManagerRunnerFactory,
		testingFatalErrorHandler,
		VoidHistoryServerArchivist.INSTANCE,
		jobGraph,
		executionMode);
}
 
Example 7
Source File: MiniDispatcherTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private MiniDispatcher createMiniDispatcher(ClusterEntrypoint.ExecutionMode executionMode) throws Exception {
	return new MiniDispatcher(
		rpcService,
		DispatcherId.generate(),
		new DispatcherServices(
			configuration,
			highAvailabilityServices,
			() -> CompletableFuture.completedFuture(resourceManagerGateway),
			blobServer,
			heartbeatServices,
			archivedExecutionGraphStore,
			testingFatalErrorHandlerResource.getFatalErrorHandler(),
			VoidHistoryServerArchivist.INSTANCE,
			null,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
			highAvailabilityServices.getJobGraphStore(),
			testingJobManagerRunnerFactory),
		new DefaultDispatcherBootstrap(Collections.singletonList(jobGraph)),
		executionMode);
}
 
Example 8
Source File: ZooKeeperHADispatcherTest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private TestingDispatcher createDispatcher(HighAvailabilityServices highAvailabilityServices, JobManagerRunnerFactory jobManagerRunnerFactory) throws Exception {
	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
	return new TestingDispatcher(
		rpcService,
		Dispatcher.DISPATCHER_NAME + '_' + name.getMethodName() + UUID.randomUUID(),
		configuration,
		highAvailabilityServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		blobServer,
		new HeartbeatServices(1000L, 1000L),
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		new MemoryArchivedExecutionGraphStore(),
		jobManagerRunnerFactory,
		testingFatalErrorHandler);
}
 
Example 9
Source File: DispatcherTest.java    From flink with Apache License 2.0 6 votes vote down vote up
TestingDispatcher build() throws Exception {
	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();

	final MemoryArchivedExecutionGraphStore archivedExecutionGraphStore = new MemoryArchivedExecutionGraphStore();

	return new TestingDispatcher(
		rpcService,
		DispatcherId.generate(),
		dispatcherBootstrap,
		new DispatcherServices(
			configuration,
			haServices,
			() -> CompletableFuture.completedFuture(resourceManagerGateway),
			blobServer,
			heartbeatServices,
			archivedExecutionGraphStore,
			testingFatalErrorHandlerResource.getFatalErrorHandler(),
			VoidHistoryServerArchivist.INSTANCE,
			null,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
			jobGraphWriter,
			jobManagerRunnerFactory));
}
 
Example 10
Source File: DispatcherHATest.java    From flink with Apache License 2.0 6 votes vote down vote up
@Nonnull
private HATestingDispatcher createDispatcher(
	HighAvailabilityServices highAvailabilityServices,
	@Nonnull Queue<DispatcherId> fencingTokens,
	JobManagerRunnerFactory jobManagerRunnerFactory) throws Exception {
	final Configuration configuration = new Configuration();

	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
	return new HATestingDispatcher(
		rpcService,
		UUID.randomUUID().toString(),
		configuration,
		highAvailabilityServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		new BlobServer(configuration, new VoidBlobStore()),
		new HeartbeatServices(1000L, 1000L),
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		new MemoryArchivedExecutionGraphStore(),
		jobManagerRunnerFactory,
		testingFatalErrorHandler,
		fencingTokens);
}
 
Example 11
Source File: ResourceManagerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private TestingResourceManager createAndStartResourceManager(HeartbeatServices heartbeatServices) throws Exception {
	final SlotManager slotManager = SlotManagerBuilder.newBuilder()
		.setScheduledExecutor(rpcService.getScheduledExecutor())
		.build();
	final JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(
		highAvailabilityServices,
		rpcService.getScheduledExecutor(),
		TestingUtils.infiniteTime());

	final TestingResourceManager resourceManager = new TestingResourceManager(
		rpcService,
		ResourceManager.RESOURCE_MANAGER_NAME + UUID.randomUUID(),
		resourceManagerResourceId,
		highAvailabilityServices,
		heartbeatServices,
		slotManager,
		NoOpMetricRegistry.INSTANCE,
		jobLeaderIdService,
		testingFatalErrorHandler,
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup());

	resourceManager.start();

	// first make the ResourceManager the leader
	resourceManagerId = ResourceManagerId.generate();
	resourceManagerLeaderElectionService.isLeader(resourceManagerId.toUUID()).get();

	return resourceManager;
}
 
Example 12
Source File: ResourceManagerTaskExecutorTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private StandaloneResourceManager createAndStartResourceManager(LeaderElectionService rmLeaderElectionService, FatalErrorHandler fatalErrorHandler) throws Exception {
	TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
	HeartbeatServices heartbeatServices = new HeartbeatServices(1000L, HEARTBEAT_TIMEOUT);
	highAvailabilityServices.setResourceManagerLeaderElectionService(rmLeaderElectionService);

	SlotManager slotManager = SlotManagerBuilder.newBuilder()
		.setScheduledExecutor(rpcService.getScheduledExecutor())
		.build();

	JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(
		highAvailabilityServices,
		rpcService.getScheduledExecutor(),
		Time.minutes(5L));

	StandaloneResourceManager resourceManager =
		new StandaloneResourceManager(
			rpcService,
			ResourceManager.RESOURCE_MANAGER_NAME + UUID.randomUUID(),
			resourceManagerResourceID,
			highAvailabilityServices,
			heartbeatServices,
			slotManager,
			NoOpMetricRegistry.INSTANCE,
			jobLeaderIdService,
			new ClusterInformation("localhost", 1234),
			fatalErrorHandler,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
			Time.minutes(5L));

	resourceManager.start();

	return resourceManager;
}
 
Example 13
Source File: StandaloneResourceManagerTest.java    From flink with Apache License 2.0 5 votes vote down vote up
private TestingStandaloneResourceManager createResourceManager(Time startupPeriod, SlotManager slotManager) throws Exception {

		final MockResourceManagerRuntimeServices rmServices = new MockResourceManagerRuntimeServices(
			RPC_SERVICE.getTestingRpcService(),
			TIMEOUT,
			slotManager);

		final TestingStandaloneResourceManager rm = new TestingStandaloneResourceManager(
			rmServices.rpcService,
			UUID.randomUUID().toString(),
			ResourceID.generate(),
			rmServices.highAvailabilityServices,
			rmServices.heartbeatServices,
			rmServices.slotManager,
			rmServices.metricRegistry,
			rmServices.jobLeaderIdService,
			new ClusterInformation("localhost", 1234),
			fatalErrorHandler,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
			startupPeriod,
			rmServices);

		rm.start();
		rmServices.grantLeadership();

		return rm;
	}
 
Example 14
Source File: ResourceManagerJobMasterTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private ResourceManager<?> createAndStartResourceManager() throws Exception {
	ResourceID rmResourceId = ResourceID.generate();

	HeartbeatServices heartbeatServices = new HeartbeatServices(1000L, 1000L);

	JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(
		haServices,
		rpcService.getScheduledExecutor(),
		Time.minutes(5L));

	final SlotManager slotManager = SlotManagerBuilder.newBuilder()
		.setScheduledExecutor(rpcService.getScheduledExecutor())
		.build();

	ResourceManager<?> resourceManager = new StandaloneResourceManager(
		rpcService,
		ResourceManager.RESOURCE_MANAGER_NAME,
		rmResourceId,
		haServices,
		heartbeatServices,
		slotManager,
		NoOpMetricRegistry.INSTANCE,
		jobLeaderIdService,
		new ClusterInformation("localhost", 1234),
		testingFatalErrorHandler,
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup());

	resourceManager.start();

	return resourceManager;
}
 
Example 15
Source File: ResourceManagerTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private TestingResourceManager createAndStartResourceManager(HeartbeatServices heartbeatServices) throws Exception {
	final SlotManager slotManager = SlotManagerBuilder.newBuilder()
		.setScheduledExecutor(rpcService.getScheduledExecutor())
		.build();
	final JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(
		highAvailabilityServices,
		rpcService.getScheduledExecutor(),
		TestingUtils.infiniteTime());

	final TestingResourceManager resourceManager = new TestingResourceManager(
		rpcService,
		ResourceManager.RESOURCE_MANAGER_NAME + UUID.randomUUID(),
		resourceManagerResourceId,
		highAvailabilityServices,
		heartbeatServices,
		slotManager,
		NoOpMetricRegistry.INSTANCE,
		jobLeaderIdService,
		testingFatalErrorHandler,
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup());

	resourceManager.start();

	// first make the ResourceManager the leader
	resourceManagerId = ResourceManagerId.generate();
	resourceManagerLeaderElectionService.isLeader(resourceManagerId.toUUID()).get();

	return resourceManager;
}
 
Example 16
Source File: ResourceManagerTaskExecutorTest.java    From Flink-CEPplus with Apache License 2.0 5 votes vote down vote up
private StandaloneResourceManager createAndStartResourceManager(LeaderElectionService rmLeaderElectionService, FatalErrorHandler fatalErrorHandler) throws Exception {
	TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
	HeartbeatServices heartbeatServices = new HeartbeatServices(1000L, HEARTBEAT_TIMEOUT);
	highAvailabilityServices.setResourceManagerLeaderElectionService(rmLeaderElectionService);

	SlotManager slotManager = SlotManagerBuilder.newBuilder()
		.setScheduledExecutor(rpcService.getScheduledExecutor())
		.build();

	JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(
		highAvailabilityServices,
		rpcService.getScheduledExecutor(),
		Time.minutes(5L));

	StandaloneResourceManager resourceManager =
		new StandaloneResourceManager(
			rpcService,
			ResourceManager.RESOURCE_MANAGER_NAME + UUID.randomUUID(),
			resourceManagerResourceID,
			highAvailabilityServices,
			heartbeatServices,
			slotManager,
			NoOpMetricRegistry.INSTANCE,
			jobLeaderIdService,
			new ClusterInformation("localhost", 1234),
			fatalErrorHandler,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup());

	resourceManager.start();

	return resourceManager;
}
 
Example 17
Source File: DispatcherResourceCleanupTest.java    From flink with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
	final JobVertex testVertex = new JobVertex("testVertex");
	testVertex.setInvokableClass(NoOpInvokable.class);
	jobId = new JobID();
	jobGraph = new JobGraph(jobId, "testJob", testVertex);
	jobGraph.setAllowQueuedScheduling(true);

	configuration = new Configuration();
	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	highAvailabilityServices = new TestingHighAvailabilityServices();
	dispatcherLeaderElectionService = new TestingLeaderElectionService();
	highAvailabilityServices.setDispatcherLeaderElectionService(dispatcherLeaderElectionService);
	clearedJobLatch = new OneShotLatch();
	runningJobsRegistry = new SingleRunningJobsRegistry(jobId, clearedJobLatch);
	highAvailabilityServices.setRunningJobsRegistry(runningJobsRegistry);
	submittedJobGraphStore = new FaultySubmittedJobGraphStore();
	highAvailabilityServices.setSubmittedJobGraphStore(submittedJobGraphStore);

	storedHABlobFuture = new CompletableFuture<>();
	deleteAllHABlobsFuture = new CompletableFuture<>();

	final TestingBlobStore testingBlobStore = new TestingBlobStoreBuilder()
		.setPutFunction(
			putArguments -> storedHABlobFuture.complete(putArguments.f2))
		.setDeleteAllFunction(deleteAllHABlobsFuture::complete)
		.createTestingBlobStore();

	cleanupJobFuture = new CompletableFuture<>();
	terminationFuture = new CompletableFuture<>();

	blobServer = new TestingBlobServer(configuration, testingBlobStore, cleanupJobFuture);

	// upload a blob to the blob server
	permanentBlobKey = blobServer.putPermanent(jobId, new byte[256]);
	jobGraph.addUserJarBlobKey(permanentBlobKey);
	blobFile = blobServer.getStorageLocation(jobId, permanentBlobKey);

	resultFuture = new CompletableFuture<>();

	fatalErrorHandler = new TestingFatalErrorHandler();

	failJobMasterCreationWith = new AtomicReference<>();

	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
	dispatcher = new TestingDispatcher(
		rpcService,
		Dispatcher.DISPATCHER_NAME + UUID.randomUUID(),
		configuration,
		highAvailabilityServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		blobServer,
		new HeartbeatServices(1000L, 1000L),
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		new MemoryArchivedExecutionGraphStore(),
		new TestingJobManagerRunnerFactory(new CompletableFuture<>(), resultFuture, terminationFuture, failJobMasterCreationWith),
		fatalErrorHandler);

	dispatcher.start();

	dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);

	dispatcherLeaderElectionService.isLeader(UUID.randomUUID()).get();

	assertThat(blobFile.exists(), is(true));

	// verify that we stored the blob also in the BlobStore
	assertThat(storedHABlobFuture.get(), equalTo(permanentBlobKey));
}
 
Example 18
Source File: MesosResourceManagerTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
/**
 * Create mock RM dependencies.
 */
Context() throws Exception {
	rpcService = new TestingRpcService();
	fatalErrorHandler = new TestingFatalErrorHandler();
	rmServices = new MockMesosResourceManagerRuntimeServices();
	mesosServices = new MockMesosServices();

	// TaskExecutor templating
	ContainerSpecification containerSpecification = new ContainerSpecification();
	ContaineredTaskManagerParameters containeredParams =
		new ContaineredTaskManagerParameters(1024, 768, 256, 4, new HashMap<String, String>());
	MesosTaskManagerParameters tmParams = new MesosTaskManagerParameters(
		1.0, 1, MesosTaskManagerParameters.ContainerType.MESOS, Option.<String>empty(), containeredParams,
		Collections.<Protos.Volume>emptyList(), Collections.<Protos.Parameter>emptyList(), false,
		Collections.<ConstraintEvaluator>emptyList(), "", Option.<String>empty(),
		Option.<String>empty(), Collections.<String>emptyList());

	// resource manager
	rmResourceID = ResourceID.generate();
	resourceManager =
		new TestingMesosResourceManager(
			rpcService,
			RM_ADDRESS,
			rmResourceID,
			rmServices.highAvailabilityServices,
			rmServices.heartbeatServices,
			rmServices.slotManager,
			rmServices.metricRegistry,
			rmServices.jobLeaderIdService,
			fatalErrorHandler,
			// Mesos specifics
			flinkConfig,
			mesosServices,
			rmServices.mesosConfig,
			tmParams,
			containerSpecification,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup());

	// TaskExecutors
	task1Executor = mockTaskExecutor(task1);
	task2Executor = mockTaskExecutor(task2);
	task3Executor = mockTaskExecutor(task3);

	// JobMaster
	jobMaster1 = mockJobMaster(rmServices, new JobID(1, 0));
}
 
Example 19
Source File: MesosResourceManagerTest.java    From flink with Apache License 2.0 4 votes vote down vote up
/**
 * Create mock RM dependencies.
 */
Context() throws Exception {
	rpcService = new TestingRpcService();
	fatalErrorHandler = new TestingFatalErrorHandler();
	rmServices = new MockMesosResourceManagerRuntimeServices();
	mesosServices = new MockMesosServices();

	// TaskExecutor templating
	ContainerSpecification containerSpecification = new ContainerSpecification();
	ContaineredTaskManagerParameters containeredParams =
		new ContaineredTaskManagerParameters(1024, 768, 256, 4, new HashMap<String, String>());
	MesosTaskManagerParameters tmParams = new MesosTaskManagerParameters(
		1.0, 1, 0, MesosTaskManagerParameters.ContainerType.MESOS, Option.<String>empty(), containeredParams,
		Collections.<Protos.Volume>emptyList(), Collections.<Protos.Parameter>emptyList(), false,
		Collections.<ConstraintEvaluator>emptyList(), "", Option.<String>empty(),
		Option.<String>empty(), Collections.<String>emptyList());

	// resource manager
	rmResourceID = ResourceID.generate();
	resourceManager =
		new TestingMesosResourceManager(
			rpcService,
			RM_ADDRESS,
			rmResourceID,
			rmServices.highAvailabilityServices,
			rmServices.heartbeatServices,
			rmServices.slotManager,
			rmServices.metricRegistry,
			rmServices.jobLeaderIdService,
			fatalErrorHandler,
			// Mesos specifics
			flinkConfig,
			mesosServices,
			rmServices.mesosConfig,
			tmParams,
			containerSpecification,
			UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup());

	// TaskExecutors
	task1Executor = mockTaskExecutor(task1);
	task2Executor = mockTaskExecutor(task2);
	task3Executor = mockTaskExecutor(task3);

	// JobMaster
	jobMaster1 = mockJobMaster(rmServices, new JobID(1, 0));
}
 
Example 20
Source File: DispatcherResourceCleanupTest.java    From Flink-CEPplus with Apache License 2.0 4 votes vote down vote up
@Before
public void setup() throws Exception {
	final JobVertex testVertex = new JobVertex("testVertex");
	testVertex.setInvokableClass(NoOpInvokable.class);
	jobId = new JobID();
	jobGraph = new JobGraph(jobId, "testJob", testVertex);
	jobGraph.setAllowQueuedScheduling(true);

	configuration = new Configuration();
	configuration.setString(BlobServerOptions.STORAGE_DIRECTORY, temporaryFolder.newFolder().getAbsolutePath());

	highAvailabilityServices = new TestingHighAvailabilityServices();
	dispatcherLeaderElectionService = new TestingLeaderElectionService();
	highAvailabilityServices.setDispatcherLeaderElectionService(dispatcherLeaderElectionService);
	clearedJobLatch = new OneShotLatch();
	runningJobsRegistry = new SingleRunningJobsRegistry(jobId, clearedJobLatch);
	highAvailabilityServices.setRunningJobsRegistry(runningJobsRegistry);
	submittedJobGraphStore = new FaultySubmittedJobGraphStore();
	highAvailabilityServices.setSubmittedJobGraphStore(submittedJobGraphStore);

	storedHABlobFuture = new CompletableFuture<>();
	deleteAllHABlobsFuture = new CompletableFuture<>();

	final TestingBlobStore testingBlobStore = new TestingBlobStoreBuilder()
		.setPutFunction(
			putArguments -> storedHABlobFuture.complete(putArguments.f2))
		.setDeleteAllFunction(deleteAllHABlobsFuture::complete)
		.createTestingBlobStore();

	cleanupJobFuture = new CompletableFuture<>();
	terminationFuture = new CompletableFuture<>();

	blobServer = new TestingBlobServer(configuration, testingBlobStore, cleanupJobFuture);

	// upload a blob to the blob server
	permanentBlobKey = blobServer.putPermanent(jobId, new byte[256]);
	jobGraph.addUserJarBlobKey(permanentBlobKey);
	blobFile = blobServer.getStorageLocation(jobId, permanentBlobKey);

	resultFuture = new CompletableFuture<>();

	fatalErrorHandler = new TestingFatalErrorHandler();

	failJobMasterCreationWith = new AtomicReference<>();

	TestingResourceManagerGateway resourceManagerGateway = new TestingResourceManagerGateway();
	dispatcher = new TestingDispatcher(
		rpcService,
		Dispatcher.DISPATCHER_NAME + UUID.randomUUID(),
		configuration,
		highAvailabilityServices,
		() -> CompletableFuture.completedFuture(resourceManagerGateway),
		blobServer,
		new HeartbeatServices(1000L, 1000L),
		UnregisteredMetricGroups.createUnregisteredJobManagerMetricGroup(),
		null,
		new MemoryArchivedExecutionGraphStore(),
		new TestingJobManagerRunnerFactory(new CompletableFuture<>(), resultFuture, terminationFuture, failJobMasterCreationWith),
		fatalErrorHandler);

	dispatcher.start();

	dispatcherGateway = dispatcher.getSelfGateway(DispatcherGateway.class);

	dispatcherLeaderElectionService.isLeader(UUID.randomUUID()).get();

	assertThat(blobFile.exists(), is(true));

	// verify that we stored the blob also in the BlobStore
	assertThat(storedHABlobFuture.get(), equalTo(permanentBlobKey));
}