Search in sources :

Example 6 with ExecutorDriver

use of org.apache.mesos.ExecutorDriver in project jesos by groupon.

the class InternalExecutorDriver method start.

//
// ========================================================================
//
// Mesos ExecutorDriver API
//
// ========================================================================
//
@Override
public Status start() {
    if (!context.isStateMachine(DRIVER_NOT_STARTED)) {
        return context.getStateMachine();
    }
    try {
        driverStart();
        //
        // Register with Mesos Slave
        //
        final RegisterExecutorMessage message = RegisterExecutorMessage.newBuilder().setFrameworkId(context.getFrameworkId()).setExecutorId(context.getExecutorId()).build();
        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getSlaveUPID(), message));
        context.setStateMachine(DRIVER_RUNNING);
    } catch (final Exception e) {
        context.setStateMachine(DRIVER_ABORTED);
        LOG.error(e, "Failed to create executor process for '%s'", context.getSlaveUPID());
        eventBus.post(new ExecutorCallback() {

            @Override
            public Runnable getCallback(final Executor executor, final ExecutorDriver executorDriver) {
                return new Runnable() {

                    @Override
                    public void run() {
                        final String message = format("Failed to create scheduler process for '%s': %s", context.getSlaveUPID(), e.getMessage());
                        LOG.debug("calling error(driver, %s)", message);
                        executor.error(executorDriver, message);
                    }
                };
            }
        });
    }
    return context.getStateMachine();
}
Also used : RegisterExecutorMessage(mesos.internal.Messages.RegisterExecutorMessage) RemoteMessageEnvelope(com.groupon.mesos.executor.ExecutorMessageEnvelope.RemoteMessageEnvelope) Executor(org.apache.mesos.Executor) ByteString(com.google.protobuf.ByteString) ExecutorDriver(org.apache.mesos.ExecutorDriver) IOException(java.io.IOException) ExecutionException(java.util.concurrent.ExecutionException)

Example 7 with ExecutorDriver

use of org.apache.mesos.ExecutorDriver in project jesos by groupon.

the class LocalExecutorMessageProcessor method runTask.

@Subscribe
public void runTask(final RunTaskMessageEnvelope envelope) {
    checkState(envelope.getRecipient().equals(context.getDriverUPID()), "Received a remote message for local delivery");
    if (context.isStateMachine(DRIVER_ABORTED)) {
        LOG.warn("driver is aborted!");
        return;
    }
    final RunTaskMessage message = envelope.getMessage();
    final TaskInfo task = message.getTask();
    checkState(!tasks.containsKey(task.getTaskId()), "Task %s already started!", task.getTaskId().getValue());
    tasks.put(task.getTaskId(), task);
    eventBus.post(new ExecutorCallback() {

        @Override
        public Runnable getCallback(final Executor executor, final ExecutorDriver executorDriver) {
            return new Runnable() {

                @Override
                public void run() {
                    executor.launchTask(executorDriver, task);
                }

                @Override
                public String toString() {
                    return "callback for launchTask()";
                }
            };
        }
    });
}
Also used : TaskInfo(org.apache.mesos.Protos.TaskInfo) Executor(org.apache.mesos.Executor) RunTaskMessage(mesos.internal.Messages.RunTaskMessage) ExecutorDriver(org.apache.mesos.ExecutorDriver) Subscribe(com.google.common.eventbus.Subscribe)

Aggregations

Executor (org.apache.mesos.Executor)7 ExecutorDriver (org.apache.mesos.ExecutorDriver)7 Subscribe (com.google.common.eventbus.Subscribe)5 ByteString (com.google.protobuf.ByteString)2 RemoteMessageEnvelope (com.groupon.mesos.executor.ExecutorMessageEnvelope.RemoteMessageEnvelope)2 IOException (java.io.IOException)1 UUID (java.util.UUID)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorRegisteredMessage (mesos.internal.Messages.ExecutorRegisteredMessage)1 ExecutorReregisteredMessage (mesos.internal.Messages.ExecutorReregisteredMessage)1 FrameworkToExecutorMessage (mesos.internal.Messages.FrameworkToExecutorMessage)1 KillTaskMessage (mesos.internal.Messages.KillTaskMessage)1 RegisterExecutorMessage (mesos.internal.Messages.RegisterExecutorMessage)1 RunTaskMessage (mesos.internal.Messages.RunTaskMessage)1 StatusUpdateMessage (mesos.internal.Messages.StatusUpdateMessage)1 TaskInfo (org.apache.mesos.Protos.TaskInfo)1