Class: ZeevexCluster::Static
Direct Known Subclasses
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ Static
constructor
A new instance of Static.
-
#join ⇒ Object
joining is a no-op for ol’ singleton here.
-
#leave ⇒ Object
leaving, too.
-
#make_master! ⇒ Object
Nobody can change the master.
-
#master ⇒ Object
Return name of master node.
-
#master? ⇒ Boolean
Are we the chosen one?.
- #member? ⇒ Boolean
-
#resign! ⇒ Object
Resign from mastership; returns false if this is the only node.
Methods inherited from Base
#ensure_master, #run_if_master
Methods included from Util::Logging
Constructor Details
#initialize(options = {}) ⇒ Static
Returns a new instance of Static.
3 4 5 6 7 8 9 10 11 |
# File 'lib/zeevex_cluster/static.rb', line 3 def initialize( = {}) super raise ArgumentError, "Must supply :master_nodename" unless @options[:master_nodename] if @options[:master_nodename] == :self @options[:master_nodename] = nodename end @member = false after_initialize end |
Instance Method Details
#join ⇒ Object
joining is a no-op for ol’ singleton here
16 17 18 |
# File 'lib/zeevex_cluster/static.rb', line 16 def join @member = true end |
#leave ⇒ Object
leaving, too
23 24 25 26 |
# File 'lib/zeevex_cluster/static.rb', line 23 def leave @member = false true end |
#make_master! ⇒ Object
Nobody can change the master
42 43 44 45 |
# File 'lib/zeevex_cluster/static.rb', line 42 def make_master! raise ClusterActionFailed, "Can not change master" unless master? true end |
#master ⇒ Object
Return name of master node
62 63 64 |
# File 'lib/zeevex_cluster/static.rb', line 62 def master [:master_nodename] end |
#master? ⇒ Boolean
Are we the chosen one?
35 36 37 |
# File 'lib/zeevex_cluster/static.rb', line 35 def master? member? && nodename == [:master_nodename] end |
#member? ⇒ Boolean
28 29 30 |
# File 'lib/zeevex_cluster/static.rb', line 28 def member? !! @member end |
#resign! ⇒ Object
Resign from mastership; returns false if this is the only node.
No-op for now.
52 53 54 55 56 57 |
# File 'lib/zeevex_cluster/static.rb', line 52 def resign! raise NotMaster unless master? # master is currently fixed, so we can't resign raise ClusterPolicyViolation, "Current master cannot resign in this implementation." end |