Java Code Examples for org.apache.flink.runtime.concurrent.ScheduledExecutorServiceAdapter

The following examples show how to use org.apache.flink.runtime.concurrent.ScheduledExecutorServiceAdapter. 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: JobStatusPollingUtilsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testPolling() {
	final int maxAttemptCounter = 3;
	final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
	try {
		final ScheduledExecutor scheduledExecutor = new ScheduledExecutorServiceAdapter(executor);

		final CallCountingJobStatusSupplier jobStatusSupplier = new CallCountingJobStatusSupplier(maxAttemptCounter);

		final CompletableFuture<JobResult> result = JobStatusPollingUtils.pollJobResultAsync(
				jobStatusSupplier,
				() -> CompletableFuture.completedFuture(createSuccessfulJobResult(new JobID(0, 0))),
				scheduledExecutor,
				10
		);

		result.join();

		assertThat(jobStatusSupplier.getAttemptCounter(), is(equalTo(maxAttemptCounter)));

	} finally {
		ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, executor);
	}
}
 
Example 3
Source Project: flink   Source File: JobStatusPollingUtilsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testHappyPath() throws ExecutionException, InterruptedException {
	final int maxAttemptCounter = 1;
	final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
	try {
		final ScheduledExecutor scheduledExecutor = new ScheduledExecutorServiceAdapter(executor);

		final CallCountingJobStatusSupplier jobStatusSupplier = new CallCountingJobStatusSupplier(maxAttemptCounter);

		final CompletableFuture<JobResult> result = JobStatusPollingUtils.pollJobResultAsync(
				jobStatusSupplier,
				() -> CompletableFuture.completedFuture(createSuccessfulJobResult(new JobID(0, 0))),
				scheduledExecutor,
				10
		);

		result.join();

		assertThat(jobStatusSupplier.getAttemptCounter(), is(equalTo(maxAttemptCounter)));
		assertTrue(result.isDone() && result.get().isSuccess());

	} finally {
		ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, executor);
	}
}
 
Example 4
Source Project: flink   Source File: JobStatusPollingUtilsTest.java    License: Apache License 2.0 6 votes vote down vote up
@Test
public void testFailedJobResult() throws ExecutionException, InterruptedException {
	final int maxAttemptCounter = 1;
	final ScheduledExecutorService executor = Executors.newSingleThreadScheduledExecutor();
	try {
		final ScheduledExecutor scheduledExecutor = new ScheduledExecutorServiceAdapter(executor);

		final CallCountingJobStatusSupplier jobStatusSupplier = new CallCountingJobStatusSupplier(maxAttemptCounter);

		final CompletableFuture<JobResult> result = JobStatusPollingUtils.pollJobResultAsync(
				jobStatusSupplier,
				() -> CompletableFuture.completedFuture(createFailedJobResult(new JobID(0, 0))),
				scheduledExecutor,
				10
		);

		result.join();

		assertThat(jobStatusSupplier.getAttemptCounter(), is(equalTo(maxAttemptCounter)));
		assertTrue(result.isDone() && result.get().getSerializedThrowable().isPresent());

	} finally {
		ExecutorUtils.gracefulShutdown(5, TimeUnit.SECONDS, executor);
	}
}
 
Example 5
private void waitForTaskManagers(int numberOfTaskManagers, DispatcherGateway dispatcherGateway, FiniteDuration timeLeft) throws ExecutionException, InterruptedException {
	FutureUtils.retrySuccessfulWithDelay(
		() -> dispatcherGateway.requestClusterOverview(Time.milliseconds(timeLeft.toMillis())),
		Time.milliseconds(50L),
		org.apache.flink.api.common.time.Deadline.fromNow(Duration.ofMillis(timeLeft.toMillis())),
		clusterOverview -> clusterOverview.getNumTaskManagersConnected() >= numberOfTaskManagers,
		new ScheduledExecutorServiceAdapter(Executors.newSingleThreadScheduledExecutor()))
		.get();
}
 
Example 6
Source Project: Flink-CEPplus   Source File: StackTraceSampleServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
	final ScheduledExecutor scheduledExecutor = new ScheduledExecutorServiceAdapter(scheduledExecutorService);

	stackTraceSampleService = new StackTraceSampleService(scheduledExecutor);
}
 
