| 1 | package executor |
| 2 | |
| 3 | import ( |
| 4 | "github.com/mesos/mesos-go/api/v0/mesosproto" |
| 5 | ) |
| 6 | |
| 7 | /** |
| 8 | * Executor callback interface to be implemented by frameworks' executors. Note |
| 9 | * that only one callback will be invoked at a time, so it is not |
| 10 | * recommended that you block within a callback because it may cause a |
| 11 | * deadlock. |
| 12 | * |
| 13 | * Each callback includes an instance to the executor driver that was |
| 14 | * used to run this executor. The driver will not change for the |
| 15 | * duration of an executor (i.e., from the point you do |
| 16 | * ExecutorDriver.Start() to the point that ExecutorDriver.Join() |
| 17 | * returns). This is intended for convenience so that an executor |
| 18 | * doesn't need to store a pointer to the driver itself. |
| 19 | */ |
| 20 | type Executor interface { |
| 21 | /** |
| 22 | * Invoked once the executor driver has been able to successfully |
| 23 | * connect with Mesos. In particular, a scheduler can pass some |
| 24 | * data to its executors through the FrameworkInfo.ExecutorInfo's |
| 25 | * data field. |
| 26 | */ |
| 27 | Registered(ExecutorDriver, *mesosproto.ExecutorInfo, *mesosproto.FrameworkInfo, *mesosproto.SlaveInfo) |
| 28 | |
| 29 | /** |
| 30 | * Invoked when the executor re-registers with a restarted slave. |
| 31 | */ |
| 32 | Reregistered(ExecutorDriver, *mesosproto.SlaveInfo) |
| 33 | |
| 34 | /** |
| 35 | * Invoked when the executor becomes "disconnected" from the slave |
| 36 | * (e.g., the slave is being restarted due to an upgrade). |
| 37 | */ |
| 38 | Disconnected(ExecutorDriver) |
| 39 | |
| 40 | /** |
| 41 | * Invoked when a task has been launched on this executor (initiated |
| 42 | * via SchedulerDriver.LaunchTasks). Note that this task can be realized |
| 43 | * with a goroutine, an external process, or some simple computation, however, |
| 44 | * no other callbacks will be invoked on this executor until this |
| 45 | * callback has returned. |
| 46 | */ |
| 47 | LaunchTask(ExecutorDriver, *mesosproto.TaskInfo) |
| 48 | |
| 49 | /** |
| 50 | * Invoked when a task running within this executor has been killed |
| 51 | * (via SchedulerDriver.KillTask). Note that no status update will |
| 52 | * be sent on behalf of the executor, the executor is responsible |
| 53 | * for creating a new TaskStatus (i.e., with TASK_KILLED) and |
| 54 | * invoking ExecutorDriver.SendStatusUpdate. |
| 55 | */ |
| 56 | KillTask(ExecutorDriver, *mesosproto.TaskID) |
| 57 | |
| 58 | /** |
| 59 | * Invoked when a framework message has arrived for this |
| 60 | * executor. These messages are best effort; do not expect a |
| 61 | * framework message to be retransmitted in any reliable fashion. |
| 62 | */ |
| 63 | FrameworkMessage(ExecutorDriver, string) |
| 64 | |
| 65 | /** |
| 66 | * Invoked when the executor should terminate all of its currently |
| 67 | * running tasks. Note that after Mesos has determined that an |
| 68 | * executor has terminated, any tasks that the executor did not send |
| 69 | * terminal status updates for (e.g., TASK_KILLED, TASK_FINISHED, |
| 70 | * TASK_FAILED, etc) a TASK_LOST status update will be created. |
| 71 | */ |
| 72 | Shutdown(ExecutorDriver) |
| 73 | |
| 74 | /** |
| 75 | * Invoked when a fatal error has occured with the executor and/or |
| 76 | * executor driver. The driver will be aborted BEFORE invoking this |
| 77 | * callback. |
| 78 | */ |
| 79 | Error(ExecutorDriver, string) |
| 80 | } |
| 81 | |
| 82 | /** |
| 83 | * ExecutorDriver interface for connecting an executor to Mesos. This |
| 84 | * interface is used both to manage the executor's lifecycle (start |
| 85 | * it, stop it, or wait for it to finish) and to interact with Mesos |
| 86 | * (e.g., send status updates, send framework messages, etc.). |
| 87 | * A driver method is expected to fail-fast and return an error when possible. |
| 88 | * Other internal errors (or remote error) that occur asynchronously are handled |
| 89 | * using the the Executor.Error() callback. |
| 90 | */ |
| 91 | type ExecutorDriver interface { |
| 92 | /** |
| 93 | * Starts the executor driver. This needs to be called before any |
| 94 | * other driver calls are made. |
| 95 | */ |
| 96 | Start() (mesosproto.Status, error) |
| 97 | |
| 98 | /** |
| 99 | * Stops the executor driver. |
| 100 | */ |
| 101 | Stop() (mesosproto.Status, error) |
| 102 | |
| 103 | /** |
| 104 | * Aborts the driver so that no more callbacks can be made to the |
| 105 | * executor. The semantics of abort and stop have deliberately been |
| 106 | * separated so that code can detect an aborted driver (i.e., via |
| 107 | * the return status of ExecutorDriver.Join, see below), and |
| 108 | * instantiate and start another driver if desired (from within the |
| 109 | * same process ... although this functionality is currently not |
| 110 | * supported for executors). |
| 111 | */ |
| 112 | Abort() (mesosproto.Status, error) |
| 113 | |
| 114 | /** |
| 115 | * Waits for the driver to be stopped or aborted, possibly |
| 116 | * blocking the calling goroutine indefinitely. The return status of |
| 117 | * this function can be used to determine if the driver was aborted |
| 118 | * (see package mesosproto for a description of Status). |
| 119 | */ |
| 120 | Join() (mesosproto.Status, error) |
| 121 | |
| 122 | /** |
| 123 | * Starts and immediately joins (i.e., blocks on) the driver. |
| 124 | */ |
| 125 | Run() (mesosproto.Status, error) |
| 126 | |
| 127 | /** |
| 128 | * Sends a status update to the framework scheduler, retrying as |
| 129 | * necessary until an acknowledgement has been received or the |
| 130 | * executor is terminated (in which case, a TASK_LOST status update |
| 131 | * will be sent). See Scheduler.StatusUpdate for more information |
| 132 | * about status update acknowledgements. |
| 133 | */ |
| 134 | SendStatusUpdate(*mesosproto.TaskStatus) (mesosproto.Status, error) |
| 135 | |
| 136 | /** |
| 137 | * Sends a message to the framework scheduler. These messages are |
| 138 | * best effort; do not expect a framework message to be |
| 139 | * retransmitted in any reliable fashion. |
| 140 | */ |
| 141 | SendFrameworkMessage(string) (mesosproto.Status, error) |
| 142 | } |