Concrete implementation of a SchedulerDriver that connects a Scheduler with a Mesos master. The MesosSchedulerDriver is thread-safe. Note that scheduler failover is supported in Mesos. After a scheduler is registered with Mesos it may failover (to a new process on the same machine or across mult
| 58 | * the MesosSchedulerDriver. |
| 59 | */ |
| 60 | public class MesosSchedulerDriver implements SchedulerDriver { |
| 61 | static { |
| 62 | MesosNativeLibrary.load(); |
| 63 | } |
| 64 | |
| 65 | /** |
| 66 | * Creates a new driver for the specified scheduler. The master |
| 67 | * should be one of: |
| 68 | * <pre> |
| 69 | * {@code |
| 70 | * host:port |
| 71 | * zk://host1:port1,host2:port2,.../path |
| 72 | * zk://username:password@host1:port1,host2:port2,.../path |
| 73 | * file:///path/to/file (where file contains one of the above) |
| 74 | * } |
| 75 | * </pre> |
| 76 | * <p> |
| 77 | * The driver will attempt to "failover" if the specified |
| 78 | * FrameworkInfo includes a valid FrameworkID. |
| 79 | * <p> |
| 80 | * Any Mesos configuration options are read from environment |
| 81 | * variables, as well as any configuration files found through the |
| 82 | * environment variables. |
| 83 | * <p> |
| 84 | * |
| 85 | * @param scheduler The scheduler implementation which callbacks are invoked |
| 86 | * upon scheduler events. |
| 87 | * @param framework The frameworkInfo describing the current framework. |
| 88 | * @param master The address to the currently active Mesos master. |
| 89 | */ |
| 90 | // TODO(vinod): Deprecate this in favor the constructor that takes |
| 91 | // 'credential' as parameter. |
| 92 | public MesosSchedulerDriver(Scheduler scheduler, |
| 93 | FrameworkInfo framework, |
| 94 | String master) { |
| 95 | if (scheduler == null) { |
| 96 | throw new NullPointerException("Not expecting a null Scheduler"); |
| 97 | } |
| 98 | |
| 99 | if (framework == null) { |
| 100 | throw new NullPointerException("Not expecting a null FrameworkInfo"); |
| 101 | } |
| 102 | |
| 103 | if (master == null) { |
| 104 | throw new NullPointerException("Not expecting a null master"); |
| 105 | } |
| 106 | |
| 107 | this.scheduler = scheduler; |
| 108 | this.framework = framework; |
| 109 | this.suppressedRoles = null; |
| 110 | this.master = master; |
| 111 | this.implicitAcknowledgements = true; |
| 112 | this.credential = null; |
| 113 | |
| 114 | initialize(); |
| 115 | } |
| 116 | |
| 117 | /** |