本文整理汇总了Java中org.apache.mesos.Protos.CommandInfo类的典型用法代码示例。如果您正苦于以下问题:Java CommandInfo类的具体用法?Java CommandInfo怎么用?Java CommandInfo使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
CommandInfo类属于org.apache.mesos.Protos包,在下文中一共展示了CommandInfo类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildContainerInfo
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
public static CommandInfo.ContainerInfo buildContainerInfo(Configuration conf) {
String containerImage = conf.get("mapred.mesos.container.image");
String[] containerOptions = conf.getStrings("mapred.mesos.container.options");
CommandInfo.ContainerInfo.Builder containerInfo =
CommandInfo.ContainerInfo.newBuilder();
if (containerImage != null) {
containerInfo.setImage(containerImage);
}
if (containerOptions != null) {
for (int i = 0; i < containerOptions.length; i++) {
containerInfo.addOptions(containerOptions[i]);
}
}
return containerInfo.build();
}
示例2: 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());
}
示例3: 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);
}
示例4: makeExecutorCommand
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
@VisibleForTesting
static CommandInfo makeExecutorCommand(
String thermosExecutorPath,
List<String> thermosExecutorResources,
boolean thermosHomeInSandbox,
String thermosExecutorFlags) {
Stream<String> resourcesToFetch = Stream.concat(
ImmutableList.of(thermosExecutorPath).stream(),
thermosExecutorResources.stream());
StringBuilder sb = new StringBuilder();
if (thermosHomeInSandbox) {
sb.append("HOME=${MESOS_SANDBOX=.} ");
}
// Default to the value of $MESOS_SANDBOX if present. This is necessary for docker tasks,
// in which case the mesos agent is responsible for setting $MESOS_SANDBOX.
sb.append("${MESOS_SANDBOX=.}/");
sb.append(uriBasename(thermosExecutorPath));
sb.append(" ");
sb.append(Optional.ofNullable(thermosExecutorFlags).orElse(""));
return CommandInfo.newBuilder()
.setValue(sb.toString().trim())
.addAllUris(resourcesToFetch
.map(r -> URI.newBuilder().setValue(r).setExecutable(true).build())
.collect(GuavaUtils.toImmutableList()))
.build();
}
示例5: testSingleCommand
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
private void testSingleCommand(
String path,
List<String> resources,
boolean homeInSandbox,
String flags,
String expectedCommand,
List<String> expectedUris) {
CommandInfo info = ExecutorModule.makeExecutorCommand(path, resources, homeInSandbox, flags);
assertEquals(expectedCommand, info.getValue());
assertEquals(expectedUris, extractUris(info.getUrisList()));
}
示例6: getTaskInfo
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
private Protos.TaskInfo getTaskInfo(Protos.SlaveID slaveID, final TaskAssignmentResult result) {
ProcessorTask t = (ProcessorTask) result.getRequest();
Protos.TaskID pTaskId = Protos.TaskID.newBuilder().setValue(t.getId()).build();
// DockerInfo docker = DockerInfo.newBuilder()
// .setImage(t.getProcessor().docker)
// .build();
//
// ContainerInfo container = ContainerInfo.newBuilder()
// .setDocker(docker)
// .setType(ContainerInfo.Type.DOCKER)
// .build();
ExecutorID eid = ExecutorID.newBuilder().setValue(t.getId()).build();
CommandInfo ci = CommandInfo.newBuilder().setValue(configuration.executorCommand).build();
ExecutorInfo executor = ExecutorInfo.newBuilder().setExecutorId(eid).setFrameworkId(frameworkId)
// .setContainer(container)
.setCommand(ci).build();
ByteString data = ByteString.copyFromUtf8(t.getMessage());
Label processorLabel = Label.newBuilder().setKey("processor").setValue(t.getProcessor().toJson())
.build();
Label messageLabel = Label.newBuilder().setKey("message").setValueBytes(data).build();
Labels labels = Labels.newBuilder().addLabels(processorLabel).addLabels(messageLabel).build();
return Protos.TaskInfo.newBuilder().setName("task " + pTaskId.getValue()).setTaskId(pTaskId).setSlaveId(slaveID)
.setLabels(labels).setData(data)
.addResources(Protos.Resource.newBuilder().setName("cpus").setType(Protos.Value.Type.SCALAR)
.setScalar(Protos.Value.Scalar.newBuilder().setValue(t.getCPUs())))
.addResources(Protos.Resource.newBuilder().setName("mem").setType(Protos.Value.Type.SCALAR)
.setScalar(Protos.Value.Scalar.newBuilder().setValue(t.getMemory())))
// .setContainer(container)
// .setCommand(Protos.CommandInfo.newBuilder().setShell(false))
.setExecutor(executor).build();
}
示例7: buildTask
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
/**
* Creates a new task and registers it with the configuration, ready for launch.
*
* @param requirement the task requirement
* @param offer the offer the task will use to run
* @param configuration the scheduler's configuration, used to register the task with
* @return a new task, ready for launch
*/
public static TaskInfo buildTask(Map.Entry<String, Integer> requirement, Offer offer, SchedulerConfiguration configuration) {
TaskID taskId = generateTaskId();
long port = configuration.pickAndRegisterPortNumber(taskId, offer);
ContainerInfo container = buildContainerInfo(port);
Environment environment = buildEnvironment(requirement.getKey());
CommandInfo command = buildCommandInfo(environment);
List<Resource> resources = buildResources(configuration, port); //DCOS-06 Scheduler MUST only use the necessary fraction of an offer.
return buildTaskInfo(taskId, offer, container, command, resources);
}
示例8: 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();
}
示例9: buildTaskInfo
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
/**
* Prepares the TaskInfo for the Kibana task
*
* @param taskId the tasks' ID
* @param offer the offer with which to run the task
* @param containerInfo the tasks' ContainerInfo
* @param commandInfo the tasks' CommandInfo
* @param resources the tasks' resources
* @return the TaskInfo
*/
private static TaskInfo buildTaskInfo(TaskID taskId, Offer offer, ContainerInfo containerInfo, CommandInfo commandInfo, List<Resource> resources) {
TaskInfo.Builder task = TaskInfo.newBuilder()
.setName(taskId.getValue())
.setTaskId(taskId)
.setSlaveId(offer.getSlaveId())
.setContainer(containerInfo)
.setCommand(commandInfo)
.addAllResources(resources);
return task.build();
}
示例10: 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();
}
示例11: 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();
}
示例12: testJHSCommandLineGeneration
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
@Test
public void testJHSCommandLineGeneration() throws Exception {
Map<String, Long> portsMap = new TreeMap<>();
portsMap.put(KEY_JHS_ADDRESS, 0L);
portsMap.put(KEY_JHS_WEBAPP_ADDRESS, 3L);
portsMap.put(KEY_JHS_ADMIN_ADDRESS, 0L);
ServiceResourceProfile profile = new ServiceResourceProfile("jobhistory", 10.0, 15.0, portsMap);
ServiceConfiguration serviceConfiguration = cfg.getServiceConfiguration("jobhistory").get();
ServiceCommandLineGenerator serviceCommandLineGenerator = new ServiceCommandLineGenerator(cfg);
List<Long> ports = new ArrayList<>();
ports.add(2L);
ports.add(1L);
ports.add(3L);
CommandInfo cInfo = serviceCommandLineGenerator.generateCommandLine(profile,
serviceConfiguration,
ports);
String testVal = String.format(CMD_FORMAT, toJHSCompare);
assertTrue(String.format(msgFormat, cInfo.getValue(), testVal),
cInfo.getValue().equals(testVal));
List<Protos.Environment.Variable> environmentList = cInfo.getEnvironment().getVariablesList();
String yarnOpts = "";
for (Protos.Environment.Variable variable: environmentList) {
if (variable.getName().equals(ServiceCommandLineGenerator.ENV_HADOOP_OPTS)){
yarnOpts = variable.getValue();
}
}
assertTrue("Environment contains " + ServiceCommandLineGenerator.ENV_HADOOP_OPTS, StringUtils.isNotEmpty(yarnOpts));
System.out.println(yarnOpts);
assertTrue(ServiceCommandLineGenerator.ENV_HADOOP_OPTS + " must contain -D" + KEY_JHS_WEBAPP_ADDRESS +
"=0.0.0.0:3", yarnOpts.contains(KEY_JHS_WEBAPP_ADDRESS + "=0.0.0.0:3"));
}
示例13: testNMCommandLineGeneration
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
@Test
public void testNMCommandLineGeneration() throws Exception {
Long[] ports = new Long[]{1L, 2L, 3L, 4L};
List<Long> nmPorts = Arrays.asList(ports);
Map<String, Long> portsMap = new TreeMap<>();
portsMap.put(KEY_NM_ADDRESS, 0L);
portsMap.put(KEY_NM_WEBAPP_ADDRESS, 0L);
portsMap.put(KEY_NM_LOCALIZER_ADDRESS, 0L);
portsMap.put(KEY_NM_SHUFFLE_PORT, 0L);
ServiceResourceProfile profile = new ExtendedResourceProfile(new NMProfile("nm", 10L, 15L), 3.0, 5.0, portsMap);
ExecutorCommandLineGenerator clGenerator = new NMExecutorCommandLineGenerator(cfg);
CommandInfo cInfo = clGenerator.generateCommandLine(profile, null, nmPorts);
String testVal = String.format(CMD_FORMAT, toCompare);
assertTrue(String.format(msgFormat, cInfo.getValue(), testVal),
cInfo.getValue().equals(testVal));
List<Protos.Environment.Variable> environmentList = cInfo.getEnvironment().getVariablesList();
String yarnOpts = "";
for (Protos.Environment.Variable variable: environmentList) {
if (variable.getName().equals(NMExecutorCommandLineGenerator.ENV_YARN_NODEMANAGER_OPTS)){
yarnOpts = variable.getValue();
}
}
System.out.println(yarnOpts);
assertTrue("Environment contains " + NMExecutorCommandLineGenerator.ENV_YARN_NODEMANAGER_OPTS, StringUtils.isNotEmpty(yarnOpts));
assertTrue(NMExecutorCommandLineGenerator.ENV_YARN_NODEMANAGER_OPTS + " must contain -D" + KEY_NM_SHUFFLE_PORT +
"=1", yarnOpts.contains(KEY_NM_SHUFFLE_PORT + "=1"));
}
示例14: reloadConfig
import org.apache.mesos.Protos.CommandInfo; //导入依赖的package包/类
protected void reloadConfig(String filename)
{
if (hbaseFrameworkConfig.usingNativeHadoopBinaries()) {
return;
}
// Find config URI
String configUri = "";
for (CommandInfo.URI uri : executorInfo.getCommand().getUrisList()) {
if (uri.getValue().contains(filename)) {
configUri = uri.getValue();
}
}
if (configUri.isEmpty()) {
log.error("Couldn't find hbase-site.xml URI");
return;
}
try {
log.info(String.format("Reloading "+filename+" from %s", configUri));
ProcessBuilder processBuilder = new ProcessBuilder("sh", "-c",
String.format("curl -o "+filename+" %s && mv "+filename+" conf/", configUri));
Process process = processBuilder.start();
//TODO(nicgrayson) check if the config has changed
redirectProcess(process);
int exitCode = process.waitFor();
if (exitCode == 0) {
log.info("Finished reloading hbase-site.xml, exited with status " + exitCode);
} else {
log.error("Error reloading hbase-site.xml.");
}
} catch (InterruptedException | IOException e) {
log.error("Caught exception", e);
}
}
示例15: 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()));
}
}
}