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

Returns:

  • (Boolean)


30
31
32
# File 'lib/synapse/service_watcher/zookeeper.rb', line 30

def ping?
  @zk.ping?
end

#startObject



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

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

  log.info "synapse: starting ZK watcher #{@name} @ hosts: #{zk_hosts}, path: #{@discovery['path']}"
  @should_exit = false
  @zk = ZK.new(zk_hosts)

  # call the callback to bootstrap the process
  watcher_callback.call
end

#stopObject



20
21
22
23
24
25
26
27
28
# File 'lib/synapse/service_watcher/zookeeper.rb', line 20

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

  @should_exit = true
  @watcher.unsubscribe if defined? @watcher
  @zk.close! if defined? @zk

  log.info "synapse: zookeeper watcher cleaned up successfully"
end