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