Interface for Mesos scheduler drivers. Users may wish to implement this class in mock objects for tests.
| 138 | |
| 139 | |
| 140 | class SchedulerDriver(object): |
| 141 | """ |
| 142 | Interface for Mesos scheduler drivers. Users may wish to implement this |
| 143 | class in mock objects for tests. |
| 144 | """ |
| 145 | def start(self): |
| 146 | """ |
| 147 | Starts the scheduler driver. This needs to be called before any other |
| 148 | driver calls are made. |
| 149 | """ |
| 150 | |
| 151 | def stop(self, failover=False): |
| 152 | """ |
| 153 | Stops the scheduler driver. If the 'failover' flag is set to False |
| 154 | then it is expected that this framework will never reconnect to Mesos |
| 155 | and all of its executors and tasks can be terminated. Otherwise, all |
| 156 | executors and tasks will remain running (for some framework specific |
| 157 | failover timeout) allowing the scheduler to reconnect (possibly in the |
| 158 | same process, or from a different process, for example, on a different |
| 159 | machine.) |
| 160 | """ |
| 161 | |
| 162 | def abort(self): |
| 163 | """ |
| 164 | Aborts the driver so that no more callbacks can be made to the |
| 165 | scheduler. The semantics of abort and stop have deliberately been |
| 166 | separated so that code can detect an aborted driver (i.e., via the |
| 167 | return status of SchedulerDriver.join), and instantiate and start |
| 168 | another driver if desired (from within the same process.) |
| 169 | """ |
| 170 | |
| 171 | def join(self): |
| 172 | """ |
| 173 | Waits for the driver to be stopped or aborted, possibly blocking the |
| 174 | current thread indefinitely. The return status of this function can |
| 175 | be used to determine if the driver was aborted (see mesos.proto for a |
| 176 | description of Status). |
| 177 | """ |
| 178 | |
| 179 | def run(self): |
| 180 | """ |
| 181 | Starts and immediately joins (i.e., blocks on) the driver. |
| 182 | """ |
| 183 | |
| 184 | def requestResources(self, requests): |
| 185 | """ |
| 186 | Requests resources from Mesos (see mesos.proto for a description of |
| 187 | Request and how, for example, to request resources from specific |
| 188 | slaves.) Any resources available are offered to the framework via |
| 189 | Scheduler.resourceOffers callback, asynchronously. |
| 190 | """ |
| 191 | |
| 192 | def launchTasks(self, offerIds, tasks, filters=None): |
| 193 | """ |
| 194 | Launches the given set of tasks. Any remaining resources (i.e., |
| 195 | those that are not used by the launched tasks or their executors) |
| 196 | will be considered declined. Note that this includes resources |
| 197 | used by tasks that the framework attempted to launch but failed |
nothing calls this directly
no outgoing calls
no test coverage detected