use of org.apache.mesos.Protos.TaskID in project elastic-job by dangdangdotcom.
the class TaskExecutorTest method assertKillTask.
@Test
public void assertKillTask() {
TaskID taskID = Protos.TaskID.newBuilder().setValue("task_id").build();
taskExecutor.killTask(executorDriver, taskID);
verify(executorDriver).sendStatusUpdate(Protos.TaskStatus.newBuilder().setTaskId(taskID).setState(Protos.TaskState.TASK_KILLED).build());
}
use of org.apache.mesos.Protos.TaskID in project incubator-myriad by apache.
the class TaskTerminator method run.
/**
* Encapsulates logic that retrieves the collection of killable tasks from the
* SchedulerState object. If a task is in pending state, the task is simply
* removed from SchedulerState. Any tasks in a running state were not successfully
* killed by Mesos or the callback failed, so the another kill attempt is made.
*/
@Override
public void run() {
// If there are 1..n killable tasks, proceed; otherwise, simply return
if (CollectionUtils.isNotEmpty(schedulerState.getKillableTaskIds())) {
/*
* Clone the killable task collection, iterate through all tasks, and
* process any pending and/or non-pending tasks
*/
Set<TaskID> killableTasks = Sets.newHashSet(schedulerState.getKillableTaskIds());
Status driverStatus = driverManager.getDriverStatus();
// TODO (hokiegeek2) Can the DriverManager be restarted? If not, should the ResourceManager stop?
if (Status.DRIVER_RUNNING != driverStatus) {
LOGGER.warn("Cannot kill tasks because Mesos Driver is not running. Status: {}", driverStatus);
return;
}
for (TaskID taskIdToKill : killableTasks) {
LOGGER.info("Received task kill request for task: {}", taskIdToKill);
if (isPendingTask(taskIdToKill)) {
handlePendingTask(taskIdToKill);
} else {
handleNonPendingTask(taskIdToKill);
}
}
}
}
use of org.apache.mesos.Protos.TaskID in project incubator-myriad by apache.
the class StatusUpdateEventHandler method onEvent.
/**
* Encapsulates the logic to log and respond to the incoming StatusUpdateEvent per the
* Event TaskStatus state:
*
* 1. TASK_STAGING: mark task as staging wtihin SchedulerState
* 2. TASK_STARTING: mark task as staging within SchedulerState
* 3. TASK_RUNNING: mark task as active within SchedulerState
* 4. TASK_FINISHED: decline outstanding offers and remove task from SchedulerState
* 5. TASK_FAILED: decline outstanding offers, remove failed, killable tasks from SchedulerState,
* mark as pending non-killable, failed tasks
* 6. TASK_KILLED: decline outstanding offers, removed killed tasks from SchedulerState
* 7. TASK_LOST: decline outstanding offers, remove killable, lost tasks from SchedulerState,
* mark as pending non-killable, lost tasks
*/
@Override
public void onEvent(StatusUpdateEvent event, long sequence, boolean endOfBatch) throws Exception {
TaskStatus status = event.getStatus();
this.schedulerState.updateTask(status);
TaskID taskId = status.getTaskId();
NodeTask task = schedulerState.getTask(taskId);
if (task == null) {
LOGGER.warn("Task: {} not found, status: {}", taskId.getValue(), status.getState());
schedulerState.removeTask(taskId);
return;
}
LOGGER.info("Status Update for task: {} | state: {}", taskId.getValue(), status.getState());
TaskState state = status.getState();
switch(state) {
case TASK_STAGING:
schedulerState.makeTaskStaging(taskId);
break;
case TASK_STARTING:
schedulerState.makeTaskStaging(taskId);
break;
case TASK_RUNNING:
schedulerState.makeTaskActive(taskId);
break;
case TASK_FINISHED:
cleanupTask(taskId, task, "finished");
break;
case TASK_FAILED:
cleanupFailedTask(taskId, task, "failed");
break;
case TASK_KILLED:
cleanupTask(taskId, task, "killed");
break;
case TASK_LOST:
cleanupFailedTask(taskId, task, "lost");
break;
default:
LOGGER.error("Invalid state: {}", state);
break;
}
}
use of org.apache.mesos.Protos.TaskID in project incubator-myriad by apache.
the class SchedulerStateTest method testRemoveTask.
@Test
public void testRemoveTask() throws Exception {
SchedulerState sState = initialize();
TaskID idOne = TaskID.newBuilder().setValue("Task1").build();
TaskID idTwo = TaskID.newBuilder().setValue("Task2").build();
sState.removeTask(idOne);
assertNull(sState.getTask(idOne));
sState.removeTask(idTwo);
assertNull(sState.getTask(idTwo));
}
use of org.apache.mesos.Protos.TaskID in project incubator-myriad by apache.
the class SchedulerStateTest method testMakeTestActive.
@Test
public void testMakeTestActive() throws Exception {
SchedulerState sState = initialize();
TaskID idOne = TaskID.newBuilder().setValue("Task1").build();
TaskID idTwo = TaskID.newBuilder().setValue("Task2").build();
sState.addTask(idOne, taskOne);
sState.addTask(idTwo, taskTwo);
sState.makeTaskActive(idOne);
sState.makeTaskActive(idTwo);
assertTrue(sState.getActiveTasks().contains(taskOne));
assertTrue(sState.getActiveTasks().contains(taskTwo));
}
Aggregations