Java Code Examples for org.apache.mesos.Protos.TaskID#getValue()
The following examples show how to use
org.apache.mesos.Protos.TaskID#getValue() .
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: MyriadScheduler.java From myriad with Apache License 2.0 | 5 votes |
@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; } }
Example 2
Source File: BdsMesosExecutor.java From BigDataScript with Apache License 2.0 | 5 votes |
/** * 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(); }
Example 3
Source File: TaskUtils.java From myriad with Apache License 2.0 | 4 votes |
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; }