Java Code Examples for org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices#setJobMasterLeaderRetriever()

The following examples show how to use org.apache.flink.runtime.highavailability.TestingHighAvailabilityServices#setJobMasterLeaderRetriever() . 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   File: TaskExecutorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	rpc = new TestingRpcService();
	timerService = new TimerService<>(TestingUtils.defaultExecutor(), timeout.toMilliseconds());

	dummyBlobCacheService = new BlobCacheService(
		new Configuration(),
		new VoidBlobStore(),
		null);

	configuration = new Configuration();
	taskManagerConfiguration = TaskManagerConfiguration.fromConfiguration(configuration);

	taskManagerLocation = new LocalTaskManagerLocation();
	jobId = new JobID();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderRetriever = new SettableLeaderRetrievalService();
	jobManagerLeaderRetriever = new SettableLeaderRetrievalService();
	haServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
	haServices.setJobMasterLeaderRetriever(jobId, jobManagerLeaderRetriever);
}
 
Example 2
Source Project: flink   File: TaskExecutorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	rpc = new TestingRpcService();
	timerService = new TimerService<>(TestingUtils.defaultExecutor(), timeout.toMilliseconds());

	dummyBlobCacheService = new BlobCacheService(
		new Configuration(),
		new VoidBlobStore(),
		null);

	configuration = new Configuration();
	taskManagerConfiguration = TaskManagerConfiguration.fromConfiguration(configuration);

	taskManagerLocation = new LocalTaskManagerLocation();
	jobId = new JobID();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderRetriever = new SettableLeaderRetrievalService();
	jobManagerLeaderRetriever = new SettableLeaderRetrievalService();
	haServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
	haServices.setJobMasterLeaderRetriever(jobId, jobManagerLeaderRetriever);

	nettyShuffleEnvironment = new NettyShuffleEnvironmentBuilder().build();
}
 
Example 3
Source Project: flink   File: TaskExecutorTest.java    License: Apache License 2.0 6 votes vote down vote up
@Before
public void setup() throws IOException {
	rpc = new TestingRpcService();

	dummyBlobCacheService = new BlobCacheService(
		new Configuration(),
		new VoidBlobStore(),
		null);

	configuration = new Configuration();

	unresolvedTaskManagerLocation = new LocalUnresolvedTaskManagerLocation();
	jobId = new JobID();

	testingFatalErrorHandler = new TestingFatalErrorHandler();

	haServices = new TestingHighAvailabilityServices();
	resourceManagerLeaderRetriever = new SettableLeaderRetrievalService();
	jobManagerLeaderRetriever = new SettableLeaderRetrievalService();
	haServices.setResourceManagerLeaderRetriever(resourceManagerLeaderRetriever);
	haServices.setJobMasterLeaderRetriever(jobId, jobManagerLeaderRetriever);

	nettyShuffleEnvironment = new NettyShuffleEnvironmentBuilder().build();
}
 
Example 4
/**
 * Tests that the initial job registration registers a timeout which will call
 * {@link JobLeaderIdActions#notifyJobTimeout(JobID, UUID)} when executed.
 */
@Test
public void testInitialJobTimeout() throws Exception {
	final JobID jobId = new JobID();
	TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
	SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService(
		null,
		null);

	highAvailabilityServices.setJobMasterLeaderRetriever(jobId, leaderRetrievalService);

	ScheduledExecutor scheduledExecutor = mock(ScheduledExecutor.class);
	Time timeout = Time.milliseconds(5000L);
	JobLeaderIdActions jobLeaderIdActions = mock(JobLeaderIdActions.class);

	JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(
		highAvailabilityServices,
		scheduledExecutor,
		timeout);

	jobLeaderIdService.start(jobLeaderIdActions);

	jobLeaderIdService.addJob(jobId);

	assertTrue(jobLeaderIdService.containsJob(jobId));

	ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class);
	verify(scheduledExecutor).schedule(runnableArgumentCaptor.capture(), anyLong(), any(TimeUnit.class));

	Runnable timeoutRunnable = runnableArgumentCaptor.getValue();
	timeoutRunnable.run();

	ArgumentCaptor<UUID> timeoutIdArgumentCaptor = ArgumentCaptor.forClass(UUID.class);

	verify(jobLeaderIdActions, times(1)).notifyJobTimeout(eq(jobId), timeoutIdArgumentCaptor.capture());

	assertTrue(jobLeaderIdService.isValidTimeout(jobId, timeoutIdArgumentCaptor.getValue()));
}
 
