Search in sources :

Example 6 with RawServiceSpec

use of com.mesosphere.sdk.specification.yaml.RawServiceSpec in project dcos-commons by mesosphere.

the class Main method createSchedulerBuilder.

private static SchedulerBuilder createSchedulerBuilder(File yamlSpecFile) throws Exception {
    SchedulerConfig schedulerConfig = SchedulerConfig.fromEnv();
    RawServiceSpec rawServiceSpec = RawServiceSpec.newBuilder(yamlSpecFile).build();
    List<String> localSeeds = CassandraSeedUtils.getLocalSeeds(rawServiceSpec.getName(), schedulerConfig);
    return DefaultScheduler.newBuilder(DefaultServiceSpec.newGenerator(rawServiceSpec, schedulerConfig, yamlSpecFile.getParentFile()).setAllPodsEnv("LOCAL_SEEDS", Joiner.on(',').join(localSeeds)).build(), schedulerConfig).setCustomConfigValidators(Arrays.asList(new CassandraZoneValidator(), new TaskEnvCannotChange("node", "server", "CASSANDRA_LOCATION_DATA_CENTER", TaskEnvCannotChange.Rule.ALLOW_UNSET_TO_SET))).setPlansFrom(rawServiceSpec).setCustomResources(getResources(localSeeds)).setRecoveryManagerFactory(new CassandraRecoveryPlanOverriderFactory()).withSingleRegionConstraint();
}
Also used : TaskEnvCannotChange(com.mesosphere.sdk.config.validate.TaskEnvCannotChange) RawServiceSpec(com.mesosphere.sdk.specification.yaml.RawServiceSpec) SchedulerConfig(com.mesosphere.sdk.scheduler.SchedulerConfig)

Example 7 with RawServiceSpec

use of com.mesosphere.sdk.specification.yaml.RawServiceSpec in project dcos-commons by mesosphere.

the class Main method createSchedulerBuilder.

private static SchedulerBuilder createSchedulerBuilder(File yamlSpecFile) throws Exception {
    RawServiceSpec rawServiceSpec = RawServiceSpec.newBuilder(yamlSpecFile).build();
    SchedulerConfig schedulerConfig = SchedulerConfig.fromEnv();
    // Modify pod environments in two ways:
    // 1) Elastic is unhappy if cluster.name contains slashes. Replace any slashes with double-underscores.
    // 2) Base64 decode the custom YAML block.
    DefaultServiceSpec.Generator serviceSpecGenerator = DefaultServiceSpec.newGenerator(rawServiceSpec, schedulerConfig, yamlSpecFile.getParentFile()).setAllPodsEnv("CLUSTER_NAME", SchedulerUtils.withEscapedSlashes(rawServiceSpec.getName()));
    String yamlBase64 = System.getenv(CUSTOM_YAML_BLOCK_BASE64_ENV);
    if (yamlBase64 != null && yamlBase64.length() > 0) {
        String esYamlBlock = new String(Base64.getDecoder().decode(yamlBase64), StandardCharsets.UTF_8);
        serviceSpecGenerator.setAllPodsEnv("CUSTOM_YAML_BLOCK", esYamlBlock);
    }
    return DefaultScheduler.newBuilder(serviceSpecGenerator.build(), schedulerConfig).setCustomConfigValidators(Arrays.asList(new ElasticZoneValidator())).setPlansFrom(rawServiceSpec).withSingleRegionConstraint();
}
Also used : RawServiceSpec(com.mesosphere.sdk.specification.yaml.RawServiceSpec) DefaultServiceSpec(com.mesosphere.sdk.specification.DefaultServiceSpec)

Example 8 with RawServiceSpec

use of com.mesosphere.sdk.specification.yaml.RawServiceSpec in project dcos-commons by mesosphere.

the class Main method createSchedulerBuilder.

private static SchedulerBuilder createSchedulerBuilder(File yamlSpecFile) throws Exception {
    RawServiceSpec rawServiceSpec = RawServiceSpec.newBuilder(yamlSpecFile).build();
    File configDir = yamlSpecFile.getParentFile();
    SchedulerConfig schedulerConfig = SchedulerConfig.fromEnv();
    DefaultServiceSpec serviceSpec = DefaultServiceSpec.newGenerator(rawServiceSpec, schedulerConfig, configDir).setPodEnv("name", SERVICE_ZK_ROOT_TASKENV, CuratorUtils.getServiceRootPath(rawServiceSpec.getName())).setAllPodsEnv(DECODED_AUTH_TO_LOCAL, getHDFSUserAuthMappings(System.getenv(), TASKCFG_ALL_AUTH_TO_LOCAL)).build();
    return DefaultScheduler.newBuilder(setPlacementRules(serviceSpec), schedulerConfig).setRecoveryManagerFactory(new HdfsRecoveryPlanOverriderFactory()).setPlansFrom(rawServiceSpec).setEndpointProducer(HDFS_SITE_XML, EndpointProducer.constant(renderTemplate(new File(configDir, HDFS_SITE_XML), serviceSpec.getName(), schedulerConfig))).setEndpointProducer(CORE_SITE_XML, EndpointProducer.constant(renderTemplate(new File(configDir, CORE_SITE_XML), serviceSpec.getName(), schedulerConfig))).setCustomConfigValidators(Arrays.asList(new HDFSZoneValidator())).withSingleRegionConstraint();
}
Also used : RawServiceSpec(com.mesosphere.sdk.specification.yaml.RawServiceSpec) File(java.io.File) SchedulerConfig(com.mesosphere.sdk.scheduler.SchedulerConfig)

Aggregations

RawServiceSpec (com.mesosphere.sdk.specification.yaml.RawServiceSpec)8 SchedulerConfig (com.mesosphere.sdk.scheduler.SchedulerConfig)4 File (java.io.File)4 SchedulerBuilder (com.mesosphere.sdk.scheduler.SchedulerBuilder)2 MemPersister (com.mesosphere.sdk.storage.MemPersister)2 Test (org.junit.Test)2 TaskEnvCannotChange (com.mesosphere.sdk.config.validate.TaskEnvCannotChange)1 Capabilities (com.mesosphere.sdk.dcos.Capabilities)1 AbstractScheduler (com.mesosphere.sdk.scheduler.AbstractScheduler)1 Phase (com.mesosphere.sdk.scheduler.plan.Phase)1 Plan (com.mesosphere.sdk.scheduler.plan.Plan)1 DefaultServiceSpec (com.mesosphere.sdk.specification.DefaultServiceSpec)1 RawPlan (com.mesosphere.sdk.specification.yaml.RawPlan)1 StateStore (com.mesosphere.sdk.state.StateStore)1 Persister (com.mesosphere.sdk.storage.Persister)1 Map (java.util.Map)1 SchedulerDriver (org.apache.mesos.SchedulerDriver)1