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();
}
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());
}
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));
}
}
Aggregations