Search in sources :

Example 1 with TaskStatus

use of org.apache.mesos.Protos.TaskStatus in project storm-mesos by nathanmarz.

the class MesosSupervisor method killedWorker.

@Override
public void killedWorker(int port) {
    try {
        _state.remove(port);
    } catch (IOException e) {
        throw new RuntimeException(e);
    }
    TaskStatus status = TaskStatus.newBuilder().setState(TaskState.TASK_FINISHED).setTaskId(TaskID.newBuilder().setValue(MesosCommon.taskId(_assignmentId, port))).build();
    _driver.sendStatusUpdate(status);
}
Also used : IOException(java.io.IOException) TaskStatus(org.apache.mesos.Protos.TaskStatus)

Example 2 with TaskStatus

use of org.apache.mesos.Protos.TaskStatus in project incubator-myriad by apache.

the class MyriadExecutorAuxService method sendStatus.

private void sendStatus(ContainerId containerId, TaskState taskState) {
    Protos.TaskID taskId = Protos.TaskID.newBuilder().setValue(YARN_CONTAINER_TASK_ID_PREFIX + containerId.toString()).build();
    TaskStatus status = TaskStatus.newBuilder().setTaskId(taskId).setState(taskState).build();
    driver.sendStatusUpdate(status);
    LOGGER.debug("Sent status " + taskState + " for taskId " + taskId);
}
Also used : Protos(org.apache.mesos.Protos) TaskStatus(org.apache.mesos.Protos.TaskStatus)

Example 3 with TaskStatus

use of org.apache.mesos.Protos.TaskStatus in project incubator-myriad by apache.

the class MyriadExecutor method killTask.

@Override
public void killTask(ExecutorDriver driver, TaskID taskId) {
    String taskIdString = taskId.toString();
    LOGGER.debug("killTask received for taskId: " + taskIdString);
    TaskStatus status;
    if (!taskIdString.contains(MyriadExecutorAuxService.YARN_CONTAINER_TASK_ID_PREFIX)) {
        // currently running
        synchronized (containerIds) {
            for (String containerId : containerIds) {
                Protos.TaskID containerTaskId = Protos.TaskID.newBuilder().setValue(MyriadExecutorAuxService.YARN_CONTAINER_TASK_ID_PREFIX + containerId).build();
                status = TaskStatus.newBuilder().setTaskId(containerTaskId).setState(TaskState.TASK_KILLED).build();
                driver.sendStatusUpdate(status);
            }
        }
        // Now kill the node manager task
        status = TaskStatus.newBuilder().setTaskId(taskId).setState(TaskState.TASK_KILLED).build();
        driver.sendStatusUpdate(status);
        LOGGER.info("NodeManager shutdown after receiving KILL_TASK for taskId {}", taskIdString);
        Runtime.getRuntime().exit(0);
    } else {
        status = TaskStatus.newBuilder().setTaskId(taskId).setState(TaskState.TASK_KILLED).build();
        driver.sendStatusUpdate(status);
        synchronized (containerIds) {
            // Likely the container isn't in here, but just in case remove it.
            if (containerIds.remove(taskIdString.substring(MyriadExecutorAuxService.YARN_CONTAINER_FULL_PREFIX.length(), taskIdString.length()))) {
                LOGGER.debug("Removed taskId {} from containerIds", taskIdString);
            }
        }
        LOGGER.debug("Killing " + taskId);
    }
}
Also used : Protos(org.apache.mesos.Protos) TaskID(org.apache.mesos.Protos.TaskID) TaskStatus(org.apache.mesos.Protos.TaskStatus)

Example 4 with TaskStatus

use of org.apache.mesos.Protos.TaskStatus in project incubator-myriad by apache.

the class MyriadExecutor method launchTask.

@Override
public void launchTask(final ExecutorDriver driver, final TaskInfo task) {
    LOGGER.debug("launchTask received for taskId: " + task.getTaskId());
    TaskStatus status = TaskStatus.newBuilder().setTaskId(task.getTaskId()).setState(TaskState.TASK_RUNNING).build();
    driver.sendStatusUpdate(status);
}
Also used : TaskStatus(org.apache.mesos.Protos.TaskStatus)

Example 5 with TaskStatus

use of org.apache.mesos.Protos.TaskStatus in project dcos-commons by mesosphere.

the class TaskStatusUtils method sendStatus.

/**
 * Sends a {@link TaskStatus} to the provided {@code driver} which contains the provided information.
 */
public static void sendStatus(ExecutorDriver driver, TaskState state, TaskID taskID, SlaveID slaveID, ExecutorID executorID, String message, boolean isHealthy, Labels labels, byte[] data) {
    final TaskStatus.Builder builder = TaskStatus.newBuilder().setState(state).setMessage(message).setTaskId(taskID).setSlaveId(slaveID).setExecutorId(executorID).setSource(TaskStatus.Source.SOURCE_EXECUTOR).setHealthy(isHealthy);
    if (data != null) {
        builder.setData(ByteString.copyFrom(data));
    }
    if (labels != null) {
        builder.setLabels(labels);
    }
    try {
        final TaskStatus taskStatus = builder.build();
        LOGGER.info("Sending task status update: {}", TextFormat.shortDebugString(taskStatus));
        driver.sendStatusUpdate(taskStatus);
    } catch (Throwable t) {
        LOGGER.error("Failed to build task status.", t);
    }
}
Also used : TaskStatus(org.apache.mesos.Protos.TaskStatus)

Aggregations

TaskStatus (org.apache.mesos.Protos.TaskStatus)10 Protos (org.apache.mesos.Protos)3 TaskID (org.apache.mesos.Protos.TaskID)2 SchedulerDriver (org.apache.mesos.SchedulerDriver)2 Subscribe (com.google.common.eventbus.Subscribe)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 UPID (com.groupon.mesos.util.UPID)1 StateStore (com.mesosphere.sdk.state.StateStore)1 IOException (java.io.IOException)1 StatusUpdateAcknowledgementMessage (mesos.internal.Messages.StatusUpdateAcknowledgementMessage)1 StatusUpdateMessage (mesos.internal.Messages.StatusUpdateMessage)1 FrameworkID (org.apache.mesos.Protos.FrameworkID)1 TaskState (org.apache.mesos.Protos.TaskState)1 Scheduler (org.apache.mesos.Scheduler)1 NodeTask (org.apache.myriad.state.NodeTask)1 ArgumentCaptor (org.mockito.ArgumentCaptor)1