Search in sources :

Example 1 with RemoteMessageEnvelope

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();
}
Also used : RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) StatusUpdateAcknowledgementMessage(mesos.internal.Messages.StatusUpdateAcknowledgementMessage)

Example 2 with RemoteMessageEnvelope

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));
}
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 3 with RemoteMessageEnvelope

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();
}
Also used : ReviveOffersMessage(mesos.internal.Messages.ReviveOffersMessage) RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)

Example 4 with RemoteMessageEnvelope

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;
}
Also used : Status(org.apache.mesos.Protos.Status) TaskStatus(org.apache.mesos.Protos.TaskStatus) UnregisterFrameworkMessage(mesos.internal.Messages.UnregisterFrameworkMessage) RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) IOException(java.io.IOException)

Example 5 with RemoteMessageEnvelope

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();
}
Also used : RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) ResourceRequestMessage(mesos.internal.Messages.ResourceRequestMessage)

Aggregations

RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)10 UPID (com.groupon.mesos.util.UPID)2 StatusUpdateAcknowledgementMessage (mesos.internal.Messages.StatusUpdateAcknowledgementMessage)2 FrameworkID (org.apache.mesos.Protos.FrameworkID)2 TaskStatus (org.apache.mesos.Protos.TaskStatus)2 ImmutableList (com.google.common.collect.ImmutableList)1 Subscribe (com.google.common.eventbus.Subscribe)1 IOException (java.io.IOException)1 DeactivateFrameworkMessage (mesos.internal.Messages.DeactivateFrameworkMessage)1 FrameworkToExecutorMessage (mesos.internal.Messages.FrameworkToExecutorMessage)1 KillTaskMessage (mesos.internal.Messages.KillTaskMessage)1 LaunchTasksMessage (mesos.internal.Messages.LaunchTasksMessage)1 ReconcileTasksMessage (mesos.internal.Messages.ReconcileTasksMessage)1 ResourceRequestMessage (mesos.internal.Messages.ResourceRequestMessage)1 ReviveOffersMessage (mesos.internal.Messages.ReviveOffersMessage)1 StatusUpdateMessage (mesos.internal.Messages.StatusUpdateMessage)1 UnregisterFrameworkMessage (mesos.internal.Messages.UnregisterFrameworkMessage)1 MasterInfo (org.apache.mesos.Protos.MasterInfo)1 OfferID (org.apache.mesos.Protos.OfferID)1 Status (org.apache.mesos.Protos.Status)1