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();
}
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();
}
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();
}
Aggregations