use of org.apache.mesos.Executor 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();
}
use of org.apache.mesos.Executor 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()";
}
};
}
});
}
Aggregations