Example 7
Source Project: Flink-CEPplus   Source File: RestClusterClient.java    License: Apache License 2.0 5 votes vote down vote up
private <C> CompletableFuture<C> retry(
		CheckedSupplier<CompletableFuture<C>> operation,
		Predicate<Throwable> retryPredicate) {
	return FutureUtils.retryWithDelay(
		CheckedSupplier.unchecked(operation),
		restClusterClientConfiguration.getRetryMaxAttempts(),
		Time.milliseconds(restClusterClientConfiguration.getRetryDelay()),
		retryPredicate,
		new ScheduledExecutorServiceAdapter(retryExecutorService));
}
 
Example 8
Source Project: Flink-CEPplus   Source File: MetricsAvailabilityITCase.java    License: Apache License 2.0 5 votes vote down vote up
private static <X> X fetchMetric(final SupplierWithException<CompletableFuture<X>, IOException> clientOperation, final Predicate<X> predicate) throws InterruptedException, ExecutionException, TimeoutException {
	final CompletableFuture<X> responseFuture = FutureUtils.retrySuccessfulWithDelay(() -> {
			try {
				return clientOperation.get();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		},
		Time.seconds(1),
		Deadline.fromNow(Duration.ofSeconds(5)),
		predicate,
		new ScheduledExecutorServiceAdapter(scheduledExecutorService));

	return responseFuture.get(30, TimeUnit.SECONDS);
}
 
Example 9
private void waitForTaskManagers(int numberOfTaskManagers, DispatcherGateway dispatcherGateway, FiniteDuration timeLeft) throws ExecutionException, InterruptedException {
	FutureUtils.retrySuccessfulWithDelay(
		() -> dispatcherGateway.requestClusterOverview(Time.milliseconds(timeLeft.toMillis())),
		Time.milliseconds(50L),
		org.apache.flink.api.common.time.Deadline.fromNow(Duration.ofMillis(timeLeft.toMillis())),
		clusterOverview -> clusterOverview.getNumTaskManagersConnected() >= numberOfTaskManagers,
		new ScheduledExecutorServiceAdapter(Executors.newSingleThreadScheduledExecutor()))
		.get();
}
 
Example 10
Source Project: flink   Source File: StackTraceSampleServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
	scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
	final ScheduledExecutor scheduledExecutor = new ScheduledExecutorServiceAdapter(scheduledExecutorService);

	stackTraceSampleService = new StackTraceSampleService(scheduledExecutor);
}
 
Example 11
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 12
Source Project: flink   Source File: RestClusterClient.java    License: Apache License 2.0 5 votes vote down vote up
private <C> CompletableFuture<C> retry(
		CheckedSupplier<CompletableFuture<C>> operation,
		Predicate<Throwable> retryPredicate) {
	return FutureUtils.retryWithDelay(
		CheckedSupplier.unchecked(operation),
		restClusterClientConfiguration.getRetryMaxAttempts(),
		Time.milliseconds(restClusterClientConfiguration.getRetryDelay()),
		retryPredicate,
		new ScheduledExecutorServiceAdapter(retryExecutorService));
}
 
