Java Code Examples for org.apache.flink.runtime.resourcemanager.slotmanager.SlotManagerBuilder

The following examples show how to use org.apache.flink.runtime.resourcemanager.slotmanager.SlotManagerBuilder. These examples are extracted from open source projects. 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 Project: Flink-CEPplus   Source File: YarnResourceManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
MockResourceManagerRuntimeServices() throws Exception {
	highAvailabilityServices = new TestingHighAvailabilityServices();
	rmLeaderElectionService = new TestingLeaderElectionService();
	highAvailabilityServices.setResourceManagerLeaderElectionService(rmLeaderElectionService);
	heartbeatServices = new TestingHeartbeatServices();
	metricRegistry = NoOpMetricRegistry.INSTANCE;
	slotManager = SlotManagerBuilder.newBuilder()
		.setScheduledExecutor(new ScheduledExecutorServiceAdapter(new DirectScheduledExecutorService()))
		.setTaskManagerRequestTimeout(Time.seconds(10))
		.setSlotRequestTimeout(Time.seconds(10))
		.setTaskManagerTimeout(Time.minutes(1))
		.build();
	jobLeaderIdService = new JobLeaderIdService(
			highAvailabilityServices,
			rpcService.getScheduledExecutor(),
			Time.minutes(5L));
}
 
Example 2
Source Project: flink   Source File: KubernetesResourceManagerTest.java    License: Apache License 2.0 6 votes vote down vote up
void runTest(RunnableWithException testMethod) throws Exception {
	if (slotManager == null) {
		WorkerResourceSpec workerResourceSpec = KubernetesWorkerResourceSpecFactory.INSTANCE
			.createDefaultWorkerResourceSpec(flinkConfig);
		slotManager = SlotManagerBuilder.newBuilder()
			.setDefaultWorkerResourceSpec(workerResourceSpec)
			.build();
		registerSlotProfile = SlotManagerImpl.generateDefaultSlotResourceProfile(workerResourceSpec, 1);
	}

	if (flinkKubeClient == null) {
		flinkKubeClient = KubernetesResourceManagerTest.this.flinkKubeClient;
	}

	resourceManager = createAndStartResourceManager(flinkConfig, slotManager, flinkKubeClient);

	try {
		testMethod.run();
	} finally {
		resourceManager.close();
	}
}
 
Example 3
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 4
Source Project: Flink-CEPplus   Source File: ResourceManagerTest.java    License: 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 5
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 6
Source Project: flink   Source File: ResourceManagerTaskExecutorTest.java    License: 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 7
Source Project: flink   Source File: MockResourceManagerRuntimeServices.java    License: Apache License 2.0 5 votes vote down vote up
public MockResourceManagerRuntimeServices(RpcService rpcService, Time timeout) {
	this(rpcService, timeout, SlotManagerBuilder.newBuilder()
		.setScheduledExecutor(new ScheduledExecutorServiceAdapter(new DirectScheduledExecutorService()))
		.setTaskManagerRequestTimeout(Time.seconds(10))
		.setSlotRequestTimeout(Time.seconds(10))
		.setTaskManagerTimeout(Time.minutes(1))
		.build());
}
 
Example 8
Source Project: flink   Source File: ResourceManagerTest.java    License: 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 9
Source Project: flink   Source File: ResourceManagerJobMasterTest.java    License: 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(),
		Time.minutes(5L));

	resourceManager.start();

	return resourceManager;
}
 
