本文整理汇总了Java中org.apache.mesos.Protos.TaskInfo方法的典型用法代码示例。如果您正苦于以下问题:Java Protos.TaskInfo方法的具体用法?Java Protos.TaskInfo怎么用?Java Protos.TaskInfo使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos
的用法示例。
在下文中一共展示了Protos.TaskInfo方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTaskInfoList
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private List<Protos.TaskInfo> getTaskInfoList(final Collection<String> integrityViolationJobs, final VMAssignmentResult vmAssignmentResult, final String hostname, final Protos.Offer offer) {
List<Protos.TaskInfo> result = new ArrayList<>(vmAssignmentResult.getTasksAssigned().size());
for (TaskAssignmentResult each: vmAssignmentResult.getTasksAssigned()) {
TaskContext taskContext = TaskContext.from(each.getTaskId());
String jobName = taskContext.getMetaInfo().getJobName();
if (!integrityViolationJobs.contains(jobName) && !facadeService.isRunning(taskContext) && !facadeService.isJobDisabled(jobName)) {
Protos.TaskInfo taskInfo = getTaskInfo(offer, each);
if (null != taskInfo) {
result.add(taskInfo);
facadeService.addMapping(taskInfo.getTaskId().getValue(), hostname);
taskScheduler.getTaskAssigner().call(each.getRequest(), hostname);
}
}
}
return result;
}
示例2: buildCustomizedExecutorTaskInfo
import org.apache.mesos.Protos; //导入方法依赖的package包/类
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();
}
示例3: getTaskConfigs
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private Set<UUID> getTaskConfigs() {
final Collection<Protos.TaskInfo> taskInfos = stateStore.fetchTasks();
final Set<UUID> activeConfigs = new HashSet<>();
try {
for (Protos.TaskInfo taskInfo : taskInfos) {
final Protos.Labels labels = taskInfo.getLabels();
for(Protos.Label label : labels.getLabelsList()) {
if (label.getKey().equals(PersistentOfferRequirementProvider.CONFIG_TARGET_KEY)) {
activeConfigs.add(UUID.fromString(label.getValue()));
}
}
}
} catch (Exception e) {
LOGGER.error("Failed to fetch configurations from taskInfos.", e);
}
return activeConfigs;
}
示例4: launchTask
import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
* Invoked when a task has been launched on this executor (initiated
* via {@link org.apache.mesos.SchedulerDriver#launchTasks}. Note that this task can be
* realized with a thread, a process, or some simple computation,
* however, no other callbacks will be invoked on this executor
* until this callback has returned.
*
* @param driver The executor driver that launched the task.
* @param task Describes the task that was launched.
* @see org.apache.mesos.ExecutorDriver
* @see org.apache.mesos.Protos.TaskInfo
*/
@Override public void launchTask(ExecutorDriver driver, Protos.TaskInfo task) {
LOGGER.info("Launching task in PinUserBoardExecutor...");
Protos.TaskStatus taskStatus = Protos.TaskStatus.newBuilder().setTaskId(task.getTaskId())
.setState(Protos.TaskState.TASK_RUNNING).build();
driver.sendStatusUpdate(taskStatus);
String url = task.getData().toStringUtf8();
byte[] message = new byte[0];
try {
message = computePi().getBytes();
} catch (IOException e) {
LOGGER.error("Error computing Pi :" + e.getMessage());
}
LOGGER.info("Sending framework message and marking task finished." + getClass().getName());
driver.sendFrameworkMessage(message);
taskStatus = Protos.TaskStatus.newBuilder().setTaskId(task.getTaskId()).setState(Protos.TaskState.TASK_FINISHED)
.build();
driver.sendStatusUpdate(taskStatus);
}
示例5: CheckRunner
import org.apache.mesos.Protos; //导入方法依赖的package包/类
private CheckRunner(
ExecutorDriver executorDriver,
Protos.TaskInfo taskInfo,
LaunchedTask launchedTask,
ProcessRunner processRunner,
Protos.HealthCheck healthCheck,
CheckStats healthCheckStats,
String checkType) {
this.executorDriver = executorDriver;
this.taskInfo = taskInfo;
this.launchedTask = launchedTask;
this.processRunner = processRunner;
this.healthCheck = healthCheck;
this.healthCheckStats = healthCheckStats;
this.checkType = checkType;
}
示例6: create
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public static BackupSnapshotTask create(
final Protos.TaskInfo template,
final CassandraDaemonTask daemon,
final BackupRestoreContext context) {
String name = nameForDaemon(daemon);
CassandraData data = CassandraData.createBackupSnapshotData(
"",
context
.forNode(name)
.withLocalLocation(daemon.getVolumePath() + "/data"));
Protos.TaskInfo completedTemplate = Protos.TaskInfo.newBuilder(template)
.setName(name)
.setTaskId(TaskUtils.toTaskId(name))
.setData(data.getBytes())
.build();
completedTemplate = org.apache.mesos.offer.TaskUtils.clearTransient(completedTemplate);
return new BackupSnapshotTask(completedTemplate);
}
示例7: getTaskInfo
import org.apache.mesos.Protos; //导入方法依赖的package包/类
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);
}
}
示例8: buildCommandExecutorTaskInfo
import org.apache.mesos.Protos; //导入方法依赖的package包/类
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();
}
示例9: create
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public Protos.TaskInfo create(String taskId, Protos.Offer offer, List<Protos.Resource> resources, ExecutionParameters executionParameters) {
logger.debug("Creating Mesos task for taskId={}", taskId);
return Protos.TaskInfo.newBuilder()
.setName(applicationName + ".task")
.setSlaveId(offer.getSlaveId())
.setTaskId(Protos.TaskID.newBuilder().setValue(taskId))
.addAllResources(resources)
.setData(ByteString.copyFromUtf8(String.join(";", humioHost, humioDataspace, humioIngesttoken,
humioDataDir, defaultIfEmpty(filebeatConfigUrl, " "), defaultIfEmpty(metricbeatConfigUrl, " "))))
.setLabels(Protos.Labels.newBuilder().addLabels(createLabel("HUMIO_IGNORE", "true")).build())
.setDiscovery(Protos.DiscoveryInfo.newBuilder()
.setName(applicationName)
.setVisibility(Protos.DiscoveryInfo.Visibility.FRAMEWORK)
.build())
.setExecutor(Protos.ExecutorInfo.newBuilder()
.setName("humioexecutor")
.setData(ByteString.copyFromUtf8(dcosAuthToken.concat(";").concat(enableContainerMetrics.toString())))
.setExecutorId(Protos.ExecutorID.newBuilder().setValue("humioexecutor." + offer.getSlaveId()
.getValue()).build())
.setCommand(Protos.CommandInfo.newBuilder()
.setValue("jre*/bin/java -jar executor-*.jar")
.addAllUris(mesosConfig.getUri().stream().map(uri -> Protos.CommandInfo.URI
.newBuilder().setValue(uri).build()).collect(Collectors.toList()))
.build())
.build())
.build();
}
示例10: sendStatusUpdate
import org.apache.mesos.Protos; //导入方法依赖的package包/类
protected void sendStatusUpdate(ExecutorDriver driver, Protos.TaskInfo task, Protos.TaskState state, boolean healthy) {
driver.sendStatusUpdate(Protos.TaskStatus.newBuilder()
.setExecutorId(task.getExecutor().getExecutorId())
.setTaskId(task.getTaskId())
.setHealthy(healthy)
.setState(state)
.build());
}
示例11: decode
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Test
public void decode() {
Protos.TaskInfo task = Protos.TaskInfo.newBuilder()
.setTaskId(Protos.TaskID.newBuilder().setValue("foobar-taskid").build())
.setSlaveId(Protos.SlaveID.newBuilder().setValue("foobar-slaveid").build())
.setName("foobar-taskname")
.addAllResources(ResourceConstructor.construct(3, 256))
.build();
Resource r = ResourceConstructor.decode(task.getResourcesList());
assertThat((int) r.cpu(), is(3));
assertThat(r.memMB(), is(256));
}
示例12: getTaskInfo
import org.apache.mesos.Protos; //导入方法依赖的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();
}
示例13: testAcceptOffers
import org.apache.mesos.Protos; //导入方法依赖的package包/类
/**
* Test offer acceptance.
*/
@Test
public void testAcceptOffers() throws Exception {
new Context() {{
startResourceManager();
// allocate a new worker
MesosWorkerStore.Worker worker1 = allocateWorker(task1, resourceProfile1);
// send an AcceptOffers message as the LaunchCoordinator would
// to launch task1 onto slave1 with offer1
Protos.TaskInfo task1info = Protos.TaskInfo.newBuilder()
.setTaskId(task1).setName("").setSlaveId(slave1).build();
AcceptOffers msg = new AcceptOffers(slave1host, singletonList(offer1), singletonList(launch(task1info)));
resourceManager.acceptOffers(msg);
// verify that the worker was persisted, the internal state was updated,
// Mesos was asked to launch task1, and the task router was notified
MesosWorkerStore.Worker worker1launched = worker1.launchWorker(slave1, slave1host);
verify(rmServices.workerStore).putWorker(worker1launched);
assertThat(resourceManager.workersInNew.entrySet(), empty());
assertThat(resourceManager.workersInLaunch, hasEntry(extractResourceID(task1), worker1launched));
resourceManager.taskRouter.expectMsg(
new TaskMonitor.TaskGoalStateUpdated(extractGoalState(worker1launched)));
verify(rmServices.schedulerDriver).acceptOffers(msg.offerIds(), msg.operations(), msg.filters());
}};
}
示例14: createDownloadSnapshotTask
import org.apache.mesos.Protos; //导入方法依赖的package包/类
public DownloadSnapshotTask createDownloadSnapshotTask(
CassandraDaemonTask daemon,
BackupRestoreContext context) throws PersistenceException {
Optional<Protos.TaskInfo> template = getTemplate(daemon);
if (template.isPresent()) {
return DownloadSnapshotTask.create(template.get(), daemon, context);
} else {
throw new PersistenceException("Failed to retrieve ClusterTask Template.");
}
}
示例15: launchTask
import org.apache.mesos.Protos; //导入方法依赖的package包/类
@Override
public void launchTask(final ExecutorDriver executorDriver, final Protos.TaskInfo taskInfo) {
executorService.submit(new TaskThread(executorDriver, taskInfo));
}