Class: Synapse::ZookeeperWatcher

Inherits:
BaseWatcher show all
Defined in:
lib/synapse/service_watcher/zookeeper.rb

Direct Known Subclasses

Synapse::ZookeeperDnsWatcher::Zookeeper

Constant Summary collapse

NUMBERS_RE =
/^\d+$/

Constants inherited from BaseWatcher

BaseWatcher::LEADER_WARN_INTERVAL

Instance Attribute Summary

Attributes inherited from BaseWatcher

#haproxy, #name

Instance Method Summary collapse

Methods inherited from BaseWatcher

#backends, #initialize

Methods included from Logging

configure_logger_for, #log, logger_for

Constructor Details

This class inherits a constructor from Synapse::BaseWatcher

Instance Method Details

#ping?Boolean


24
25
26
# File 'lib/synapse/service_watcher/zookeeper.rb', line 24

def ping?
  @zk && @zk.connected?
end

#startObject


9
10
11
12
13
14
15
16
17
# File 'lib/synapse/service_watcher/zookeeper.rb', line 9

def start
  @zk_hosts = @discovery['hosts'].shuffle.join(',')

  @watcher = nil
  @zk = nil

  log.info "synapse: starting ZK watcher #{@name} @ hosts: #{@zk_hosts}, path: #{@discovery['path']}"
  zk_connect
end

#stopObject


19
20
21
22
# File 'lib/synapse/service_watcher/zookeeper.rb', line 19

def stop
  log.warn "synapse: zookeeper watcher exiting"
  zk_cleanup
end