Example 5
Source Project: flink   File: JobLeaderIdServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the initial job registration registers a timeout which will call
 * {@link JobLeaderIdActions#notifyJobTimeout(JobID, UUID)} when executed.
 */
@Test
public void testInitialJobTimeout() throws Exception {
	final JobID jobId = new JobID();
	TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
	SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService(
		null,
		null);

	highAvailabilityServices.setJobMasterLeaderRetriever(jobId, leaderRetrievalService);

	ScheduledExecutor scheduledExecutor = mock(ScheduledExecutor.class);
	Time timeout = Time.milliseconds(5000L);
	JobLeaderIdActions jobLeaderIdActions = mock(JobLeaderIdActions.class);

	JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(
		highAvailabilityServices,
		scheduledExecutor,
		timeout);

	jobLeaderIdService.start(jobLeaderIdActions);

	jobLeaderIdService.addJob(jobId);

	assertTrue(jobLeaderIdService.containsJob(jobId));

	ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class);
	verify(scheduledExecutor).schedule(runnableArgumentCaptor.capture(), anyLong(), any(TimeUnit.class));

	Runnable timeoutRunnable = runnableArgumentCaptor.getValue();
	timeoutRunnable.run();

	ArgumentCaptor<UUID> timeoutIdArgumentCaptor = ArgumentCaptor.forClass(UUID.class);

	verify(jobLeaderIdActions, times(1)).notifyJobTimeout(eq(jobId), timeoutIdArgumentCaptor.capture());

	assertTrue(jobLeaderIdService.isValidTimeout(jobId, timeoutIdArgumentCaptor.getValue()));
}
 
Example 6
Source Project: flink   File: JobLeaderIdServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Tests that the initial job registration registers a timeout which will call
 * {@link JobLeaderIdActions#notifyJobTimeout(JobID, UUID)} when executed.
 */
@Test
public void testInitialJobTimeout() throws Exception {
	final JobID jobId = new JobID();
	TestingHighAvailabilityServices highAvailabilityServices = new TestingHighAvailabilityServices();
	SettableLeaderRetrievalService leaderRetrievalService = new SettableLeaderRetrievalService(
		null,
		null);

	highAvailabilityServices.setJobMasterLeaderRetriever(jobId, leaderRetrievalService);

	ScheduledExecutor scheduledExecutor = mock(ScheduledExecutor.class);
	Time timeout = Time.milliseconds(5000L);
	JobLeaderIdActions jobLeaderIdActions = mock(JobLeaderIdActions.class);

	JobLeaderIdService jobLeaderIdService = new JobLeaderIdService(
		highAvailabilityServices,
		scheduledExecutor,
		timeout);

	jobLeaderIdService.start(jobLeaderIdActions);

	jobLeaderIdService.addJob(jobId);

	assertTrue(jobLeaderIdService.containsJob(jobId));

	ArgumentCaptor<Runnable> runnableArgumentCaptor = ArgumentCaptor.forClass(Runnable.class);
	verify(scheduledExecutor).schedule(runnableArgumentCaptor.capture(), anyLong(), any(TimeUnit.class));

	Runnable timeoutRunnable = runnableArgumentCaptor.getValue();
	timeoutRunnable.run();

	ArgumentCaptor<UUID> timeoutIdArgumentCaptor = ArgumentCaptor.forClass(UUID.class);

	verify(jobLeaderIdActions, times(1)).notifyJobTimeout(eq(jobId), timeoutIdArgumentCaptor.capture());

	assertTrue(jobLeaderIdService.isValidTimeout(jobId, timeoutIdArgumentCaptor.getValue()));
}