Class: ProxyMgr::Watcher::Zookeeper

Inherits:
Base
  • Object
show all
Defined in:
lib/proxymgr/watcher/zookeeper.rb

Direct Known Subclasses

Campanjazk

Instance Attribute Summary

Attributes inherited from Base

#listen_options, #port, #server_options, #servers

Instance Method Summary collapse

Methods inherited from Base

#==, #initialize, #valid?

Methods included from Logging

disable!, #logger, logger

Constructor Details

This class inherits a constructor from ProxyMgr::Watcher::Base

Instance Method Details

#shutdownObject



16
17
18
# File 'lib/proxymgr/watcher/zookeeper.rb', line 16

def shutdown
  @zookeeper.close if @zookeeper
end

#validate_configObject



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/proxymgr/watcher/zookeeper.rb', line 20

def validate_config
  unless @config['path'].is_a? String and
    @config['path'] =~ /^\// and
    @config['path'] !~ /\/$/

    logger.warn "'path' is not a valid Zookeeper path"
    return
  end

  unless @config['server'].is_a? String and
      @config['server'] =~ /^(?:.*:\d{1,6}){1,}$/
    logger.warn "'server' is not properly specified"
    return
  end

  true
end

#watchObject



7
8
9
10
11
12
13
14
# File 'lib/proxymgr/watcher/zookeeper.rb', line 7

def watch
  @zookeeper  = Zoology::Client.new(@config['server'])
  @path_cache = Zoology::PathCache.new(@zookeeper,
                                       @config['path'],
                                       &method(:watch_zookeeper))
  @zk_mapping = {}
  @zookeeper.connect
end