Concrete implementation of an ExecutorDriver that connects an Executor with a Mesos slave. The MesosExecutorDriver is thread-safe. The driver is responsible for invoking the Executor callbacks as it communicates with the Mesos slave. Note that blocking on the MesosExecutorDriver (e.g.,
| 48 | * </p> |
| 49 | */ |
| 50 | public class MesosExecutorDriver implements ExecutorDriver { |
| 51 | static { |
| 52 | MesosNativeLibrary.load(); |
| 53 | } |
| 54 | |
| 55 | /** |
| 56 | * Creates a new driver that uses the specified Executor. |
| 57 | * |
| 58 | * @param executor The instance of the executor that will be used |
| 59 | * to connect to the slave. |
| 60 | * |
| 61 | * @see Executor |
| 62 | */ |
| 63 | public MesosExecutorDriver(Executor executor) { |
| 64 | if (executor == null) { |
| 65 | throw new NullPointerException("Not expecting a null Executor"); |
| 66 | } |
| 67 | |
| 68 | this.executor = executor; |
| 69 | |
| 70 | initialize(); |
| 71 | } |
| 72 | |
| 73 | /** |
| 74 | * See ExecutorDriver for descriptions of these. |
| 75 | * |
| 76 | * @see ExecutorDriver |
| 77 | */ |
| 78 | public native Status start(); |
| 79 | public native Status stop(); |
| 80 | public native Status abort(); |
| 81 | public native Status join(); |
| 82 | |
| 83 | public Status run() { |
| 84 | Status status = start(); |
| 85 | return status != Status.DRIVER_RUNNING ? status : join(); |
| 86 | } |
| 87 | |
| 88 | public native Status sendStatusUpdate(TaskStatus status); |
| 89 | public native Status sendFrameworkMessage(byte[] data); |
| 90 | |
| 91 | protected native void initialize(); |
| 92 | protected native void finalize(); |
| 93 | |
| 94 | private final Executor executor; |
| 95 | |
| 96 | private long __executor; |
| 97 | private long __driver; |
| 98 | } |