.setEnvironment(Protos.Environment.newBuilder() .addVariables(Protos.Environment.Variable.newBuilder() .setName("IGNITE_TCP_DISCOVERY_ADDRESSES")
@Override public Protos.CommandInfo create(Map<String, String> additionalEnvironmentVariables) { Protos.CommandInfo.Builder builder = Protos.CommandInfo.newBuilder(); Optional<String> command = Optional.ofNullable(mesosConfig.getCommand()); builder.setShell(command.isPresent()); command.ifPresent(builder::setValue); builder.addAllUris(mesosConfig.getUri().stream().map(uri -> Protos.CommandInfo.URI.newBuilder().setValue(uri).build()).collect(Collectors.toList())); Map<String, String> environmentVariables = new LinkedHashMap<>(); environmentVariables.putAll(additionalEnvironmentVariables); environmentVariables.putAll(mesosConfig.getEnvironment()); //todo: migrate to foreach environmentVariables.entrySet().stream() .map(kv -> Protos.Environment.Variable.newBuilder().setName(kv.getKey()).setValue(kv.getValue()).build()) .collect(Collectors.collectingAndThen( Collectors.toList(), variables -> builder.setEnvironment(Protos.Environment.newBuilder().addAllVariables(variables)))); return builder.build(); } }
/** * Updates the stored readiness check, if any, to have the provided environment variable. * Does nothing if no readiness check is present. * * @throws TaskException if parsing a previously set {@link HealthCheck} */ public TaskLabelWriter setReadinessCheckEnvvar(String key, String value) throws TaskException { Optional<HealthCheck> readinessCheck = getReadinessCheck(); if (!readinessCheck.isPresent()) { return this; } HealthCheck.Builder readinessCheckBuilder = readinessCheck.get().toBuilder(); readinessCheckBuilder.getCommandBuilder().setEnvironment( EnvUtils.withEnvVar(readinessCheckBuilder.getCommand().getEnvironment(), key, value)); return setReadinessCheck(readinessCheckBuilder.build()); }
.setEnvironment(envBuilder) .setValue(String.format("cd %s && %s", directory, command)); if (uri != null) {
.setEnvironment(envBuilder) .setValue(String.format("cd %s && %s", directory, command)) .addUris(CommandInfo.URI.newBuilder().setValue(uri)).build();
commandBuilder.setEnvironment(EnvUtils.toProto(getTaskEnvironment(serviceName, podInstance, taskSpec,
taskBuilder.getCommandBuilder().setEnvironment( EnvUtils.withEnvVar( taskBuilder.getCommandBuilder().getEnvironment(), Protos.CommandInfo.Builder healthCheckCmdBuilder = taskBuilder.getHealthCheckBuilder().getCommandBuilder(); healthCheckCmdBuilder.setEnvironment( EnvUtils.withEnvVar(healthCheckCmdBuilder.getEnvironment(), portEnvKey, portEnvVal)); } else { checkCmdBuilder.setEnvironment( EnvUtils.withEnvVar(checkCmdBuilder.getEnvironment(), portEnvKey, portEnvVal)); if (portEnvKey != null) { Protos.CommandInfo.Builder executorCmdBuilder = executorBuilder.getCommandBuilder(); executorCmdBuilder.setEnvironment( EnvUtils.withEnvVar(executorCmdBuilder.getEnvironment(), portEnvKey, portEnvVal));
private void setReadinessCheck( Protos.TaskInfo.Builder taskInfoBuilder, String serviceName, PodInstance podInstance, TaskSpec taskSpec, GoalStateOverride override, SchedulerConfig schedulerConfig) { Optional<ReadinessCheckSpec> readinessCheckSpecOptional = getReadinessCheck(taskSpec, override); if (!readinessCheckSpecOptional.isPresent()) { LOGGER.debug("No readiness check defined for taskSpec: {}", taskSpec.getName()); return; } ReadinessCheckSpec readinessCheckSpec = readinessCheckSpecOptional.get(); // Default executor supports the newer TaskInfo.check field: Protos.CheckInfo.Builder builder = taskInfoBuilder.getCheckBuilder() .setType(Protos.CheckInfo.Type.COMMAND) .setDelaySeconds(readinessCheckSpec.getDelay()) .setIntervalSeconds(readinessCheckSpec.getInterval()) .setTimeoutSeconds(readinessCheckSpec.getTimeout()); builder.getCommandBuilder().getCommandBuilder() .setValue(readinessCheckSpec.getCommand()) .setEnvironment(EnvUtils.toProto(getTaskEnvironment(serviceName, podInstance, taskSpec, schedulerConfig))); }
.setEnvironment(EnvUtils.toProto(getTaskEnvironment(serviceName, podInstance, taskSpec,
private static void setBootstrapConfigFileEnv(Protos.CommandInfo.Builder commandInfoBuilder, TaskSpec taskSpec) { if (taskSpec.getConfigFiles() == null) { return; } for (ConfigFileSpec config : taskSpec.getConfigFiles()) { // For use by bootstrap process: an environment variable pointing to (comma-separated): // a. where the template file was downloaded (by the mesos fetcher) // b. where the rendered result should go commandInfoBuilder.setEnvironment(EnvUtils.withEnvVar( commandInfoBuilder.getEnvironment(), String.format(CONFIG_TEMPLATE_KEY_FORMAT, EnvUtils.toEnvName(config.getName())), String.format("%s,%s", getConfigTemplateDownloadPath(config), config.getRelativePath()))); } }
private static Protos.TaskInfo createTaskInfoWithZone(String taskName, String zone) { return Protos.TaskInfo.newBuilder(createTask(taskName)) .setCommand(Protos.CommandInfo.newBuilder() .setEnvironment(Protos.Environment.newBuilder() .addVariables(Protos.Environment.Variable.newBuilder() .setName(EnvConstants.ZONE_TASKENV) .setValue(zone)))) .build(); }
public static CommandInfo createCommandInfo( final String command, final List<String> arguments, final Set<String> uris, boolean cacheFetchedUris, final Map<String, String> environment) { return CommandInfo.newBuilder() .setValue(command) .addAllArguments(arguments) .addAllUris(createURIs(uris, cacheFetchedUris)) .setEnvironment(createEnvironment(environment)).build(); }
public static Protos.TaskInfo getTaskInfoExternalVolume(Integer esNodeId) { return Protos.TaskInfo.newBuilder(getDefaultTaskInfo()) .setCommand(Protos.CommandInfo.newBuilder() .setValue("") .setEnvironment(Protos.Environment.newBuilder() .addVariables(Protos.Environment.Variable.newBuilder() .setName(ExecutorEnvironmentalVariables.ELASTICSEARCH_NODE_ID) .setValue(esNodeId.toString()))) .build()) .build(); }