com.netflix.fenzo.TaskScheduler Java Examples

The following examples show how to use com.netflix.fenzo.TaskScheduler. 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 File: MesosResourceManager.java    From Flink-CEPplus with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the Fenzo optimizer (builder).
 * The builder is an indirection to facilitate unit testing of the Launch Coordinator.
 */
private static TaskSchedulerBuilder createOptimizer() {
	return new TaskSchedulerBuilder() {
		TaskScheduler.Builder builder = new TaskScheduler.Builder();

		@Override
		public TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action) {
			builder.withLeaseRejectAction(action);
			return this;
		}

		@Override
		public TaskScheduler build() {
			return builder.build();
		}
	};
}
 
Example #2
Source File: MesosResourceManager.java    From flink with Apache License 2.0 6 votes vote down vote up
/**
 * Creates the Fenzo optimizer (builder).
 * The builder is an indirection to facilitate unit testing of the Launch Coordinator.
 */
private static TaskSchedulerBuilder createOptimizer() {
	return new TaskSchedulerBuilder() {
		TaskScheduler.Builder builder = new TaskScheduler.Builder();

		@Override
		public TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action) {
			builder.withLeaseRejectAction(action);
			return this;
		}

		@Override
		public TaskScheduler build() {
			return builder.build();
		}
	};
}
 
Example #3
Source File: SchedulerService.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 6 votes vote down vote up
private SchedulerDriver getSchedulerDriver(final TaskScheduler taskScheduler, final JobEventBus jobEventBus, final FrameworkIDService frameworkIDService) {
    Optional<String> frameworkIDOptional = frameworkIDService.fetch();
    Protos.FrameworkInfo.Builder builder = Protos.FrameworkInfo.newBuilder();
    if (frameworkIDOptional.isPresent()) {
        builder.setId(Protos.FrameworkID.newBuilder().setValue(frameworkIDOptional.get()).build());
    }
    Optional<String> role = env.getMesosRole();
    String frameworkName = MesosConfiguration.FRAMEWORK_NAME;
    if (role.isPresent()) {
        builder.setRole(role.get());
        frameworkName += "-" + role.get();
    }
    builder.addCapabilitiesBuilder().setType(Protos.FrameworkInfo.Capability.Type.PARTITION_AWARE);
    MesosConfiguration mesosConfig = env.getMesosConfiguration();
    Protos.FrameworkInfo frameworkInfo = builder.setUser(mesosConfig.getUser()).setName(frameworkName)
            .setHostname(mesosConfig.getHostname()).setFailoverTimeout(MesosConfiguration.FRAMEWORK_FAILOVER_TIMEOUT_SECONDS)
            .setWebuiUrl(WEB_UI_PROTOCOL + env.getFrameworkHostPort()).setCheckpoint(true).build();
    return new MesosSchedulerDriver(new SchedulerEngine(taskScheduler, facadeService, jobEventBus, frameworkIDService, statisticManager), frameworkInfo, mesosConfig.getUrl());
}
 
Example #4
Source File: DefaultSchedulingService.java    From titus-control-plane with Apache License 2.0 6 votes vote down vote up
private TaskScheduler setupTaskScheduler(Observable<LeaseRescindedEvent> vmLeaseRescindedObservable,
                                         TaskScheduler.Builder schedulerBuilder) {
    int minMinIdle = 4;
    final TaskScheduler scheduler = schedulerBuilder.withMaxOffersToReject(Math.max(1, minMinIdle))
            .withSingleOfferPerVM(kubeIntegrationEnabled)
            .build();
    vmLeaseRescindedObservable
            .doOnNext(event -> {
                switch (event.getType()) {
                    case All:
                        scheduler.expireAllLeases();
                        break;
                    case LeaseId:
                        scheduler.expireLease(event.getValue());
                        break;
                }
            })
            .subscribe();
    return scheduler;
}
 
