Apache Mesos
|
An abstraction of a Master detector which can be used to detect the leading master from a group. More...
#include <detector.hpp>
Public Member Functions | |
virtual | ~MasterDetector ()=0 |
virtual process::Future< Option< MasterInfo > > | detect (const Option< MasterInfo > &previous=None())=0 |
Returns MasterInfo after an election has occurred and the elected master is different than that specified (if any), or NONE if an election occurs and no master is elected (e.g., all masters are lost). More... | |
Static Public Member Functions | |
static Try< MasterDetector * > | create (const Option< std::string > &zk, const Option< std::string > &masterDetectorModule=None(), const Option< Duration > &zkSessionTimeout=None()) |
Creates a master detector. More... | |
An abstraction of a Master detector which can be used to detect the leading master from a group.
|
pure virtual |
|
static |
Creates a master detector.
If masterDetectorModule
contains a valid module name (that is, a name that matches the name specified in a JSON file/string passed into the command-line invocation using the --modules
flag), the result is the MasterDetector
returned by the module. Additional parameters required to create an object of the detector type are expected to be specified in the JSON's parameter
object. In command-line invocations, the value of masterDetectorModule
is expected to come from the --master_detector
flag.
If masterDetectorModule
is None
, zk
is checked and if it contains a valid zk://
or file://
path (passed in using the --master
flag), an instance of ZooKeeperMasterDetector is returned.
If both arguments are None
, StandaloneMasterDetector
is returned.
|
pure virtual |
Returns MasterInfo after an election has occurred and the elected master is different than that specified (if any), or NONE if an election occurs and no master is elected (e.g., all masters are lost).
A failed future is returned if the detector is unable to detect the leading master due to a non-retryable error. Note that the detector transparently tries to recover from retryable errors. The future is never discarded unless it stays pending when the detector destructs.
The 'previous' result (if any) should be passed back if this method is called repeatedly so the detector only returns when it gets a different result.
Implemented in mesos::master::detector::ZooKeeperMasterDetector, and mesos::master::detector::StandaloneMasterDetector.