Search in sources :

Example 1 with FrameworkToExecutorMessage

use of mesos.internal.Messages.FrameworkToExecutorMessage 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)

Example 2 with FrameworkToExecutorMessage

use of mesos.internal.Messages.FrameworkToExecutorMessage in project jesos by groupon.

the class InternalSchedulerDriver method sendFrameworkMessage.

@Override
public Status sendFrameworkMessage(final ExecutorID executorId, final SlaveID slaveId, final byte[] data) {
    checkNotNull(executorId, "executorId is null");
    checkNotNull(slaveId, "slaveId is null");
    checkNotNull(data, "data is null");
    if (!context.isStateMachine(DRIVER_RUNNING)) {
        return context.getStateMachine();
    }
    final FrameworkToExecutorMessage message = FrameworkToExecutorMessage.newBuilder().setFrameworkId(context.getFrameworkId()).setExecutorId(executorId).setSlaveId(slaveId).setData(ByteString.copyFrom(data)).build();
    // directly to the slave, otherwise to the master and let the master sort it out.
    if (context.containsSlave(message.getSlaveId())) {
        final UPID slave = context.getSlaveUPID(message.getSlaveId());
        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), slave, message));
    } else {
        eventBus.post(new RemoteMessageEnvelope(context.getDriverUPID(), context.getMasterUPID(), message));
    }
    return context.getStateMachine();
}
Also used : UPID(com.groupon.mesos.util.UPID) RemoteMessageEnvelope(com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope) FrameworkToExecutorMessage(mesos.internal.Messages.FrameworkToExecutorMessage)

Aggregations

FrameworkToExecutorMessage (mesos.internal.Messages.FrameworkToExecutorMessage)2 Subscribe (com.google.common.eventbus.Subscribe)1 RemoteMessageEnvelope (com.groupon.mesos.scheduler.SchedulerMessageEnvelope.RemoteMessageEnvelope)1 UPID (com.groupon.mesos.util.UPID)1 Executor (org.apache.mesos.Executor)1 ExecutorDriver (org.apache.mesos.ExecutorDriver)1