Search in sources :

Example 1 with SchedulerRunner

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();
}
Also used : SchedulerRunner(com.mesosphere.sdk.scheduler.SchedulerRunner) RawServiceSpec(com.mesosphere.sdk.specification.yaml.RawServiceSpec) SchedulerBuilder(com.mesosphere.sdk.scheduler.SchedulerBuilder) SchedulerConfig(com.mesosphere.sdk.scheduler.SchedulerConfig) File(java.io.File)

Aggregations

SchedulerBuilder (com.mesosphere.sdk.scheduler.SchedulerBuilder)1 SchedulerConfig (com.mesosphere.sdk.scheduler.SchedulerConfig)1 SchedulerRunner (com.mesosphere.sdk.scheduler.SchedulerRunner)1 RawServiceSpec (com.mesosphere.sdk.specification.yaml.RawServiceSpec)1 File (java.io.File)1