本文整理汇总了Java中org.apache.mesos.Protos.CommandInfo.Builder方法的典型用法代码示例。如果您正苦于以下问题:Java CommandInfo.Builder方法的具体用法?Java CommandInfo.Builder怎么用?Java CommandInfo.Builder使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos.CommandInfo
的用法示例。
在下文中一共展示了CommandInfo.Builder方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: prepareEnvironment
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
private void prepareEnvironment(final SingularityTaskRequest task, SingularityTaskId taskId, CommandInfo.Builder commandBuilder, final Protos.Offer offer, final Optional<long[]> ports) {
Environment.Builder envBldr = Environment.newBuilder();
setEnv(envBldr, "INSTANCE_NO", task.getPendingTask().getPendingTaskId().getInstanceNo());
setEnv(envBldr, "TASK_HOST", offer.getHostname());
Optional<String> rack = slaveAndRackHelper.getRackId(offer);
if (rack.isPresent()) {
setEnv(envBldr, "TASK_RACK_ID", rack.get());
}
setEnv(envBldr, "TASK_REQUEST_ID", task.getPendingTask().getPendingTaskId().getRequestId());
setEnv(envBldr, "TASK_DEPLOY_ID", taskId.getDeployId());
setEnv(envBldr, "ESTIMATED_INSTANCE_COUNT", task.getRequest().getInstancesSafe());
for (Entry<String, String> envEntry : task.getDeploy().getEnv().or(Collections.<String, String>emptyMap()).entrySet()) {
setEnv(envBldr, envEntry.getKey(), envEntry.getValue());
}
if (ports.isPresent()) {
for (int portNum = 0; portNum < ports.get().length; portNum++) {
if (portNum == 0) {
setEnv(envBldr, "PORT", ports.get()[portNum]);
}
setEnv(envBldr, String.format("PORT%s", portNum), ports.get()[portNum]);
}
}
commandBuilder.setEnvironment(envBldr.build());
}
示例2: prepareCommand
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
private void prepareCommand(final TaskInfo.Builder bldr, final SingularityTaskId taskId, final SingularityTaskRequest task, final Protos.Offer offer, final Optional<long[]> ports) {
CommandInfo.Builder commandBldr = CommandInfo.newBuilder();
if (task.getDeploy().getCommand().isPresent()) {
commandBldr.setValue(task.getDeploy().getCommand().get());
}
if (task.getDeploy().getArguments().isPresent()) {
commandBldr.addAllArguments(task.getDeploy().getArguments().get());
}
if (task.getPendingTask().getCmdLineArgsList().isPresent()) {
commandBldr.addAllArguments(task.getPendingTask().getCmdLineArgsList().get());
}
if (task.getDeploy().getArguments().isPresent() ||
// Hopefully temporary workaround for
// http://www.mail-archive.com/[email protected]/msg01449.html
task.getDeploy().getContainerInfo().isPresent() ||
task.getPendingTask().getCmdLineArgsList().isPresent()) {
commandBldr.setShell(false);
}
for (String uri : task.getDeploy().getUris().or(Collections.<String> emptyList())) {
commandBldr.addUris(URI.newBuilder().setValue(uri).build());
}
prepareEnvironment(task, taskId, commandBldr, offer, ports);
bldr.setCommand(commandBldr);
}
示例3: buildCommandInfo
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
/**
* Prepares a CommandInfoBuilder, including the given Environment
*
* @param environment the Environment to include
* @return the CommandInfoBuilder
*/
private static CommandInfo buildCommandInfo(Environment environment) {
CommandInfo.Builder commandInfoBuilder = CommandInfo.newBuilder();
commandInfoBuilder.setEnvironment(environment);
commandInfoBuilder.setShell(false);
return commandInfoBuilder.build();
}
示例4: generateCommandLine
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
@Override
CommandInfo generateCommandLine(ServiceResourceProfile profile,
ServiceConfiguration serviceConfiguration, Collection<Long> ports) {
CommandInfo.Builder builder = CommandInfo.newBuilder();
builder.mergeFrom(staticCommandInfo);
builder.setEnvironment(generateEnvironment(profile, ports));
builder.setUser(getUser());
return builder.build();
}
示例5: generateStaticCommandLine
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
protected void generateStaticCommandLine() {
CommandInfo.Builder builder = CommandInfo.newBuilder();
StringBuilder cmdLine = new StringBuilder();
appendCgroupsCmds(cmdLine);
appendDistroExtractionCommands(cmdLine);
appendUserSudo(cmdLine);
cmdLine.append(YARN_NM_CMD);
builder.setValue(String.format(CMD_FORMAT, cmdLine.toString()));
builder.addAllUris(getUris());
staticCommandInfo = builder.build();
}
示例6: detectAndAddAdditionalURIs
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
private void detectAndAddAdditionalURIs(Request request, CommandInfo.Builder commandBuilder) {
if (request.request.slaveInfo.getAdditionalURIs() != null) {
for (MesosSlaveInfo.URI uri : request.request.slaveInfo.getAdditionalURIs()) {
commandBuilder.addUris(
CommandInfo.URI.newBuilder().setValue(
uri.getValue()).setExecutable(uri.isExecutable()).setExtract(uri.isExtract()));
}
}
}
示例7: getBaseCommandBuilder
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
private CommandInfo.Builder getBaseCommandBuilder(Request request) {
CommandInfo.Builder commandBuilder = CommandInfo.newBuilder();
String jenkinsCommand2Run = generateJenkinsCommand2Run(
request.request.slaveInfo.getSlaveMem(),
request.request.slaveInfo.getJvmArgs(),
request.request.slaveInfo.getJnlpArgs(),
request.request.slave.name);
if (request.request.slaveInfo.getContainerInfo() != null &&
request.request.slaveInfo.getContainerInfo().getUseCustomDockerCommandShell()) {
// Ref http://mesos.apache.org/documentation/latest/upgrades
// regarding setting the shell value, and the impact on the command to be
// launched
String customShell = request.request.slaveInfo.getContainerInfo().getCustomDockerCommandShell();
if (StringUtils.stripToNull(customShell)==null) {
throw new IllegalArgumentException("Invalid custom shell argument supplied ");
}
LOGGER.fine( String.format( "About to use custom shell: %s " , customShell));
commandBuilder.setShell(false);
commandBuilder.setValue(customShell);
List args = new ArrayList();
args.add(jenkinsCommand2Run);
commandBuilder.addAllArguments( args );
} else {
LOGGER.fine("About to use default shell ....");
commandBuilder.setValue(jenkinsCommand2Run);
}
commandBuilder.addUris(
CommandInfo.URI.newBuilder().setValue(
joinPaths(jenkinsMaster, SLAVE_JAR_URI_SUFFIX)).setExecutable(false).setExtract(false));
return commandBuilder;
}
示例8: prepareCustomExecutor
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
private void prepareCustomExecutor(final TaskInfo.Builder bldr, final SingularityTaskId taskId, final SingularityTaskRequest task, final Protos.Offer offer,
final Optional<long[]> ports, final Resources desiredExecutorResources) {
CommandInfo.Builder commandBuilder = CommandInfo.newBuilder().setValue(task.getDeploy().getCustomExecutorCmd().get());
prepareEnvironment(task, taskId, commandBuilder, offer, ports);
if (task.getDeploy().getCustomExecutorUser().isPresent()) {
commandBuilder.setUser(task.getDeploy().getCustomExecutorUser().get());
}
bldr.setExecutor(ExecutorInfo.newBuilder()
.setCommand(commandBuilder.build())
.setExecutorId(ExecutorID.newBuilder().setValue(task.getDeploy().getCustomExecutorId().or(idGenerator.getNextExecutorId())))
.setSource(task.getDeploy().getCustomExecutorSource().or(task.getPendingTask().getPendingTaskId().getId()))
.addAllResources(buildMesosResources(desiredExecutorResources))
.build()
);
if (task.getDeploy().getExecutorData().isPresent()) {
final ExecutorDataBuilder executorDataBldr = task.getDeploy().getExecutorData().get().toBuilder();
if (configuration.getS3Configuration().isPresent()) {
if (task.getRequest().getGroup().isPresent() && configuration.getS3Configuration().get().getGroupOverrides().containsKey(task.getRequest().getGroup().get())) {
final Optional<String> loggingS3Bucket = Optional.of(configuration.getS3Configuration().get().getGroupOverrides().get(task.getRequest().getGroup().get()).getS3Bucket());
LOG.trace("Setting loggingS3Bucket to {} for task {} executorData", loggingS3Bucket, taskId.getId());
executorDataBldr.setLoggingS3Bucket(loggingS3Bucket);
}
}
if (task.getPendingTask().getCmdLineArgsList().isPresent() && !task.getPendingTask().getCmdLineArgsList().get().isEmpty()) {
LOG.trace("Adding cmd line args {} to task {} executorData", task.getPendingTask().getCmdLineArgsList(), taskId.getId());
final ImmutableList.Builder<String> extraCmdLineArgsBuilder = ImmutableList.builder();
if (executorDataBldr.getExtraCmdLineArgs() != null && !executorDataBldr.getExtraCmdLineArgs().isEmpty()) {
extraCmdLineArgsBuilder.addAll(executorDataBldr.getExtraCmdLineArgs());
}
extraCmdLineArgsBuilder.addAll(task.getPendingTask().getCmdLineArgsList().get());
executorDataBldr.setExtraCmdLineArgs(extraCmdLineArgsBuilder.build());
}
final ExecutorData executorData = executorDataBldr.build();
try {
bldr.setData(ByteString.copyFromUtf8(objectMapper.writeValueAsString(executorData)));
} catch (JsonProcessingException e) {
LOG.warn("Unable to process executor data {} for task {} as json (trying as string)", executorData, taskId.getId(), e);
bldr.setData(ByteString.copyFromUtf8(executorData.toString()));
}
} else if (task.getDeploy().getCommand().isPresent()) {
bldr.setData(ByteString.copyFromUtf8(task.getDeploy().getCommand().get()));
}
}
示例9: getCommandInfo
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
private static CommandInfo getCommandInfo() {
CommandInfo.Builder cmdInfoBuilder = Protos.CommandInfo.newBuilder();
cmdInfoBuilder.addUris(getUri());
cmdInfoBuilder.setValue(command);
return cmdInfoBuilder.build();
}
示例10: createYARNTask
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
public static TaskInfo createYARNTask(Offer offer, NodeTask nodeTask) {
NMProfile profile = nodeTask.getProfile();
TaskID taskId = TaskID.newBuilder().setValue(nodeTask.getTaskId())
.build();
String taskIdValue = taskId.getValue();
LOGGER.info("Launching task {} with profile: {}", taskIdValue, profile);
String revisedConfig = getRevisedConfig(profile.getCpus(),
profile.getMemory());
String CONFIG_UPDATE_CMD = "sudo -H -u hduser bash -c \"echo '"
+ revisedConfig
+ "' > /usr/local/hadoop/etc/hadoop/yarn-site.xml\"; ";
CommandInfo.Builder commandBuilder = CommandInfo.newBuilder();
commandBuilder.setUser("root").setValue(
CONFIG_UPDATE_CMD + NM_LAUNCH_CMD);
TaskInfo task = TaskInfo
.newBuilder()
.setName("task " + taskIdValue)
.setTaskId(taskId)
.setSlaveId(offer.getSlaveId())
.addResources(
Resource.newBuilder()
.setName("cpus")
.setType(Value.Type.SCALAR)
.setScalar(
Value.Scalar.newBuilder()
.setValue(profile.getCpus())
.build()).build())
.addResources(
Resource.newBuilder()
.setName("mem")
.setType(Value.Type.SCALAR)
.setScalar(
Value.Scalar.newBuilder()
.setValue(profile.getMemory())
.build()).build())
.setCommand(commandBuilder.build()).build();
return task;
}
示例11: createMesosTask
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
private void createMesosTask(Offer offer, Request request) {
final String slaveName = request.request.slave.name;
TaskID taskId = TaskID.newBuilder().setValue(slaveName).build();
LOGGER.fine("Launching task " + taskId.getValue() + " with URI " +
joinPaths(jenkinsMaster, SLAVE_JAR_URI_SUFFIX));
if (isExistingTask(taskId)) {
refuseOffer(offer);
return;
}
Jenkins jenkins = getJenkins();
for (final Computer computer : jenkins.getComputers()) {
if (!MesosComputer.class.isInstance(computer)) {
LOGGER.finer("Not a mesos computer, skipping");
continue;
}
MesosComputer mesosComputer = (MesosComputer) computer;
MesosSlave mesosSlave = mesosComputer.getNode();
if (taskId.getValue().equals(computer.getName()) && mesosSlave.isPendingDelete()) {
LOGGER.info("This mesos task " + taskId.getValue() + " is pending deletion. Not launching another task");
driver.declineOffer(offer.getId());
}
}
CommandInfo.Builder commandBuilder = getCommandInfoBuilder(request);
TaskInfo.Builder taskBuilder = getTaskInfoBuilder(offer, request, taskId, commandBuilder);
if (request.request.slaveInfo.getContainerInfo() != null) {
getContainerInfoBuilder(offer, request, slaveName, taskBuilder);
}
List<TaskInfo> tasks = new ArrayList<TaskInfo>();
tasks.add(taskBuilder.build());
Filters filters = Filters.newBuilder().setRefuseSeconds(1).build();
driver.launchTasks(offer.getId(), tasks, filters);
results.put(taskId, new Result(request.result, new Mesos.JenkinsSlave(offer.getSlaveId()
.getValue())));
finishedTasks.add(taskId);
}
示例12: getCommandInfoBuilder
import org.apache.mesos.Protos.CommandInfo; //导入方法依赖的package包/类
@VisibleForTesting
CommandInfo.Builder getCommandInfoBuilder(Request request) {
CommandInfo.Builder commandBuilder = getBaseCommandBuilder(request);
detectAndAddAdditionalURIs(request, commandBuilder);
return commandBuilder;
}