Example 10
Source Project: flink   Source File: YarnResourceManagerTest.java    License: Apache License 2.0 5 votes vote down vote up
Context(Configuration configuration, @Nullable SlotManager slotManager) throws  Exception {

			workerResourceSpec = YarnWorkerResourceSpecFactory.INSTANCE.createDefaultWorkerResourceSpec(configuration);
			if (slotManager == null) {
				slotManager = SlotManagerBuilder.newBuilder()
					.setDefaultWorkerResourceSpec(workerResourceSpec)
					.build();
			}
			rpcService = new TestingRpcService();
			rmServices = new MockResourceManagerRuntimeServices(rpcService, TIMEOUT, slotManager);

			// resource manager
			rmResourceID = ResourceID.generate();
			resourceManager =
					new TestingYarnResourceManager(
							rpcService,
							rmResourceID,
							configuration,
							env,
							rmServices.highAvailabilityServices,
							rmServices.heartbeatServices,
							rmServices.slotManager,
							rmServices.jobLeaderIdService,
							new ClusterInformation("localhost", 1234),
							testingFatalErrorHandler,
							null,
							UnregisteredMetricGroups.createUnregisteredResourceManagerMetricGroup());

			testingYarnAMRMClientAsync = resourceManager.testingYarnAMRMClientAsync;
			testingYarnNMClientAsync = resourceManager.testingYarnNMClientAsync;

			containerResource = resourceManager.getContainerResource(workerResourceSpec).get();
		}
 
Example 11
Source Project: flink   Source File: ResourceManagerTaskExecutorTest.java    License: 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,
			resourceManagerResourceID,
			highAvailabilityServices,
			heartbeatServices,
			slotManager,
			NoOpResourceManagerPartitionTracker::get,
			jobLeaderIdService,
			new ClusterInformation("localhost", 1234),
			fatalErrorHandler,
			UnregisteredMetricGroups.createUnregisteredResourceManagerMetricGroup(),
			Time.minutes(5L),
			RpcUtils.INF_TIMEOUT);

	resourceManager.start();

	return resourceManager;
}
 
Example 12
Source Project: flink   Source File: MockResourceManagerRuntimeServices.java    License: Apache License 2.0 5 votes vote down vote up
public MockResourceManagerRuntimeServices(RpcService rpcService, Time timeout) {
	this(rpcService, timeout, SlotManagerBuilder.newBuilder()
		.setScheduledExecutor(new ScheduledExecutorServiceAdapter(new DirectScheduledExecutorService()))
		.setTaskManagerRequestTimeout(Time.seconds(10))
		.setSlotRequestTimeout(Time.seconds(10))
		.setTaskManagerTimeout(Time.minutes(1))
		.build());
}
 
Example 13
Source Project: flink   Source File: ResourceManagerTest.java    License: 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,
		resourceManagerResourceId,
		highAvailabilityServices,
		heartbeatServices,
		slotManager,
		NoOpResourceManagerPartitionTracker::get,
		jobLeaderIdService,
		testingFatalErrorHandler,
		UnregisteredMetricGroups.createUnregisteredResourceManagerMetricGroup());

	resourceManager.start();

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

	return resourceManager;
}
 
Example 14
Source Project: flink   Source File: ResourceManagerJobMasterTest.java    License: 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,
		rmResourceId,
		haServices,
		heartbeatServices,
		slotManager,
		NoOpResourceManagerPartitionTracker::get,
		jobLeaderIdService,
		new ClusterInformation("localhost", 1234),
		testingFatalErrorHandler,
		UnregisteredMetricGroups.createUnregisteredResourceManagerMetricGroup(),
		Time.minutes(5L),
		RpcUtils.INF_TIMEOUT);

	resourceManager.start();

	return resourceManager;
}
 
Example 15
private ResourceManagerGateway createAndStartResourceManager() 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,
		ResourceID.generate(),
		highAvailabilityServices,
		new HeartbeatServices(100000L, 1000000L),
		slotManager,
		ResourceManagerPartitionTrackerImpl::new,
		jobLeaderIdService,
		testingFatalErrorHandler,
		UnregisteredMetricGroups.createUnregisteredResourceManagerMetricGroup());

	resourceManager.start();

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

	this.resourceManager = resourceManager;

	return resourceManager.getSelfGateway(ResourceManagerGateway.class);
}