Search in sources :

Example 1 with StatusUpdateAcknowledgementMessage

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

the class InternalSchedulerDriver method acknowledgeStatusUpdate.

@Override
public Status acknowledgeStatusUpdate(final TaskStatus taskStatus) {
    checkNotNull(taskStatus, "taskStatus is null");
    checkState(!implicitAcknowledges, "Can not call acknowledgeStatusUpdate with implicitAcknowledges turned off");
    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }
    final StatusUpdateAcknowledgementMessage message = StatusUpdateAcknowledgementMessage.newBuilder().setFrameworkId(context.getFrameworkId()).setSlaveId(taskStatus.getSlaveId()).setTaskId(taskStatus.getTaskId()).setUuid(taskStatus.getUuid()).build();
    eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
    return context.getStateMachine();
}
Also used : RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) StatusUpdateAcknowledgementMessage(mesos.internal.Messages.StatusUpdateAcknowledgementMessage)

Example 2 with StatusUpdateAcknowledgementMessage

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

the class LocalExecutorMessageProcessor method statusUpdateAcknowledgement.

@Subscribe
public void statusUpdateAcknowledgement(final StatusUpdateAcknowledgementMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    if (context.isStateMachine(DRIVER_ABORTED)) {
        LOG.warn("driver is aborted!");
        return;
    }
    final StatusUpdateAcknowledgementMessage message = envelope.getMessage();
    context.removeUpdate(UUIDUtil.bytesUuid(message.getUuid()));
    tasks.remove(message.getTaskId());
}
Also used : StatusUpdateAcknowledgementMessage(mesos.internal.Messages.StatusUpdateAcknowledgementMessage) Subscribe(com.google.common.eventbus.Subscribe)

Example 3 with StatusUpdateAcknowledgementMessage

use of mesos.internal.Messages.StatusUpdateAcknowledgementMessage 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)

Aggregations

StatusUpdateAcknowledgementMessage (mesos.internal.Messages.StatusUpdateAcknowledgementMessage)3 Subscribe (com.google.common.eventbus.Subscribe)2 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)2 UPID (com.groupon.mesos.util.UPID)1 StatusUpdateMessage (mesos.internal.Messages.StatusUpdateMessage)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