use of org.apache.flink.util.concurrent.ScheduledExecutor in project flink by apache.
the class CheckpointCoordinatorMasterHooksTest method instantiateCheckpointCoordinator.
private CheckpointCoordinator instantiateCheckpointCoordinator(ExecutionGraph graph, ScheduledExecutor testingScheduledExecutor) {
CheckpointCoordinatorConfiguration chkConfig = new CheckpointCoordinatorConfiguration(10000000L, 600000L, 0L, 1, CheckpointRetentionPolicy.NEVER_RETAIN_AFTER_TERMINATION, true, false, 0, 0);
Executor executor = Executors.directExecutor();
return new CheckpointCoordinator(graph.getJobID(), chkConfig, Collections.emptyList(), new StandaloneCheckpointIDCounter(), new StandaloneCompletedCheckpointStore(10), new MemoryStateBackend(), executor, new CheckpointsCleaner(), testingScheduledExecutor, new CheckpointFailureManager(0, NoOpFailJobCall.INSTANCE), new DefaultCheckpointPlanCalculator(graph.getJobID(), new ExecutionGraphCheckpointPlanCalculatorContext(graph), graph.getVerticesTopologically(), false), new ExecutionAttemptMappingProvider(graph.getAllExecutionVertices()), new CheckpointStatsTracker(1, new DummyMetricGroup()));
}
use of org.apache.flink.util.concurrent.ScheduledExecutor in project flink by apache.
the class AkkaRpcServiceTest method testScheduledExecutorServiceSimpleSchedule.
/**
* Tests a simple scheduled runnable being executed by the RPC services scheduled executor
* service.
*/
@Test(timeout = 60000)
public void testScheduledExecutorServiceSimpleSchedule() throws Exception {
ScheduledExecutor scheduledExecutor = akkaRpcService.getScheduledExecutor();
final OneShotLatch latch = new OneShotLatch();
ScheduledFuture<?> future = scheduledExecutor.schedule(latch::trigger, 10L, TimeUnit.MILLISECONDS);
future.get();
// once the future is completed, then the latch should have been triggered
assertTrue(latch.isTriggered());
}
use of org.apache.flink.util.concurrent.ScheduledExecutor in project flink by apache.
the class AkkaRpcServiceTest method testScheduledExecutorServicePeriodicSchedule.
/**
* Tests that the RPC service's scheduled executor service can execute runnables at a fixed
* rate.
*/
@Test(timeout = 60000)
public void testScheduledExecutorServicePeriodicSchedule() throws Exception {
ScheduledExecutor scheduledExecutor = akkaRpcService.getScheduledExecutor();
final int tries = 4;
final long delay = 10L;
final CountDownLatch countDownLatch = new CountDownLatch(tries);
long currentTime = System.nanoTime();
ScheduledFuture<?> future = scheduledExecutor.scheduleAtFixedRate(countDownLatch::countDown, delay, delay, TimeUnit.MILLISECONDS);
assertTrue(!future.isDone());
countDownLatch.await();
// the future should not complete since we have a periodic task
assertTrue(!future.isDone());
long finalTime = System.nanoTime() - currentTime;
// the processing should have taken at least delay times the number of count downs.
assertTrue(finalTime >= tries * delay);
future.cancel(true);
}
use of org.apache.flink.util.concurrent.ScheduledExecutor in project flink by apache.
the class ApplicationDispatcherBootstrapTest method testClusterIsShutdownInAttachedModeWhenJobCancelled.
@Test
public void testClusterIsShutdownInAttachedModeWhenJobCancelled() throws Exception {
final CompletableFuture<ApplicationStatus> clusterShutdown = new CompletableFuture<>();
final TestingDispatcherGateway dispatcherGateway = canceledJobGatewayBuilder().setClusterShutdownFunction(status -> {
clusterShutdown.complete(status);
return CompletableFuture.completedFuture(Acknowledge.get());
}).build();
final PackagedProgram program = getProgram(2);
final Configuration configuration = getConfiguration();
configuration.set(DeploymentOptions.ATTACHED, true);
final ApplicationDispatcherBootstrap bootstrap = new ApplicationDispatcherBootstrap(program, Collections.emptyList(), configuration, dispatcherGateway, scheduledExecutor, e -> {
});
final CompletableFuture<Void> applicationFuture = bootstrap.getApplicationCompletionFuture();
assertException(applicationFuture, UnsuccessfulExecutionException.class);
assertEquals(clusterShutdown.get(), ApplicationStatus.CANCELED);
}
use of org.apache.flink.util.concurrent.ScheduledExecutor in project flink by apache.
the class ApplicationDispatcherBootstrapTest method testSubmitFailedJobOnApplicationError.
private void testSubmitFailedJobOnApplicationError(Configuration configuration, BiConsumer<JobID, Throwable> failedJobAssertion) throws Exception {
final CompletableFuture<Void> submitted = new CompletableFuture<>();
final TestingDispatcherGateway dispatcherGateway = TestingDispatcherGateway.newBuilder().setSubmitFailedFunction((jobId, jobName, t) -> {
try {
failedJobAssertion.accept(jobId, t);
submitted.complete(null);
return CompletableFuture.completedFuture(Acknowledge.get());
} catch (Throwable assertion) {
submitted.completeExceptionally(assertion);
return FutureUtils.completedExceptionally(assertion);
}
}).setRequestJobStatusFunction(jobId -> submitted.thenApply(ignored -> JobStatus.FAILED)).setRequestJobResultFunction(jobId -> submitted.thenApply(ignored -> createJobResult(jobId, ApplicationStatus.FAILED))).build();
final ApplicationDispatcherBootstrap bootstrap = new ApplicationDispatcherBootstrap(FailingJob.getProgram(), Collections.emptyList(), configuration, dispatcherGateway, scheduledExecutor, exception -> {
});
bootstrap.getBootstrapCompletionFuture().get();
}
Aggregations