Class: ZeevexCluster::Strategy::Static
- Inherits:
-
Base
- Object
- Base
- ZeevexCluster::Strategy::Static
show all
- Defined in:
- lib/zeevex_cluster/strategy/static.rb
Instance Method Summary
collapse
Methods inherited from Base
#has_master?, #member?, #online?, #started?, #state, #stopped?
#logger
Constructor Details
#initialize(options = {}) ⇒ Static
Returns a new instance of Static.
5
6
7
8
9
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 5
def initialize(options = {})
super
@master_nodename = options[:master_nodename] || raise(ArgumentError, 'Must specify :master_nodename')
@members = options[:members]
end
|
Instance Method Details
#am_i_master? ⇒ Boolean
30
31
32
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 30
def am_i_master?
@state == :started && @my_cluster_status == :master
end
|
#can_view? ⇒ Boolean
58
59
60
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 58
def can_view?
true
end
|
#master_node ⇒ Object
FIXME: this is CAS-specific
35
36
37
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 35
def master_node
{:nodename => @master_nodename}
end
|
#members ⇒ Object
39
40
41
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 39
def members
@members || [@master_nodename, @nodename].select {|x| x != "none" }.uniq
end
|
#observe ⇒ Object
62
63
64
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 62
def observe
true
end
|
#observing? ⇒ Boolean
54
55
56
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 54
def observing?
true
end
|
#resign(delay = nil) ⇒ Object
43
44
45
46
47
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 43
def resign(delay = nil)
logger.warn 'Current master cannot resign in this implementation.'
false
end
|
#start ⇒ Object
11
12
13
14
15
16
17
18
19
20
21
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 11
def start
@state = :started
change_cluster_status :online
if @nodename == @master_nodename
change_my_status :master
change_master_status :good
else
change_my_status :member
change_master_status :unknown
end
end
|
#steal_election! ⇒ Object
49
50
51
52
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 49
def steal_election!
raise ClusterActionFailed, 'Can not change master' unless am_i_master?
true
end
|
#stop ⇒ Object
23
24
25
26
27
28
|
# File 'lib/zeevex_cluster/strategy/static.rb', line 23
def stop
@state = :stopped
change_my_status :nonmember
change_master_status :unknown
change_cluster_status :offline
end
|