Search in sources :

Example 1 with StatusUpdateMessage

use of mesos.internal.Messages.StatusUpdateMessage in project jesos by groupon.

the class InternalExecutorDriver method sendStatusUpdate.

@Override
public Status sendStatusUpdate(final TaskStatus taskStatus) {
    checkNotNull(taskStatus, "status is null");
    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }
    if (taskStatus.getState() == TASK_STAGING) {
        LOG.error("Executor is not allowed to send TASK_STAGING status update. Aborting!");
        eventBus.post(new ExecutorCallback() {

            @Override
            public Runnable getCallback(final Executor executor, final ExecutorDriver executorDriver) {
                return new Runnable() {

                    @Override
                    public void run() {
                        executorDriver.abort();
                        final String message = "Executor is not allowed to send TASK_STAGING status update. Aborting!";
                        LOG.debug("calling error(driver, %s)", message);
                        executor.error(executorDriver, message);
                    }
                };
            }
        });
        return context.getStateMachine();
    }
    final UUID uuid = UUID.randomUUID();
    final long now = TimeUtil.currentTime();
    final StatusUpdateMessage message = StatusUpdateMessage.newBuilder().setPid(context.getDriverUPID().asString()).setUpdate(StatusUpdate.newBuilder().setFrameworkId(context.getFrameworkId()).setExecutorId(context.getExecutorId()).setSlaveId(context.getSlaveId()).setStatus(TaskStatus.newBuilder(taskStatus).setTimestamp(now)).setTimestamp(now).setUuid(UUIDUtil.uuidBytes(UUID.randomUUID()))).build();
    context.addUpdate(uuid, message.getUpdate());
    eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getSlaveUPID(), message));
    return context.getStateMachine();
}
Also used : RemoteMessageEnvelope(com.groupon.mesos.executor.ExecutorMessageEnvelope.RemoteMessageEnvelope) Executor(org.apache.mesos.Executor) StatusUpdateMessage(mesos.internal.Messages.StatusUpdateMessage) ByteString(com.google.protobuf.ByteString) ExecutorDriver(org.apache.mesos.ExecutorDriver) UUID(java.util.UUID)

Example 2 with StatusUpdateMessage

use of mesos.internal.Messages.StatusUpdateMessage in project jesos by groupon.

the class LocalSchedulerMessageProcessor method frameworkStatusUpdate.

@Subscribe
public void frameworkStatusUpdate(final StatusUpdateMessageEnvelope envelope) throws IOException {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    final UPID sender = envelope.getSender();
    if (!driverIsConnected(sender)) {
        return;
    }
    final StatusUpdateMessage statusUpdateMessage = envelope.getMessage();
    final FrameworkID frameworkId = context.getFrameworkId();
    final FrameworkID messageFrameworkId = statusUpdateMessage.getUpdate().getFrameworkId();
    checkState(frameworkId.equals(messageFrameworkId), "Received Message for framework %s, but local id is %s", messageFrameworkId, frameworkId);
    final TaskStatus.Builder taskStatusBuilder = TaskStatus.newBuilder(statusUpdateMessage.getUpdate().getStatus());
    final TaskStatus taskStatus;
    // If the update is driver-generated or master-generated, it does not require acknowledgement (from Mesos source code, sched.cpp).
    final Optional<UPID> pid = statusUpdateMessage.hasPid() ? Optional.of(UPID.create(statusUpdateMessage.getPid())) : Optional.<UPID>absent();
    final boolean noAckRequired = envelope.getSender().equals(context.getDriverUPID()) || pid.isPresent() && pid.get().equals(context.getDriverUPID());
    if (noAckRequired) {
        taskStatus = taskStatusBuilder.clearUuid().build();
    } else {
        taskStatus = taskStatusBuilder.setUuid(statusUpdateMessage.getUpdate().getUuid()).build();
    }
    eventBus.post(new SchedulerCallback() {

        @Override
        public Runnable getCallback(final Scheduler scheduler, final SchedulerDriver schedulerDriver) {
            return new Runnable() {

                @Override
                public void run() {
                    scheduler.statusUpdate(schedulerDriver, taskStatus);
                }
            };
        }
    });
    if (implicitAcknowledgements && !noAckRequired) {
        final StatusUpdateAcknowledgementMessage statusUpdateAcknowledgementMessage = StatusUpdateAcknowledgementMessage.newBuilder().setFrameworkId(frameworkId).setSlaveId(statusUpdateMessage.getUpdate().getSlaveId()).setTaskId(taskStatus.getTaskId()).setUuid(statusUpdateMessage.getUpdate().getUuid()).build();
        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), statusUpdateAcknowledgementMessage));
    }
}
Also used : Scheduler(org.apache.mesos.Scheduler) TaskStatus(org.apache.mesos.Protos.TaskStatus) UPID(com.groupon.mesos.util.UPID) RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) StatusUpdateAcknowledgementMessage(mesos.internal.Messages.StatusUpdateAcknowledgementMessage) StatusUpdateMessage(mesos.internal.Messages.StatusUpdateMessage) FrameworkID(org.apache.mesos.Protos.FrameworkID) SchedulerDriver(org.apache.mesos.SchedulerDriver) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with StatusUpdateMessage

use of mesos.internal.Messages.StatusUpdateMessage in project jesos by groupon.

the class InternalSchedulerDriver method loseTask.

private void loseTask(final TaskInfo taskInfo, final String reason) {
    final StatusUpdateMessage statusUpdate = StatusUpdateMessage.newBuilder().setUpdate(StatusUpdate.newBuilder().setFrameworkId(context.getFrameworkId()).setSlaveId(taskInfo.getSlaveId()).setExecutorId(taskInfo.getExecutor().getExecutorId()).setStatus(TaskStatus.newBuilder().setTaskId(taskInfo.getTaskId()).setState(TaskState.TASK_LOST).setMessage(reason)).setTimestamp(TimeUtil.currentTime()).setUuid(UUIDUtil.uuidBytes(UUID.randomUUID()))).build();
    eventBus.post(new StatusUpdateMessageEnvelope(context.getDriverUPID(), context.getDriverUPID(), statusUpdate));
}
Also used : StatusUpdateMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.StatusUpdateMessageEnvelope) StatusUpdateMessage(mesos.internal.Messages.StatusUpdateMessage)

Aggregations

StatusUpdateMessage (mesos.internal.Messages.StatusUpdateMessage)3 Subscribe (com.google.common.eventbus.Subscribe)1 ByteString (com.google.protobuf.ByteString)1 RemoteMessageEnvelope (com.groupon.mesos.executor.ExecutorMessageEnvelope.RemoteMessageEnvelope)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 StatusUpdateMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.StatusUpdateMessageEnvelope)1 UPID (com.groupon.mesos.util.UPID)1 UUID (java.util.UUID)1 StatusUpdateAcknowledgementMessage (mesos.internal.Messages.StatusUpdateAcknowledgementMessage)1 Executor (org.apache.mesos.Executor)1 ExecutorDriver (org.apache.mesos.ExecutorDriver)1 FrameworkID (org.apache.mesos.Protos.FrameworkID)1 TaskStatus (org.apache.mesos.Protos.TaskStatus)1 Scheduler (org.apache.mesos.Scheduler)1 SchedulerDriver (org.apache.mesos.SchedulerDriver)1