Search in sources :

Example 1 with ManuallyTriggeredComponentMainThreadExecutor

use of org.apache.flink.runtime.concurrent.ManuallyTriggeredComponentMainThreadExecutor in project flink by apache.

the class AdaptiveSchedulerTest method testResourceTimeout.

@Test
public void testResourceTimeout() throws Exception {
    final ManuallyTriggeredComponentMainThreadExecutor mainThreadExecutor = new ManuallyTriggeredComponentMainThreadExecutor(Thread.currentThread());
    final Duration resourceTimeout = Duration.ofMinutes(1234);
    final Configuration configuration = new Configuration();
    configuration.set(JobManagerOptions.RESOURCE_WAIT_TIMEOUT, resourceTimeout);
    final AdaptiveScheduler scheduler = new AdaptiveSchedulerBuilder(createJobGraph(), mainThreadExecutor).setJobMasterConfiguration(configuration).build();
    scheduler.startScheduling();
    // check whether some task was scheduled with the expected timeout
    // this is technically not really safe, but the chosen timeout value
    // is odd enough that it realistically won't cause issues.
    // With this approach we don't have to make assumption as to how many
    // tasks are being scheduled.
    final boolean b = mainThreadExecutor.getActiveNonPeriodicScheduledTask().stream().anyMatch(scheduledTask -> scheduledTask.getDelay(TimeUnit.MINUTES) == resourceTimeout.toMinutes());
    assertThat(b).isTrue();
}
Also used : ManuallyTriggeredComponentMainThreadExecutor(org.apache.flink.runtime.concurrent.ManuallyTriggeredComponentMainThreadExecutor) CheckpointCoordinatorConfiguration(org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration) Configuration(org.apache.flink.configuration.Configuration) Duration(java.time.Duration) Test(org.junit.Test) ArchivedExecutionGraphTest(org.apache.flink.runtime.executiongraph.ArchivedExecutionGraphTest) DefaultSchedulerTest(org.apache.flink.runtime.scheduler.DefaultSchedulerTest)

Aggregations

Duration (java.time.Duration)1 Configuration (org.apache.flink.configuration.Configuration)1 ManuallyTriggeredComponentMainThreadExecutor (org.apache.flink.runtime.concurrent.ManuallyTriggeredComponentMainThreadExecutor)1 ArchivedExecutionGraphTest (org.apache.flink.runtime.executiongraph.ArchivedExecutionGraphTest)1 CheckpointCoordinatorConfiguration (org.apache.flink.runtime.jobgraph.tasks.CheckpointCoordinatorConfiguration)1 DefaultSchedulerTest (org.apache.flink.runtime.scheduler.DefaultSchedulerTest)1 Test (org.junit.Test)1