Example 13
Source Project: flink   Source File: MetricsAvailabilityITCase.java    License: Apache License 2.0 5 votes vote down vote up
private static <X> X fetchMetric(final SupplierWithException<CompletableFuture<X>, IOException> clientOperation, final Predicate<X> predicate) throws InterruptedException, ExecutionException, TimeoutException {
	final CompletableFuture<X> responseFuture = FutureUtils.retrySuccessfulWithDelay(() -> {
			try {
				return clientOperation.get();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		},
		Time.seconds(1),
		Deadline.fromNow(Duration.ofSeconds(5)),
		predicate,
		new ScheduledExecutorServiceAdapter(scheduledExecutorService));

	return responseFuture.get(30, TimeUnit.SECONDS);
}
 
Example 14
private void waitForTaskManagers(int numberOfTaskManagers, DispatcherGateway dispatcherGateway, Duration timeLeft) throws ExecutionException, InterruptedException {
	FutureUtils.retrySuccessfulWithDelay(
		() -> dispatcherGateway.requestClusterOverview(Time.milliseconds(timeLeft.toMillis())),
		Time.milliseconds(50L),
		org.apache.flink.api.common.time.Deadline.fromNow(Duration.ofMillis(timeLeft.toMillis())),
		clusterOverview -> clusterOverview.getNumTaskManagersConnected() >= numberOfTaskManagers,
		new ScheduledExecutorServiceAdapter(Executors.newSingleThreadScheduledExecutor()))
		.get();
}
 
Example 15
Source Project: flink   Source File: CheckpointCoordinatorTriggeringTest.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * This test only fails eventually.
 */
@Test
public void discardingTriggeringCheckpointWillExecuteNextCheckpointRequest() throws Exception {
	final ExecutionVertex executionVertex = mockExecutionVertex(new ExecutionAttemptID());

	final ScheduledExecutorService scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
	final CheckpointCoordinator checkpointCoordinator = new CheckpointCoordinatorTestingUtils.CheckpointCoordinatorBuilder()
		.setTasks(new ExecutionVertex[]{executionVertex})
		.setTimer(new ScheduledExecutorServiceAdapter(scheduledExecutorService))
		.setCheckpointCoordinatorConfiguration(CheckpointCoordinatorConfiguration.builder()
			.build())
		.build();

	final CompletableFuture<String> masterHookCheckpointFuture = new CompletableFuture<>();
	final OneShotLatch triggerCheckpointLatch = new OneShotLatch();
	checkpointCoordinator.addMasterHook(new TestingMasterHook(masterHookCheckpointFuture, triggerCheckpointLatch));

	try {
		checkpointCoordinator.triggerCheckpoint(false);
		final CompletableFuture<CompletedCheckpoint> secondCheckpoint = checkpointCoordinator.triggerCheckpoint(false);

		triggerCheckpointLatch.await();
		masterHookCheckpointFuture.complete("Completed");

		// discard triggering checkpoint
		checkpointCoordinator.abortPendingCheckpoints(new CheckpointException(CheckpointFailureReason.CHECKPOINT_DECLINED));

		try {
			// verify that the second checkpoint request will be executed and eventually times out
			secondCheckpoint.get();
			fail("Expected the second checkpoint to fail.");
		} catch (ExecutionException ee) {
			assertThat(ExceptionUtils.stripExecutionException(ee), instanceOf(CheckpointException.class));
		}
	} finally {
		checkpointCoordinator.shutdown(JobStatus.FINISHED);
		ExecutorUtils.gracefulShutdown(10L, TimeUnit.SECONDS, scheduledExecutorService);
	}
}
 
Example 16
Source Project: flink   Source File: BackPressureSampleServiceTest.java    License: Apache License 2.0 5 votes vote down vote up
@BeforeClass
public static void setUp() throws Exception {
	scheduledExecutorService = Executors.newSingleThreadScheduledExecutor();
	final ScheduledExecutor scheduledExecutor = new ScheduledExecutorServiceAdapter(scheduledExecutorService);

	backPressureSampleService = new BackPressureSampleService(10, Time.milliseconds(10), scheduledExecutor);
}
 
Example 17
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 18
Source Project: flink   Source File: RestClusterClient.java    License: Apache License 2.0 5 votes vote down vote up
private <C> CompletableFuture<C> retry(
		CheckedSupplier<CompletableFuture<C>> operation,
		Predicate<Throwable> retryPredicate) {
	return FutureUtils.retryWithDelay(
		CheckedSupplier.unchecked(operation),
		restClusterClientConfiguration.getRetryMaxAttempts(),
		Time.milliseconds(restClusterClientConfiguration.getRetryDelay()),
		retryPredicate,
		new ScheduledExecutorServiceAdapter(retryExecutorService));
}
 
Example 19
Source Project: flink   Source File: MetricsAvailabilityITCase.java    License: Apache License 2.0 5 votes vote down vote up
private static <X> X fetchMetric(final SupplierWithException<CompletableFuture<X>, IOException> clientOperation, final Predicate<X> predicate) throws InterruptedException, ExecutionException, TimeoutException {
	final CompletableFuture<X> responseFuture = FutureUtils.retrySuccessfulWithDelay(() -> {
			try {
				return clientOperation.get();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		},
		Time.seconds(1),
		Deadline.fromNow(Duration.ofSeconds(5)),
		predicate,
		new ScheduledExecutorServiceAdapter(scheduledExecutorService));

	return responseFuture.get(30, TimeUnit.SECONDS);
}
 
Example 20
Source Project: Flink-CEPplus   Source File: HeartbeatManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Tests that the heartbeat target {@link ResourceID} is properly passed to the {@link HeartbeatListener} by the
 * {@link HeartbeatManagerSenderImpl}.
 */
@Test
public void testHeartbeatManagerSenderTargetPayload() throws Exception {
	final long heartbeatTimeout = 100L;
	final long heartbeatPeriod = 2000L;

	final ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);

	final ResourceID someTargetId = ResourceID.generate();
	final ResourceID specialTargetId = ResourceID.generate();

	final OneShotLatch someTargetReceivedLatch = new OneShotLatch();
	final OneShotLatch specialTargetReceivedLatch = new OneShotLatch();

	final TargetDependentHeartbeatReceiver someHeartbeatTarget = new TargetDependentHeartbeatReceiver(someTargetReceivedLatch);
	final TargetDependentHeartbeatReceiver specialHeartbeatTarget = new TargetDependentHeartbeatReceiver(specialTargetReceivedLatch);

	final int defaultResponse = 0;
	final int specialResponse = 1;

	HeartbeatManager<?, Integer> heartbeatManager = new HeartbeatManagerSenderImpl<>(
		heartbeatPeriod,
		heartbeatTimeout,
		ResourceID.generate(),
		new TargetDependentHeartbeatSender(specialTargetId, specialResponse, defaultResponse),
		new ScheduledExecutorServiceAdapter(scheduledThreadPoolExecutor),
		LOG);

	try {
		heartbeatManager.monitorTarget(someTargetId, someHeartbeatTarget);
		heartbeatManager.monitorTarget(specialTargetId, specialHeartbeatTarget);

		someTargetReceivedLatch.await(5, TimeUnit.SECONDS);
		specialTargetReceivedLatch.await(5, TimeUnit.SECONDS);

		assertEquals(defaultResponse, someHeartbeatTarget.getLastRequestedHeartbeatPayload());
		assertEquals(specialResponse, specialHeartbeatTarget.getLastRequestedHeartbeatPayload());
	} finally {
		heartbeatManager.stop();
		scheduledThreadPoolExecutor.shutdown();
	}
}
 
Example 21
Source Project: flink   Source File: HeartbeatManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Tests that the heartbeat target {@link ResourceID} is properly passed to the {@link HeartbeatListener} by the
 * {@link HeartbeatManagerSenderImpl}.
 */
@Test
public void testHeartbeatManagerSenderTargetPayload() throws Exception {
	final long heartbeatTimeout = 100L;
	final long heartbeatPeriod = 2000L;

	final ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);

	final ResourceID someTargetId = ResourceID.generate();
	final ResourceID specialTargetId = ResourceID.generate();

	final OneShotLatch someTargetReceivedLatch = new OneShotLatch();
	final OneShotLatch specialTargetReceivedLatch = new OneShotLatch();

	final TargetDependentHeartbeatReceiver someHeartbeatTarget = new TargetDependentHeartbeatReceiver(someTargetReceivedLatch);
	final TargetDependentHeartbeatReceiver specialHeartbeatTarget = new TargetDependentHeartbeatReceiver(specialTargetReceivedLatch);

	final int defaultResponse = 0;
	final int specialResponse = 1;

	HeartbeatManager<?, Integer> heartbeatManager = new HeartbeatManagerSenderImpl<>(
		heartbeatPeriod,
		heartbeatTimeout,
		ResourceID.generate(),
		new TargetDependentHeartbeatSender(specialTargetId, specialResponse, defaultResponse),
		new ScheduledExecutorServiceAdapter(scheduledThreadPoolExecutor),
		LOG);

	try {
		heartbeatManager.monitorTarget(someTargetId, someHeartbeatTarget);
		heartbeatManager.monitorTarget(specialTargetId, specialHeartbeatTarget);

		someTargetReceivedLatch.await(5, TimeUnit.SECONDS);
		specialTargetReceivedLatch.await(5, TimeUnit.SECONDS);

		assertEquals(defaultResponse, someHeartbeatTarget.getLastRequestedHeartbeatPayload());
		assertEquals(specialResponse, specialHeartbeatTarget.getLastRequestedHeartbeatPayload());
	} finally {
		heartbeatManager.stop();
		scheduledThreadPoolExecutor.shutdown();
	}
}
 
