@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(); } }
private Protos.CommandInfo buildCommand(final Protos.CommandInfo.URI uri, final String script, final ShardingContexts shardingContexts, final boolean isCommandExecutor) { Protos.CommandInfo.Builder result = Protos.CommandInfo.newBuilder().addUris(uri).setShell(true); if (isCommandExecutor) { CommandLine commandLine = CommandLine.parse(script); commandLine.addArgument(GsonFactory.getGson().toJson(shardingContexts), false); result.setValue(Joiner.on(" ").join(commandLine.getExecutable(), Joiner.on(" ").join(commandLine.getArguments()))); } else { result.setValue(script); } return result.build(); }
commandBuilder.setShell(false); commandBuilder.setValue(customShell); List args = new ArrayList();
.setScalar(Protos.Value.Scalar.newBuilder().setValue(128))) .setContainer(containerInfoBuilder) .setCommand(Protos.CommandInfo.newBuilder().setShell(false)) .build();