use of com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope 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 com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope in project jesos by groupon.
the class InternalSchedulerDriver method doLaunchTasks.
//
// Launch Tasks processing
//
private void doLaunchTasks(final LaunchTasksMessage message) {
final MasterInfo masterInfo = context.connectedMaster();
if (masterInfo == null) {
loseAllTasks(message.getTasksList(), "Master disconnected");
return;
}
final ImmutableList.Builder<TaskInfo> builder = ImmutableList.builder();
for (TaskInfo taskInfo : message.getTasksList()) {
if (taskInfo.hasExecutor() == taskInfo.hasCommand()) {
loseTask(taskInfo, "TaskInfo must have either an 'executor' or a 'command'");
// for(...
continue;
}
if (taskInfo.hasExecutor()) {
if (taskInfo.getExecutor().hasFrameworkId()) {
final FrameworkID executorFrameworkId = taskInfo.getExecutor().getFrameworkId();
if (!executorFrameworkId.equals(context.getFrameworkId())) {
loseTask(taskInfo, format("ExecutorInfo has an invalid FrameworkID (Actual: %s vs Expected: %s)", executorFrameworkId.getValue(), context.getFrameworkId().getValue()));
// for(...
continue;
}
} else {
// Executor present but not framework id. Set the framework id.
taskInfo = TaskInfo.newBuilder(taskInfo).setExecutor(ExecutorInfo.newBuilder(taskInfo.getExecutor()).setFrameworkId(context.getFrameworkId())).build();
}
}
builder.add(taskInfo);
}
final List<TaskInfo> launchTasks = builder.build();
for (final OfferID offer : message.getOfferIdsList()) {
if (!context.hasOffers(offer)) {
LOG.warn("Unknown offer %s ignored!", offer.getValue());
}
for (final TaskInfo launchTask : launchTasks) {
if (context.hasOffer(offer, launchTask.getSlaveId())) {
context.addSlave(launchTask.getSlaveId(), context.getOffer(offer, launchTask.getSlaveId()));
}
}
context.removeAllOffers(offer);
}
final LaunchTasksMessage launchMessage = LaunchTasksMessage.newBuilder(message).setFrameworkId(context.getFrameworkId()).clearTasks().addAllTasks(launchTasks).build();
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), launchMessage));
}
use of com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope in project jesos by groupon.
the class InternalSchedulerDriver method reviveOffers.
@Override
public Status reviveOffers() {
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final ReviveOffersMessage message = ReviveOffersMessage.newBuilder().setFrameworkId(context.getFrameworkId()).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 InternalSchedulerDriver method stop.
@Override
public Status stop(final boolean failover) {
Status status = context.getStateMachine();
if (!context.isStateMachine(DRIVER_RUNNING, DRIVER_ABORTED)) {
return status;
}
if (context.isConnected() && !failover) {
final UnregisterFrameworkMessage message = UnregisterFrameworkMessage.newBuilder().setFrameworkId(context.getFrameworkId()).build();
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
}
try {
closer.close();
} catch (final IOException e) {
LOG.warn(e, "While stopping");
}
context.setStateMachine(DRIVER_STOPPED);
// state on the return.
if (status != DRIVER_ABORTED) {
status = DRIVER_STOPPED;
}
return status;
}
use of com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope in project jesos by groupon.
the class InternalSchedulerDriver method requestResources.
@Override
public Status requestResources(final Collection<Protos.Request> requests) {
checkNotNull(requests, "requests is null");
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final ResourceRequestMessage message = ResourceRequestMessage.newBuilder().setFrameworkId(context.getFrameworkId()).addAllRequests(requests).build();
eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
return context.getStateMachine();
}
Aggregations