Search in sources :

Example 1 with Executor

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

the class InternalExecutorDriver method sendStatusUpdate.

@Override
public Status sendStatusUpdate(final TaskStatus taskStatus) {
    checkNotNull(taskStatus, "status is null");
    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }
    if (taskStatus.getState() == TASK_STAGING) {
        LOG.error("Executor is not allowed to send TASK_STAGING status update. Aborting!");
        eventBus.post(new ExecutorCallback() {

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

                    @Override
                    public void run() {
                        executorDriver.abort();
                        final String message = "Executor is not allowed to send TASK_STAGING status update. Aborting!";
                        LOG.debug("calling error(driver, %s)", message);
                        executor.error(executorDriver, message);
                    }
                };
            }
        });
        return context.getStateMachine();
    }
    final UUID uuid = UUID.randomUUID();
    final long now = TimeUtil.currentTime();
    final StatusUpdateMessage message = StatusUpdateMessage.newBuilder().setPid(context.getDriverUPID().asString()).setUpdate(StatusUpdate.newBuilder().setFrameworkId(context.getFrameworkId()).setExecutorId(context.getExecutorId()).setSlaveId(context.getSlaveId()).setStatus(TaskStatus.newBuilder(taskStatus).setTimestamp(now)).setTimestamp(now).setUuid(UUIDUtil.uuidBytes(UUID.randomUUID()))).build();
    context.addUpdate(uuid, message.getUpdate());
    eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getSlaveUPID(), message));
    return context.getStateMachine();
}
Also used : RemoteMessageEnvelope(com.groupon.mesos.executor.ExecutorMessageEnvelope.RemoteMessageEnvelope) Executor(org.apache.mesos.Executor) StatusUpdateMessage(mesos.internal.Messages.StatusUpdateMessage) ByteString(com.google.protobuf.ByteString) ExecutorDriver(org.apache.mesos.ExecutorDriver) UUID(java.util.UUID)

Example 2 with Executor

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

the class LocalExecutorMessageProcessor method killTask.

@Subscribe
public void killTask(final KillTaskMessageEnvelope 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 KillTaskMessage message = envelope.getMessage();
    eventBus.post(new ExecutorCallback() {

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

                @Override
                public void run() {
                    executor.killTask(executorDriver, message.getTaskId());
                }

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

Example 3 with Executor

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

the class LocalExecutorMessageProcessor method executorRegistered.

@Subscribe
public void executorRegistered(final ExecutorRegisteredMessageEnvelope 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 ExecutorRegisteredMessage message = envelope.getMessage();
    eventBus.post(new ExecutorCallback() {

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

                @Override
                public void run() {
                    executor.registered(executorDriver, message.getExecutorInfo(), message.getFrameworkInfo(), message.getSlaveInfo());
                }

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

Example 4 with Executor

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

the class LocalExecutorMessageProcessor method executorReregistered.

@Subscribe
public void executorReregistered(final ExecutorReregisteredMessageEnvelope 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 ExecutorReregisteredMessage message = envelope.getMessage();
    eventBus.post(new ExecutorCallback() {

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

                @Override
                public void run() {
                    executor.reregistered(executorDriver, message.getSlaveInfo());
                }

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

Example 5 with Executor

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

the class LocalExecutorMessageProcessor method frameworkToExecutor.

@Subscribe
public void frameworkToExecutor(final FrameworkToExecutorMessageEnvelope 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 FrameworkToExecutorMessage message = envelope.getMessage();
    eventBus.post(new ExecutorCallback() {

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

                @Override
                public void run() {
                    executor.frameworkMessage(executorDriver, message.getData().toByteArray());
                }

                @Override
                public String toString() {
                    return "callback for frameworkMessage()";
                }
            };
        }
    });
}
Also used : Executor(org.apache.mesos.Executor) FrameworkToExecutorMessage(mesos.internal.Messages.FrameworkToExecutorMessage) 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