use of com.mesosphere.sdk.scheduler.SchedulerRunner in project dcos-commons by mesosphere.
the class Main method main.
public static void main(String[] args) throws Exception {
final SchedulerConfig schedulerConfig = SchedulerConfig.fromEnv();
final SchedulerRunner runner;
File yamlSpecFile;
ServiceSpec serviceSpec;
SchedulerBuilder builder;
Scenario scenario = getScenario();
LOGGER.info("Scheduler operating under scenario: {}", scenario.name());
switch(scenario) {
case Java:
// Create a sample config in Java
runner = SchedulerRunner.fromServiceSpec(createSampleServiceSpec(schedulerConfig), schedulerConfig);
break;
case YAML:
// Read config from provided file, and assume any config templates
// are in the same directory as the file:
yamlSpecFile = new File(args[0]);
runner = SchedulerRunner.fromRawServiceSpec(RawServiceSpec.newBuilder(yamlSpecFile).build(), schedulerConfig, yamlSpecFile.getParentFile());
break;
case MULTI_REGION:
yamlSpecFile = new File(args[0]);
serviceSpec = DefaultServiceSpec.newGenerator(yamlSpecFile, SchedulerConfig.fromEnv()).build();
builder = DefaultScheduler.newBuilder(serviceSpec, SchedulerConfig.fromEnv()).withSingleRegionConstraint();
runner = SchedulerRunner.fromSchedulerBuilder(builder);
break;
case CUSTOM_PLAN:
yamlSpecFile = new File(args[0]);
serviceSpec = DefaultServiceSpec.newGenerator(yamlSpecFile, SchedulerConfig.fromEnv()).build();
builder = DefaultScheduler.newBuilder(serviceSpec, SchedulerConfig.fromEnv()).setPlanCustomizer(new ReversePhasesCustomizer());
runner = SchedulerRunner.fromSchedulerBuilder(builder);
break;
case CUSTOM_DECOMMISSION:
yamlSpecFile = new File(args[0]);
serviceSpec = DefaultServiceSpec.newGenerator(yamlSpecFile, SchedulerConfig.fromEnv()).build();
builder = DefaultScheduler.newBuilder(serviceSpec, SchedulerConfig.fromEnv()).setPlanCustomizer(new DecomissionCustomizer());
runner = SchedulerRunner.fromSchedulerBuilder(builder);
break;
default:
throw new IllegalStateException(String.format("Unexpected scnenario '%s'", scenario.name()));
}
runner.run();
}
Aggregations