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