Documentation ¶
Overview ¶
The detector package houses implementation of master detectors. The default implementation is the zookeeper master detector. It uses zookeeper to detect the lead Mesos master during startup/failover.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var (
EmptySpecError = errors.New("empty master specification")
)
Functions ¶
func CreateMasterInfo ¶
func CreateMasterInfo(pid *upid.UPID) *mesos.MasterInfo
Super-useful utility func that attempts to build a mesos.MasterInfo from a upid.UPID specification. An attempt is made to determine the IP address of the UPID's Host and any errors during such resolution will result in a nil returned result. A nil result is also returned upon errors parsing the Port specification of the UPID.
TODO(jdef) make this a func of upid.UPID so that callers can invoke somePid.MasterInfo()?
func Register ¶
func Register(prefix string, f PluginFactory) error
associates a plugin implementation with a Master specification prefix. packages that provide plugins are expected to invoke this func within their init() implementation. schedulers that wish to support plugins may anonymously import ("_") a package the auto-registers said plugins.
Types ¶
type AllMasters ¶ added in v1.0.3
type AllMasters interface { // UpdatedMasters is invoked upon a change in the membership of mesos // masters, and is useful to clients that wish to know the entire set // of Mesos masters currently running. UpdatedMasters([]*mesos.MasterInfo) }
AllMasters defines an optional interface that, if implemented by the same struct as implements MasterChanged, will receive an additional callbacks independently of leadership changes. it's possible that, as a result of a leadership change, both the OnMasterChanged and UpdatedMasters callbacks would be invoked.
**NOTE:** Detector implementations are not required to support this optional interface. Please RTFM of the detector implementation that you want to use.
type Master ¶
type Master interface { // Detect new master election. Every time a new master is elected, the // detector will alert the observer. The first call to Detect is expected // to kickstart any background detection processing (and not before then). // If detection startup fails, or the listener cannot be added, then an // error is returned. Detect(MasterChanged) error // returns a chan that, when closed, indicates the detector has terminated Done() <-chan struct{} // cancel the detector. it's ok to call this multiple times, or even if // Detect() hasn't been invoked yet. Cancel() }
An abstraction of a Master detector which can be used to detect the leading master from a group.
func New ¶
Create a new detector given the provided specification. Examples are:
- file://{path_to_local_file}
- {ipaddress}:{port}
- master@{ip_address}:{port}
- master({id})@{ip_address}:{port}
Support for the file:// prefix is intentionally hardcoded so that it may not be inadvertently overridden by a custom plugin implementation. Custom plugins are supported via the Register and MatchingPlugin funcs.
Furthermore it is expected that master detectors returned from this func are not yet running and will only begin to spawn requisite background processing upon, or some time after, the first invocation of their Detect.
type MasterChanged ¶
type MasterChanged interface { // Invoked when the master changes OnMasterChanged(*mesos.MasterInfo) }
type OnMasterChanged ¶
type OnMasterChanged func(*mesos.MasterInfo)
func/interface adapter
func (OnMasterChanged) OnMasterChanged ¶
func (f OnMasterChanged) OnMasterChanged(mi *mesos.MasterInfo)
type Option ¶ added in v1.1.5
type Option func(interface{}) Option
functional option type for detectors
type PluginFactory ¶
func MatchingPlugin ¶
func MatchingPlugin(spec string) (PluginFactory, bool)
type Standalone ¶
type Standalone struct {
// contains filtered or unexported fields
}
func NewStandalone ¶
func NewStandalone(mi *mesos.MasterInfo) *Standalone
Create a new stand alone master detector.
func (*Standalone) Cancel ¶
func (s *Standalone) Cancel()
func (*Standalone) Detect ¶
func (s *Standalone) Detect(o MasterChanged) error
Detecting the new master.
func (*Standalone) Done ¶
func (s *Standalone) Done() <-chan struct{}
func (*Standalone) String ¶
func (s *Standalone) String() string