Class: ZeevexCluster::Strategy::Base

Inherits:
Object
  • Object
show all
Includes:
Hookem, Util::Logging
Defined in:
lib/zeevex_cluster/strategy/base.rb

Direct Known Subclasses

Cas, Static, Zookeeper

Instance Method Summary collapse

Methods included from Util::Logging

#logger

Constructor Details

#initialize(options = {}) ⇒ Base

include ZeevexThreadsafe::ThreadSafer



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/zeevex_cluster/strategy/base.rb', line 12

def initialize(options = {})
  @options       = options
  @namespace     = options[:namespace]
  @cluster_name  = options[:cluster_name]
  @nodename      = options[:nodename] || Socket.gethostname
  @hooks         = {}
  @logger        = options[:logger]

  @state         = :stopped

  reset_state_vars

  _initialize_hook_module

  if options[:hooks]
    add_hooks options[:hooks]
  end
end

Instance Method Details

#am_i_master?Boolean

Returns:

  • (Boolean)


35
36
37
# File 'lib/zeevex_cluster/strategy/base.rb', line 35

def am_i_master?
  @my_cluster_status == :master
end

#has_master?Boolean

Returns:

  • (Boolean)


31
32
33
# File 'lib/zeevex_cluster/strategy/base.rb', line 31

def has_master?
  !! @current_master
end

#member?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/zeevex_cluster/strategy/base.rb', line 47

def member?
  online?
end

#online?Boolean

Returns:

  • (Boolean)


43
44
45
# File 'lib/zeevex_cluster/strategy/base.rb', line 43

def online?
  @cluster_status == :online
end

#started?Boolean

Returns:

  • (Boolean)


51
52
53
# File 'lib/zeevex_cluster/strategy/base.rb', line 51

def started?
  @state == :started
end

#stateObject



39
40
41
# File 'lib/zeevex_cluster/strategy/base.rb', line 39

def state
  @state
end

#stopped?Boolean

Returns:

  • (Boolean)


55
56
57
# File 'lib/zeevex_cluster/strategy/base.rb', line 55

def stopped?
  @state == :stopped
end