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();
}
Aggregations