Java Code Examples for org.apache.mesos.Protos#CommandInfo
The following examples show how to use
org.apache.mesos.Protos#CommandInfo .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: MockExecutorDriver.java From cassandra-mesos-deprecated with Apache License 2.0 | 6 votes |
public void launchTask( @NotNull final Protos.TaskID taskId, @NotNull final Protos.CommandInfo commandInfo, @NotNull final CassandraFrameworkProtos.TaskDetails taskDetails, @NotNull final String name, @NotNull final Iterable<? extends Protos.Resource> resources ) { executor.launchTask(this, Protos.TaskInfo.newBuilder() .setTaskId(taskId) .setCommand(commandInfo) .setData(taskDetails.toByteString()) .setExecutor(executorInfo) .setName(name) .addAllResources(resources) .setSlaveId(slaveInfo.getId()) .build()); }
Example 2
Source File: TaskLaunchScheduledService.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 6 votes |
private Protos.TaskInfo buildCustomizedExecutorTaskInfo(final TaskContext taskContext, final CloudAppConfiguration appConfig, final CloudJobConfiguration jobConfig, final ShardingContexts shardingContexts, final Protos.Offer offer, final Protos.CommandInfo command) { Protos.TaskInfo.Builder result = Protos.TaskInfo.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskContext.getId()).build()) .setName(taskContext.getTaskName()).setSlaveId(offer.getSlaveId()) .addResources(buildResource("cpus", jobConfig.getCpuCount(), offer.getResourcesList())) .addResources(buildResource("mem", jobConfig.getMemoryMB(), offer.getResourcesList())) .setData(ByteString.copyFrom(new TaskInfoData(shardingContexts, jobConfig).serialize())); Protos.ExecutorInfo.Builder executorBuilder = Protos.ExecutorInfo.newBuilder().setExecutorId(Protos.ExecutorID.newBuilder() .setValue(taskContext.getExecutorId(jobConfig.getAppName()))).setCommand(command) .addResources(buildResource("cpus", appConfig.getCpuCount(), offer.getResourcesList())) .addResources(buildResource("mem", appConfig.getMemoryMB(), offer.getResourcesList())); if (env.getJobEventRdbConfiguration().isPresent()) { executorBuilder.setData(ByteString.copyFrom(SerializationUtils.serialize(env.getJobEventRdbConfigurationMap()))).build(); } return result.setExecutor(executorBuilder.build()).build(); }
Example 3
Source File: ServiceTaskFactory.java From incubator-myriad with Apache License 2.0 | 6 votes |
@Override public Protos.TaskInfo createTask(ResourceOfferContainer resourceOfferContainer, Protos.FrameworkID frameworkId, Protos.TaskID taskId, NodeTask nodeTask) { ServiceConfiguration serviceConfig = cfg.getServiceConfiguration(nodeTask.getTaskPrefix()).get(); Objects.requireNonNull(serviceConfig, "ServiceConfig should be non-null"); Objects.requireNonNull(serviceConfig.getCommand().orNull(), "command for ServiceConfig should be non-null"); List<Protos.Resource> portResources = resourceOfferContainer.consumePorts(nodeTask.getProfile().getPorts().values()); Protos.CommandInfo commandInfo = clGenerator.generateCommandLine(nodeTask.getProfile(), serviceConfig, rangesConverter(portResources)); LOGGER.info("Command line for service: {} is: {}", commandInfo.getValue()); Protos.TaskInfo.Builder taskBuilder = Protos.TaskInfo.newBuilder(); taskBuilder.setName(nodeTask.getTaskPrefix()).setTaskId(taskId).setSlaveId(resourceOfferContainer.getSlaveId()) .addAllResources(resourceOfferContainer.consumeCpus(nodeTask.getProfile().getCpus())) .addAllResources(resourceOfferContainer.consumeMem(nodeTask.getProfile().getMemory())) .addAllResources(portResources); taskBuilder.setCommand(commandInfo); if (cfg.getContainerInfo().isPresent()) { taskBuilder.setContainer(getContainerInfo()); } return taskBuilder.build(); }
Example 4
Source File: DefaultV3TaskInfoRequestFactory.java From titus-control-plane with Apache License 2.0 | 6 votes |
private Protos.ExecutorInfo newExecutorInfo(Task task, Map<String, String> attributesMap, Optional<String> executorUriOverrideOpt) { boolean executorPerTask = attributesMap.containsKey(EXECUTOR_PER_TASK_LABEL); String executorName = LEGACY_EXECUTOR_NAME; String executorId = LEGACY_EXECUTOR_NAME; if (executorPerTask) { executorName = EXECUTOR_PER_TASK_EXECUTOR_NAME; executorId = EXECUTOR_PER_TASK_EXECUTOR_NAME + "-" + task.getId(); } Protos.CommandInfo commandInfo = newCommandInfo(executorPerTask, executorUriOverrideOpt); return Protos.ExecutorInfo.newBuilder() .setExecutorId(Protos.ExecutorID.newBuilder().setValue(executorId).build()) .setName(executorName) .setCommand(commandInfo) .build(); }
Example 5
Source File: DefaultV3TaskInfoRequestFactory.java From titus-control-plane with Apache License 2.0 | 6 votes |
private Protos.CommandInfo newCommandInfo(boolean executorPerTask, Optional<String> executorUriOverrideOpt) { Protos.CommandInfo.URI.Builder uriBuilder = Protos.CommandInfo.URI.newBuilder(); Protos.CommandInfo.Builder commandInfoBuilder = Protos.CommandInfo.newBuilder(); if (executorPerTask && mesosConfiguration.isExecutorUriOverrideEnabled() && executorUriOverrideOpt.isPresent()) { commandInfoBuilder.setShell(false); commandInfoBuilder.setValue(mesosConfiguration.getExecutorUriOverrideCommand()); uriBuilder.setValue(executorUriOverrideOpt.get()); uriBuilder.setExtract(true); uriBuilder.setCache(true); commandInfoBuilder.addUris(uriBuilder.build()); } else { commandInfoBuilder.setValue(masterConfiguration.pathToTitusExecutor()); } return commandInfoBuilder.build(); }
Example 6
Source File: NMTaskFactory.java From incubator-myriad with Apache License 2.0 | 6 votes |
@Override public Protos.TaskInfo createTask(ResourceOfferContainer resourceOfferContainer, Protos.FrameworkID frameworkId, Protos.TaskID taskId, NodeTask nodeTask) { ServiceResourceProfile serviceProfile = nodeTask.getProfile(); Double taskMemory = serviceProfile.getAggregateMemory(); Double taskCpus = serviceProfile.getAggregateCpu(); List<Protos.Resource> portResources = resourceOfferContainer.consumePorts(serviceProfile.getPorts().values()); Protos.CommandInfo commandInfo = clGenerator.generateCommandLine(serviceProfile, null, rangesConverter(portResources)); Protos.ExecutorInfo executorInfo = getExecutorInfoForSlave(resourceOfferContainer, frameworkId, commandInfo); Protos.TaskInfo.Builder taskBuilder = Protos.TaskInfo.newBuilder().setName(cfg.getFrameworkName() + "-" + taskId.getValue()).setTaskId(taskId).setSlaveId( resourceOfferContainer.getSlaveId()); return taskBuilder .addAllResources(resourceOfferContainer.consumeCpus(taskCpus)) .addAllResources(resourceOfferContainer.consumeMem(taskMemory)) .addAllResources(portResources) .setExecutor(executorInfo) .build(); }
Example 7
Source File: TaskInfoFactory.java From elasticsearch with Apache License 2.0 | 6 votes |
private Protos.CommandInfo nativeCommand(Configuration configuration, List<String> args, Long elasticSearchNodeId) { String address = configuration.getFrameworkFileServerAddress(); if (address == null) { throw new NullPointerException("Webserver address is null"); } String httpPath = address + "/get/" + Configuration.ES_TAR; String command = configuration.nativeCommand(args); final Protos.Environment environment = Protos.Environment.newBuilder().addAllVariables(new ExecutorEnvironmentalVariables(configuration, elasticSearchNodeId).getList()).build(); final Protos.CommandInfo.Builder builder = Protos.CommandInfo.newBuilder() .setShell(true) .setValue(command) .setUser("root") .mergeEnvironment(environment); if (configuration.getElasticsearchBinary().isEmpty()) { builder.addUris(Protos.CommandInfo.URI.newBuilder().setValue(httpPath)); } else { builder.addUris(Protos.CommandInfo.URI.newBuilder().setValue(configuration.getElasticsearchBinary())); } if (!configuration.getElasticsearchSettingsLocation().isEmpty()) { builder.addUris(Protos.CommandInfo.URI.newBuilder().setValue(configuration.getElasticsearchSettingsLocation())); } return builder .build(); }
Example 8
Source File: TaskInfoFactory.java From elasticsearch with Apache License 2.0 | 5 votes |
private Protos.CommandInfo dockerCommand(Configuration configuration, List<String> args, Long elasticSearchNodeId) { final Protos.Environment environment = Protos.Environment.newBuilder().addAllVariables(new ExecutorEnvironmentalVariables(configuration, elasticSearchNodeId).getList()).build(); final Protos.CommandInfo.Builder builder = Protos.CommandInfo.newBuilder() .setShell(false) .mergeEnvironment(environment) .addAllArguments(args); if (!configuration.getElasticsearchSettingsLocation().isEmpty()) { builder.addUris(Protos.CommandInfo.URI.newBuilder().setValue(configuration.getElasticsearchSettingsLocation())); } return builder .build(); }
Example 9
Source File: NMTaskFactory.java From incubator-myriad with Apache License 2.0 | 5 votes |
@Override public Protos.ExecutorInfo getExecutorInfoForSlave(ResourceOfferContainer resourceOfferContainer, Protos.FrameworkID frameworkId, Protos.CommandInfo commandInfo) { Protos.ExecutorID executorId = Protos.ExecutorID.newBuilder() .setValue(EXECUTOR_PREFIX + frameworkId.getValue() + resourceOfferContainer.getOfferId() + resourceOfferContainer.getSlaveId().getValue()) .build(); Protos.ExecutorInfo.Builder executorInfo = Protos.ExecutorInfo.newBuilder().setCommand(commandInfo).setName(EXECUTOR_NAME).setExecutorId(executorId) .addAllResources(resourceOfferContainer.consumeCpus(taskUtils.getExecutorCpus())) .addAllResources(resourceOfferContainer.consumeMem(taskUtils.getExecutorMemory())); if (cfg.getContainerInfo().isPresent()) { executorInfo.setContainer(getContainerInfo()); } return executorInfo.build(); }
Example 10
Source File: ServiceCommandLineGenerator.java From incubator-myriad with Apache License 2.0 | 5 votes |
@Override public Protos.CommandInfo generateCommandLine(ServiceResourceProfile profile, ServiceConfiguration serviceConfiguration, Collection<Long> ports) { Protos.CommandInfo.Builder builder = Protos.CommandInfo.newBuilder(); builder.mergeFrom(staticCommandInfo); builder.setValue(String.format(CMD_FORMAT, baseCmd + " " + serviceConfiguration.getCommand().get())); builder.setEnvironment(generateEnvironment(profile, ports)); return builder.build(); }
Example 11
Source File: TaskLaunchScheduledService.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 5 votes |
private Protos.TaskInfo getTaskInfo(final Protos.Offer offer, final TaskAssignmentResult taskAssignmentResult) { TaskContext taskContext = TaskContext.from(taskAssignmentResult.getTaskId()); Optional<CloudJobConfiguration> jobConfigOptional = facadeService.load(taskContext.getMetaInfo().getJobName()); if (!jobConfigOptional.isPresent()) { return null; } CloudJobConfiguration jobConfig = jobConfigOptional.get(); Optional<CloudAppConfiguration> appConfigOptional = facadeService.loadAppConfig(jobConfig.getAppName()); if (!appConfigOptional.isPresent()) { return null; } CloudAppConfiguration appConfig = appConfigOptional.get(); taskContext.setSlaveId(offer.getSlaveId().getValue()); ShardingContexts shardingContexts = getShardingContexts(taskContext, appConfig, jobConfig); boolean isCommandExecutor = CloudJobExecutionType.TRANSIENT == jobConfig.getJobExecutionType() && JobType.SCRIPT == jobConfig.getTypeConfig().getJobType(); String script = appConfig.getBootstrapScript(); if (isCommandExecutor) { script = ((ScriptJobConfiguration) jobConfig.getTypeConfig()).getScriptCommandLine(); } Protos.CommandInfo.URI uri = buildURI(appConfig, isCommandExecutor); Protos.CommandInfo command = buildCommand(uri, script, shardingContexts, isCommandExecutor); if (isCommandExecutor) { return buildCommandExecutorTaskInfo(taskContext, jobConfig, shardingContexts, offer, command); } else { return buildCustomizedExecutorTaskInfo(taskContext, appConfig, jobConfig, shardingContexts, offer, command); } }
Example 12
Source File: TaskTestUtils.java From dcos-commons with Apache License 2.0 | 5 votes |
private static Protos.ExecutorInfo.Builder getExecutorInfoBuilder() { Protos.CommandInfo cmd = Protos.CommandInfo.newBuilder().build(); return Protos.ExecutorInfo.newBuilder() .setExecutorId(Protos.ExecutorID.newBuilder().setValue("")) .setName(TestConstants.EXECUTOR_NAME) .setCommand(cmd); }
Example 13
Source File: MesosController.java From twister2 with Apache License 2.0 | 5 votes |
public Protos.CommandInfo getCommandInfo(String jobID, String workerName) { String command = "java -cp \"twister2-core/lib/*:twister2-job/libexamples-java.jar:" + "/root/.twister2/repository/twister2-core/lib/mesos-1.5.0.jar\" " + workerClass + " " + jobID + " " + workerName; Protos.CommandInfo.Builder cmdInfoBuilder = Protos.CommandInfo.newBuilder(); cmdInfoBuilder.addUris(getJobUri()); //mesos-fetcher uses this to fetch job cmdInfoBuilder.addUris(getCoreUri()); cmdInfoBuilder.setValue(command); return cmdInfoBuilder.build(); }
Example 14
Source File: TaskLaunchScheduledService.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 5 votes |
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(); }
Example 15
Source File: TaskLaunchScheduledService.java From shardingsphere-elasticjob-cloud with Apache License 2.0 | 5 votes |
private Protos.TaskInfo buildCommandExecutorTaskInfo(final TaskContext taskContext, final CloudJobConfiguration jobConfig, final ShardingContexts shardingContexts, final Protos.Offer offer, final Protos.CommandInfo command) { Protos.TaskInfo.Builder result = Protos.TaskInfo.newBuilder().setTaskId(Protos.TaskID.newBuilder().setValue(taskContext.getId()).build()) .setName(taskContext.getTaskName()).setSlaveId(offer.getSlaveId()) .addResources(buildResource("cpus", jobConfig.getCpuCount(), offer.getResourcesList())) .addResources(buildResource("mem", jobConfig.getMemoryMB(), offer.getResourcesList())) .setData(ByteString.copyFrom(new TaskInfoData(shardingContexts, jobConfig).serialize())); return result.setCommand(command).build(); }
Example 16
Source File: ClusterTaskOfferRequirementProviderTest.java From dcos-cassandra-service with Apache License 2.0 | 4 votes |
@Test public void testGetNewOfferRequirement() throws Exception { OfferRequirement requirement = provider.getNewOfferRequirement( CassandraTask.TYPE.CASSANDRA_DAEMON.name(), testTaskInfo); Protos.TaskInfo taskInfo = requirement.getTaskRequirements().iterator().next().getTaskInfo(); Assert.assertEquals(taskInfo.getName(), "test-daemon"); Assert.assertTrue(taskInfo.getTaskId().getValue().contains("test-daemon")); Assert.assertEquals(taskInfo.getSlaveId().getValue(), ""); List<Protos.Resource> resources = taskInfo.getResourcesList(); Assert.assertEquals(4, resources.size()); Protos.Resource cpusResource = resources.get(0); Assert.assertEquals("cpus", cpusResource.getName()); Assert.assertEquals(Protos.Value.Type.SCALAR, cpusResource.getType()); Assert.assertEquals(testCpus, cpusResource.getScalar().getValue(), 0.0); Assert.assertEquals(testRole, cpusResource.getRole()); Assert.assertEquals(testPrincipal, cpusResource.getReservation().getPrincipal()); Assert.assertEquals("resource_id", cpusResource.getReservation().getLabels().getLabelsList().get(0).getKey()); Assert.assertEquals(testResourceId, cpusResource.getReservation().getLabels().getLabelsList().get(0).getValue()); Protos.Resource memResource = resources.get(1); Assert.assertEquals("mem", memResource.getName()); Assert.assertEquals(Protos.Value.Type.SCALAR, memResource.getType()); Assert.assertEquals(testMem, memResource.getScalar().getValue(), 0.0); Assert.assertEquals(testRole, memResource.getRole()); Assert.assertEquals(testPrincipal, memResource.getReservation().getPrincipal()); Assert.assertEquals("resource_id", memResource.getReservation().getLabels().getLabelsList().get(0).getKey()); Assert.assertEquals(testResourceId, memResource.getReservation().getLabels().getLabelsList().get(0).getValue()); Protos.Resource diskResource = resources.get(2); Assert.assertEquals("disk", diskResource.getName()); Assert.assertEquals(Protos.Value.Type.SCALAR, diskResource.getType()); Assert.assertEquals(testDisk, diskResource.getScalar().getValue(), 0.0); Assert.assertEquals(testRole, diskResource.getRole()); Assert.assertEquals(testPrincipal, diskResource.getReservation().getPrincipal()); Assert.assertEquals("resource_id", diskResource.getReservation().getLabels().getLabelsList().get(0).getKey()); Assert.assertEquals(testResourceId, diskResource.getReservation().getLabels().getLabelsList().get(0).getValue()); Protos.Resource portsResource = resources.get(3); Assert.assertEquals("ports", portsResource.getName()); Assert.assertEquals(Protos.Value.Type.RANGES, portsResource.getType()); Assert.assertTrue(portsResource.getRanges().getRangeList().get(0).getBegin() >= testPortBegin); Assert.assertTrue(portsResource.getRanges().getRangeList().get(0).getEnd() >= testPortBegin); Assert.assertEquals(testRole, portsResource.getRole()); Assert.assertEquals(testPrincipal, portsResource.getReservation().getPrincipal()); Assert.assertEquals("resource_id", portsResource.getReservation().getLabels().getLabelsList().get(0).getKey()); Assert.assertEquals(testResourceId, portsResource.getReservation().getLabels().getLabelsList().get(0).getValue()); final Protos.ExecutorInfo executorInfo = requirement.getExecutorRequirementOptional().get().getExecutorInfo(); Protos.CommandInfo cmd = executorInfo.getCommand(); Assert.assertEquals(4, cmd.getUrisList().size()); List<Protos.CommandInfo.URI> urisList = new ArrayList<>(cmd.getUrisList()); urisList.sort((a, b) -> a.getValue().compareTo(b.getValue())); Assert.assertEquals( config.getExecutorConfig().getLibmesosLocation().toString(), urisList.get(0).getValue()); Assert.assertEquals( config.getExecutorConfig().getJreLocation().toString(), urisList.get(1).getValue()); Assert.assertEquals( config.getExecutorConfig().getCassandraLocation().toString(), urisList.get(2).getValue()); Assert.assertEquals( config.getExecutorConfig().getExecutorLocation().toString(), urisList.get(3).getValue()); }
Example 17
Source File: ServiceTaskFactory.java From incubator-myriad with Apache License 2.0 | 4 votes |
@Override public Protos.ExecutorInfo getExecutorInfoForSlave(ResourceOfferContainer resourceOfferContainer, Protos.FrameworkID frameworkId, Protos.CommandInfo commandInfo) { return null; }
Example 18
Source File: TaskFactory.java From incubator-myriad with Apache License 2.0 | votes |
public abstract Protos.ExecutorInfo getExecutorInfoForSlave(ResourceOfferContainer resourceOfferContainer, Protos.FrameworkID frameworkId, Protos.CommandInfo commandInfo);
Example 19
Source File: ExecutorCommandLineGenerator.java From incubator-myriad with Apache License 2.0 | votes |
abstract Protos.CommandInfo generateCommandLine(ServiceResourceProfile profile, ServiceConfiguration serviceConfiguration, Collection<Long> ports);