本文整理汇总了Java中org.apache.mesos.Protos.TaskID.getValue方法的典型用法代码示例。如果您正苦于以下问题:Java TaskID.getValue方法的具体用法?Java TaskID.getValue怎么用?Java TaskID.getValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.mesos.Protos.TaskID
的用法示例。
在下文中一共展示了TaskID.getValue方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: register
import org.apache.mesos.Protos.TaskID; //导入方法依赖的package包/类
/**
* Signal to the storm-core supervisor that this task should be started.
*/
public int register(TaskID taskId) throws IllegalArgumentException {
int port = MesosCommon.portFromTaskId(taskId.getValue());
AssignmentInfo existingAssignment = portAssignments.get(port);
if (existingAssignment != null) {
throw new IllegalArgumentException("Refusing to register task " + taskId.getValue() +
" because its port " + port + " is already registered for task " +
existingAssignment.taskId.getValue());
}
portAssignments.put(port, new AssignmentInfo(taskId, TaskState.ACTIVE));
return port;
}
示例2: sendMessageTo
import org.apache.mesos.Protos.TaskID; //导入方法依赖的package包/类
public void sendMessageTo(SchedulerDriver driver, TaskID taskId,
SlaveID slaveID, String message) {
log.info(String.format("Sending message '%s' to taskId=%s, slaveId=%s", message,
taskId.getValue(), slaveID.getValue()));
String postfix = taskId.getValue();
postfix = postfix.substring(postfix.indexOf('.') + 1, postfix.length());
postfix = postfix.substring(postfix.indexOf('.') + 1, postfix.length());
driver.sendFrameworkMessage(
ExecutorID.newBuilder().setValue("executor." + postfix).build(),
slaveID,
message.getBytes(Charset.defaultCharset()));
}
示例3: statusUpdate
import org.apache.mesos.Protos.TaskID; //导入方法依赖的package包/类
@Override
public void statusUpdate(SchedulerDriver sd, Protos.TaskStatus status) {
TaskID taskId = status.getTaskId();
LOGGER.info("Status Update for task: {} | state: {}", taskId,
status.getState());
TaskState state = status.getState();
String taskIdValue = taskId.getValue();
switch (state) {
case TASK_STAGING:
schedulerState.makeTaskStaging(taskIdValue);
break;
case TASK_STARTING:
schedulerState.makeTaskStaging(taskIdValue);
break;
case TASK_RUNNING:
schedulerState.makeTaskActive(taskIdValue);
NodeTask task = schedulerState.getTask(taskIdValue);
schedulerState.releaseLock(task.getClusterId());
break;
case TASK_FINISHED:
schedulerState.removeTask(taskIdValue);
break;
case TASK_FAILED:
// Add to pending tasks
schedulerState.makeTaskPending(taskIdValue);
break;
case TASK_KILLED:
schedulerState.removeTask(taskIdValue);
break;
case TASK_LOST:
schedulerState.makeTaskPending(taskIdValue);
break;
default:
LOGGER.error("Invalid state: {}", state);
break;
}
}
示例4: killTask
import org.apache.mesos.Protos.TaskID; //导入方法依赖的package包/类
/**
* Invoked when a task running within this executor has been killed
* (via SchedulerDriver::killTask). Note that no status update will
* be sent on behalf of the executor, the executor is responsible
* for creating a new TaskStatus (i.e., with TASK_KILLED) and
* invoking ExecutorDriver::sendStatusUpdate.
*/
@Override
public void killTask(ExecutorDriver driver, TaskID taskId) {
String tid = taskId.getValue();
CmdInfo cmdInfo = cmdInfoById.get(tid);
if (cmdInfo == null) return;
cmdInfo.cmd.kill();
}
示例5: createYARNTask
import org.apache.mesos.Protos.TaskID; //导入方法依赖的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;
}