Example 22
Source Project: flink   Source File: DefaultSchedulerFactory.java    License: Apache License 2.0 4 votes vote down vote up
@Override
public SchedulerNG createInstance(
		final Logger log,
		final JobGraph jobGraph,
		final BackPressureStatsTracker backPressureStatsTracker,
		final Executor ioExecutor,
		final Configuration jobMasterConfiguration,
		final SlotProvider slotProvider,
		final ScheduledExecutorService futureExecutor,
		final ClassLoader userCodeLoader,
		final CheckpointRecoveryFactory checkpointRecoveryFactory,
		final Time rpcTimeout,
		final BlobWriter blobWriter,
		final JobManagerJobMetricGroup jobManagerJobMetricGroup,
		final Time slotRequestTimeout,
		final ShuffleMaster<?> shuffleMaster,
		final JobMasterPartitionTracker partitionTracker) throws Exception {

	final SchedulingStrategyFactory schedulingStrategyFactory = createSchedulingStrategyFactory(jobGraph.getScheduleMode());
	final RestartBackoffTimeStrategy restartBackoffTimeStrategy = RestartBackoffTimeStrategyFactoryLoader
		.createRestartBackoffTimeStrategyFactory(
			jobGraph
				.getSerializedExecutionConfig()
				.deserializeValue(userCodeLoader)
				.getRestartStrategy(),
			jobMasterConfiguration,
			jobGraph.isCheckpointingEnabled())
		.create();
	log.info("Using restart back off time strategy {} for {} ({}).", restartBackoffTimeStrategy, jobGraph.getName(), jobGraph.getJobID());

	final ExecutionSlotAllocatorFactory slotAllocatorFactory =
		createExecutionSlotAllocatorFactory(
			jobGraph.getScheduleMode(),
			slotProvider,
			slotRequestTimeout,
			schedulingStrategyFactory);

	return new DefaultScheduler(
		log,
		jobGraph,
		backPressureStatsTracker,
		ioExecutor,
		jobMasterConfiguration,
		futureExecutor,
		new ScheduledExecutorServiceAdapter(futureExecutor),
		userCodeLoader,
		checkpointRecoveryFactory,
		rpcTimeout,
		blobWriter,
		jobManagerJobMetricGroup,
		shuffleMaster,
		partitionTracker,
		schedulingStrategyFactory,
		FailoverStrategyFactoryLoader.loadFailoverStrategyFactory(jobMasterConfiguration),
		restartBackoffTimeStrategy,
		new DefaultExecutionVertexOperations(),
		new ExecutionVertexVersioner(),
		slotAllocatorFactory);
}
 