Example #5
Source File: SchedulerService.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 5 votes vote down vote up
public SchedulerService(final CoordinatorRegistryCenter regCenter) {
    env = BootstrapEnvironment.getInstance();
    facadeService = new FacadeService(regCenter);
    statisticManager = StatisticManager.getInstance(regCenter, env.getJobEventRdbConfiguration());
    TaskScheduler taskScheduler = getTaskScheduler();
    JobEventBus jobEventBus = getJobEventBus();
    schedulerDriver = getSchedulerDriver(taskScheduler, jobEventBus, new FrameworkIDService(regCenter));
    producerManager = new ProducerManager(schedulerDriver, regCenter);
    cloudJobConfigurationListener = new CloudJobConfigurationListener(regCenter, producerManager);
    taskLaunchScheduledService = new TaskLaunchScheduledService(schedulerDriver, taskScheduler, facadeService, jobEventBus);
    reconcileService = new ReconcileService(schedulerDriver, facadeService);
    restfulService = new RestfulService(regCenter, env.getRestfulServerConfiguration(), producerManager, reconcileService);
}
 
Example #6
Source File: SchedulerService.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 5 votes vote down vote up
private TaskScheduler getTaskScheduler() {
    return new TaskScheduler.Builder()
            .withLeaseOfferExpirySecs(1000000000L)
            .withLeaseRejectAction(new Action1<VirtualMachineLease>() {
                
                @Override
                public void call(final VirtualMachineLease lease) {
                    log.warn("Declining offer on '{}'", lease.hostname());
                    schedulerDriver.declineOffer(lease.getOffer().getId());
                }
            }).build();
}
 
Example #7
Source File: AppConstraintEvaluatorTest.java    From shardingsphere-elasticjob-cloud with Apache License 2.0 5 votes vote down vote up
@Before
public void setUp() throws Exception {
    taskScheduler = new TaskScheduler.Builder().withLeaseOfferExpirySecs(1000000000L).withLeaseRejectAction(new Action1<VirtualMachineLease>() {
        
        @Override
        public void call(final VirtualMachineLease virtualMachineLease) {
        }
    }).build();
}
 
Example #8
Source File: DefaultSchedulingService.java    From titus-control-plane with Apache License 2.0 5 votes vote down vote up
private TaskSchedulingService setupTaskSchedulingService(TaskScheduler taskScheduler) {
    TaskSchedulingService.Builder builder = new TaskSchedulingService.Builder()
            .withLoopIntervalMillis(schedulerConfiguration.getSchedulerIterationIntervalMs())
            // sort of rate limiting when no assignments were made and no new offers available
            .withMaxDelayMillis(schedulerConfiguration.getSchedulerMaxIdleIntervalMs())
            .withTaskQueue(taskQueue)
            .withPreSchedulingLoopHook(this::preSchedulingHook)
            .withSchedulingResultCallback(this::schedulingResultsHandler)
            .withTaskScheduler(taskScheduler);
    return builder.build();
}
 
Example #9
Source File: MesosResourceManager.java    From flink with Apache License 2.0 5 votes vote down vote up
/**
 * Creates the Fenzo optimizer (builder).
 * The builder is an indirection to facilitate unit testing of the Launch Coordinator.
 */
private static TaskSchedulerBuilder createOptimizer() {
	return new TaskSchedulerBuilder() {
		TaskScheduler.Builder builder = new TaskScheduler.Builder();

		@Override
		public TaskSchedulerBuilder withLeaseRejectAction(Action1<VirtualMachineLease> action) {
			builder.withLeaseRejectAction(action);
			return this;
		}

		@Override
		public TaskSchedulerBuilder withRejectAllExpiredOffers() {
			builder.withRejectAllExpiredOffers();
			return this;
		}

		@Override
		public TaskSchedulerBuilder withLeaseOfferExpirySecs(long leaseOfferExpirySecs) {
			builder.withLeaseOfferExpirySecs(leaseOfferExpirySecs);
			return this;
		}

		@Override
		public TaskScheduler build() {
			return builder.build();
		}
	};
}
 
Example #10
Source File: TaskSchedulerBuilder.java    From Flink-CEPplus with Apache License 2.0 2 votes vote down vote up
/**
 * Build a Fenzo task scheduler.
 */
TaskScheduler build();
 
Example #11
Source File: TaskSchedulerBuilder.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Build a Fenzo task scheduler.
 */
TaskScheduler build();
 
Example #12
Source File: TaskSchedulerBuilder.java    From flink with Apache License 2.0 2 votes vote down vote up
/**
 * Build a Fenzo task scheduler.
 */
TaskScheduler build();