use of mesos.internal.Messages.LaunchTasksMessage 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 mesos.internal.Messages.LaunchTasksMessage in project jesos by groupon.
the class InternalSchedulerDriver method launchTasks.
@Override
public Status launchTasks(final OfferID offerId, final Collection<TaskInfo> tasks, final Filters filters) {
checkNotNull(offerId, "offerId is null");
checkNotNull(tasks, "tasks is null");
checkNotNull(filters, "filters is null");
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final LaunchTasksMessage message = LaunchTasksMessage.newBuilder().setFrameworkId(context.getFrameworkId()).addOfferIds(offerId).addAllTasks(tasks).setFilters(filters).build();
doLaunchTasks(message);
return context.getStateMachine();
}
use of mesos.internal.Messages.LaunchTasksMessage in project jesos by groupon.
the class InternalSchedulerDriver method declineOffer.
@Override
public Status declineOffer(final OfferID offerId, final Filters filters) {
checkNotNull(offerId, "offerId is null");
checkNotNull(filters, "filters is null");
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final LaunchTasksMessage message = LaunchTasksMessage.newBuilder().setFrameworkId(context.getFrameworkId()).addOfferIds(offerId).setFilters(filters).build();
doLaunchTasks(message);
return context.getStateMachine();
}
use of mesos.internal.Messages.LaunchTasksMessage in project jesos by groupon.
the class InternalSchedulerDriver method launchTasks.
@Override
public Status launchTasks(final Collection<OfferID> offerIds, final Collection<TaskInfo> tasks) {
checkNotNull(offerIds, "offerIds is null");
checkNotNull(tasks, "tasks is null");
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final LaunchTasksMessage message = LaunchTasksMessage.newBuilder().setFrameworkId(context.getFrameworkId()).addAllOfferIds(offerIds).addAllTasks(tasks).setFilters(Filters.newBuilder().build()).build();
doLaunchTasks(message);
return context.getStateMachine();
}
use of mesos.internal.Messages.LaunchTasksMessage in project jesos by groupon.
the class InternalSchedulerDriver method launchTasks.
@Override
public Status launchTasks(final OfferID offerId, final Collection<TaskInfo> tasks) {
checkNotNull(offerId, "offerId is null");
checkNotNull(tasks, "tasks is null");
if (!context.isStateMachine(DRIVER_RUNNING)) {
return context.getStateMachine();
}
final LaunchTasksMessage message = LaunchTasksMessage.newBuilder().setFrameworkId(context.getFrameworkId()).addOfferIds(offerId).addAllTasks(tasks).setFilters(Filters.newBuilder().build()).build();
doLaunchTasks(message);
return context.getStateMachine();
}
Aggregations