Example 23
Source Project: flink   Source File: HeartbeatManagerTest.java    License: Apache License 2.0 4 votes vote down vote up
/**
 * Tests that the heartbeat target {@link ResourceID} is properly passed to the {@link HeartbeatListener} by the
 * {@link HeartbeatManagerSenderImpl}.
 */
@Test
public void testHeartbeatManagerSenderTargetPayload() throws Exception {
	final long heartbeatTimeout = 100L;
	final long heartbeatPeriod = 2000L;

	final ScheduledThreadPoolExecutor scheduledThreadPoolExecutor = new ScheduledThreadPoolExecutor(1);

	final ResourceID someTargetId = ResourceID.generate();
	final ResourceID specialTargetId = ResourceID.generate();

	final OneShotLatch someTargetReceivedLatch = new OneShotLatch();
	final OneShotLatch specialTargetReceivedLatch = new OneShotLatch();

	final TargetDependentHeartbeatReceiver someHeartbeatTarget = new TargetDependentHeartbeatReceiver(someTargetReceivedLatch);
	final TargetDependentHeartbeatReceiver specialHeartbeatTarget = new TargetDependentHeartbeatReceiver(specialTargetReceivedLatch);

	final int defaultResponse = 0;
	final int specialResponse = 1;

	HeartbeatManager<?, Integer> heartbeatManager = new HeartbeatManagerSenderImpl<>(
		heartbeatPeriod,
		heartbeatTimeout,
		ResourceID.generate(),
		new TargetDependentHeartbeatSender(specialTargetId, specialResponse, defaultResponse),
		new ScheduledExecutorServiceAdapter(scheduledThreadPoolExecutor),
		LOG);

	try {
		heartbeatManager.monitorTarget(someTargetId, someHeartbeatTarget);
		heartbeatManager.monitorTarget(specialTargetId, specialHeartbeatTarget);

		someTargetReceivedLatch.await(5, TimeUnit.SECONDS);
		specialTargetReceivedLatch.await(5, TimeUnit.SECONDS);

		assertEquals(defaultResponse, someHeartbeatTarget.getLastRequestedHeartbeatPayload());
		assertEquals(specialResponse, specialHeartbeatTarget.getLastRequestedHeartbeatPayload());
	} finally {
		heartbeatManager.stop();
		scheduledThreadPoolExecutor.shutdown();
	}
}