Search in sources :

Example 1 with LaunchTasksMessage

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));
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) OfferID(org.apache.mesos.Protos.OfferID) MasterInfo(org.apache.mesos.Protos.MasterInfo) RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) ImmutableList(com.google.common.collect.ImmutableList) FrameworkID(org.apache.mesos.Protos.FrameworkID) LaunchTasksMessage(mesos.internal.Messages.LaunchTasksMessage)

Example 2 with LaunchTasksMessage

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();
}
Also used : LaunchTasksMessage(mesos.internal.Messages.LaunchTasksMessage)

Example 3 with LaunchTasksMessage

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();
}
Also used : LaunchTasksMessage(mesos.internal.Messages.LaunchTasksMessage)

Example 4 with LaunchTasksMessage

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();
}
Also used : LaunchTasksMessage(mesos.internal.Messages.LaunchTasksMessage)

Example 5 with LaunchTasksMessage

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();
}
Also used : LaunchTasksMessage(mesos.internal.Messages.LaunchTasksMessage)

Aggregations

LaunchTasksMessage (mesos.internal.Messages.LaunchTasksMessage)7 ImmutableList (com.google.common.collect.ImmutableList)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 FrameworkID (org.apache.mesos.Protos.FrameworkID)1 MasterInfo (org.apache.mesos.Protos.MasterInfo)1 OfferID (org.apache.mesos.Protos.OfferID)1 TaskInfo (org.apache.mesos.Protos.TaskInfo)1