Search in sources :

Example 1 with SchedulerNGFactory

use of org.apache.flink.runtime.scheduler.SchedulerNGFactory in project flink by apache.

the class DefaultSlotPoolServiceSchedulerFactory method fromConfiguration.

public static DefaultSlotPoolServiceSchedulerFactory fromConfiguration(Configuration configuration, JobType jobType) {
    final Time rpcTimeout = Time.fromDuration(configuration.get(AkkaOptions.ASK_TIMEOUT_DURATION));
    final Time slotIdleTimeout = Time.milliseconds(configuration.getLong(JobManagerOptions.SLOT_IDLE_TIMEOUT));
    final Time batchSlotTimeout = Time.milliseconds(configuration.getLong(JobManagerOptions.SLOT_REQUEST_TIMEOUT));
    final SlotPoolServiceFactory slotPoolServiceFactory;
    final SchedulerNGFactory schedulerNGFactory;
    JobManagerOptions.SchedulerType schedulerType = ClusterOptions.getSchedulerType(configuration);
    if (schedulerType == JobManagerOptions.SchedulerType.Adaptive && jobType == JobType.BATCH) {
        LOG.info("Adaptive Scheduler configured, but Batch job detected. Changing scheduler type to NG / DefaultScheduler.");
        // overwrite
        schedulerType = JobManagerOptions.SchedulerType.Ng;
    }
    switch(schedulerType) {
        case Ng:
            schedulerNGFactory = new DefaultSchedulerFactory();
            slotPoolServiceFactory = new DeclarativeSlotPoolBridgeServiceFactory(SystemClock.getInstance(), rpcTimeout, slotIdleTimeout, batchSlotTimeout, getRequestSlotMatchingStrategy(configuration, jobType));
            break;
        case Adaptive:
            schedulerNGFactory = getAdaptiveSchedulerFactoryFromConfiguration(configuration);
            slotPoolServiceFactory = new DeclarativeSlotPoolServiceFactory(SystemClock.getInstance(), slotIdleTimeout, rpcTimeout);
            break;
        case AdaptiveBatch:
            schedulerNGFactory = new AdaptiveBatchSchedulerFactory();
            slotPoolServiceFactory = new DeclarativeSlotPoolBridgeServiceFactory(SystemClock.getInstance(), rpcTimeout, slotIdleTimeout, batchSlotTimeout, getRequestSlotMatchingStrategy(configuration, jobType));
            break;
        default:
            throw new IllegalArgumentException(String.format("Illegal value [%s] for config option [%s]", schedulerType, JobManagerOptions.SCHEDULER.key()));
    }
    return new DefaultSlotPoolServiceSchedulerFactory(slotPoolServiceFactory, schedulerNGFactory);
}
Also used : SchedulerNGFactory(org.apache.flink.runtime.scheduler.SchedulerNGFactory) AdaptiveBatchSchedulerFactory(org.apache.flink.runtime.scheduler.adaptivebatch.AdaptiveBatchSchedulerFactory) DeclarativeSlotPoolServiceFactory(org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolServiceFactory) DeclarativeSlotPoolBridgeServiceFactory(org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolBridgeServiceFactory) DefaultSchedulerFactory(org.apache.flink.runtime.scheduler.DefaultSchedulerFactory) Time(org.apache.flink.api.common.time.Time) DeclarativeSlotPoolServiceFactory(org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolServiceFactory) SlotPoolServiceFactory(org.apache.flink.runtime.jobmaster.slotpool.SlotPoolServiceFactory) JobManagerOptions(org.apache.flink.configuration.JobManagerOptions)

Example 2 with SchedulerNGFactory

use of org.apache.flink.runtime.scheduler.SchedulerNGFactory in project flink by apache.

the class JobMasterSchedulerTest method testIfStartSchedulingFailsJobMasterFails.

/**
 * Tests that the JobMaster fails if we cannot start the scheduling. See FLINK-20382.
 */
@Test
public void testIfStartSchedulingFailsJobMasterFails() throws Exception {
    final SchedulerNGFactory schedulerFactory = new FailingSchedulerFactory();
    final JobMasterBuilder.TestingOnCompletionActions onCompletionActions = new JobMasterBuilder.TestingOnCompletionActions();
    final JobMaster jobMaster = new JobMasterBuilder(JobGraphTestUtils.emptyJobGraph(), TESTING_RPC_SERVICE_RESOURCE.getTestingRpcService()).withSlotPoolServiceSchedulerFactory(DefaultSlotPoolServiceSchedulerFactory.create(TestingSlotPoolServiceBuilder.newBuilder(), schedulerFactory)).withOnCompletionActions(onCompletionActions).createJobMaster();
    jobMaster.start();
    assertThat(onCompletionActions.getJobMasterFailedFuture().join(), is(instanceOf(JobMasterException.class)));
    // cleanly
    try {
        jobMaster.close();
    } catch (Exception expected) {
    // expected
    }
}
Also used : SchedulerNGFactory(org.apache.flink.runtime.scheduler.SchedulerNGFactory) JobMasterBuilder(org.apache.flink.runtime.jobmaster.utils.JobMasterBuilder) FlinkRuntimeException(org.apache.flink.util.FlinkRuntimeException) Test(org.junit.Test)

Aggregations

SchedulerNGFactory (org.apache.flink.runtime.scheduler.SchedulerNGFactory)2 Time (org.apache.flink.api.common.time.Time)1 JobManagerOptions (org.apache.flink.configuration.JobManagerOptions)1 DeclarativeSlotPoolBridgeServiceFactory (org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolBridgeServiceFactory)1 DeclarativeSlotPoolServiceFactory (org.apache.flink.runtime.jobmaster.slotpool.DeclarativeSlotPoolServiceFactory)1 SlotPoolServiceFactory (org.apache.flink.runtime.jobmaster.slotpool.SlotPoolServiceFactory)1 JobMasterBuilder (org.apache.flink.runtime.jobmaster.utils.JobMasterBuilder)1 DefaultSchedulerFactory (org.apache.flink.runtime.scheduler.DefaultSchedulerFactory)1 AdaptiveBatchSchedulerFactory (org.apache.flink.runtime.scheduler.adaptivebatch.AdaptiveBatchSchedulerFactory)1 FlinkRuntimeException (org.apache.flink.util.FlinkRuntimeException)1 Test (org.junit.Test)1