use of com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope in project jesos by groupon.
the class InternalSchedulerDriver method sendFrameworkMessage.
@Override
public Status sendFrameworkMessage(final ExecutorID executorId, final SlaveID slaveId, final byte[] data) {
checkNotNull(executorId, "executorId is null");
checkNotNull(slaveId, "slaveId is null");
checkNotNull(data, "data is null");
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final FrameworkToExecutorMessage message = FrameworkToExecutorMessage.newBuilder().setFrameworkId(context.getFrameworkId()).setExecutorId(executorId).setSlaveId(slaveId).setData(ByteString.copyFrom(data)).build();
// directly to the slave, otherwise to the master and let the master sort it out.
if (context.containsSlave(message.getSlaveId())) {
final UPID slave = context.getSlaveUPID(message.getSlaveId());
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), slave, message));
} else {
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
}
return context.getStateMachine();
}
use of com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope in project jesos by groupon.
the class InternalSchedulerDriver method reconcileTasks.
@Override
public Status reconcileTasks(final Collection<TaskStatus> statuses) {
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final ReconcileTasksMessage message = ReconcileTasksMessage.newBuilder().setFrameworkId(context.getFrameworkId()).addAllStatuses(statuses).build();
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
return context.getStateMachine();
}
use of com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope 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 com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope in project jesos by groupon.
the class InternalSchedulerDriver method abort.
@Override
public Status abort() {
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
if (context.isConnected()) {
final DeactivateFrameworkMessage message = DeactivateFrameworkMessage.newBuilder().setFrameworkId(context.getFrameworkId()).build();
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
}
context.setStateMachine(DRIVER_ABORTED);
return context.getStateMachine();
}
use of com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope in project jesos by groupon.
the class InternalSchedulerDriver method killTask.
@Override
public Status killTask(final TaskID taskId) {
checkNotNull(taskId, "taskId is null");
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final KillTaskMessage message = KillTaskMessage.newBuilder().setFrameworkId(context.getFrameworkId()).setTaskId(taskId).build();
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
return context.getStateMachine();
}
Aggregations