Class: Synapse::ServiceWatcher::ZookeeperDnsWatcher
- Inherits:
-
BaseWatcher
- Object
- BaseWatcher
- Synapse::ServiceWatcher::ZookeeperDnsWatcher
- Defined in:
- lib/synapse/service_watcher/zookeeper_dns.rb
Defined Under Namespace
Modules: Messages Classes: Dns, Zookeeper
Constant Summary
Constants inherited from BaseWatcher
BaseWatcher::LEADER_WARN_INTERVAL
Instance Attribute Summary
Attributes inherited from BaseWatcher
Instance Method Summary collapse
- #backends ⇒ Object
- #ping? ⇒ Boolean
-
#reconfigure! ⇒ Object
Override reconfigure! as this class should not explicitly reconfigure synapse.
- #start ⇒ Object
- #stop ⇒ Object
Methods inherited from BaseWatcher
#config_for_generator, #haproxy, #initialize
Methods included from Logging
configure_logger_for, #log, logger_for
Constructor Details
This class inherits a constructor from Synapse::ServiceWatcher::BaseWatcher
Instance Method Details
#backends ⇒ Object
198 199 200 |
# File 'lib/synapse/service_watcher/zookeeper_dns.rb', line 198 def backends @dns.backends end |
#ping? ⇒ Boolean
187 188 189 |
# File 'lib/synapse/service_watcher/zookeeper_dns.rb', line 187 def ping? @watcher.alive? && @dns.ping? && @zk.ping? end |
#reconfigure! ⇒ Object
Override reconfigure! as this class should not explicitly reconfigure synapse
204 205 206 |
# File 'lib/synapse/service_watcher/zookeeper_dns.rb', line 204 def reconfigure! @revision += 1 end |
#start ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 |
# File 'lib/synapse/service_watcher/zookeeper_dns.rb', line 141 def start dns_discovery_opts = @discovery.select do |k,_| k == 'nameserver' || k == 'label_filter' end zookeeper_discovery_opts = @discovery.select do |k,_| k == 'hosts' || k == 'path' || k == 'label_filter' end @check_interval = @discovery['check_interval'] || 30.0 @message_queue = Queue.new @dns = Dns.new( mk_child_watcher_opts(dns_discovery_opts), self, @synapse, @message_queue ) @zk = Zookeeper.new( mk_child_watcher_opts(zookeeper_discovery_opts), self, @synapse, @message_queue ) @zk.start @dns.start @watcher = Thread.new do until @should_exit # Trigger a DNS resolve every @check_interval seconds sleep @check_interval # Only trigger the resolve if the queue is empty, every other message # on the queue would either cause a resolve or stop the watcher if @message_queue.empty? @message_queue.push(Messages::CHECK_INTERVAL_MESSAGE) end end log.info "synapse: zookeeper_dns watcher exited successfully" end end |
#stop ⇒ Object
191 192 193 194 195 196 |
# File 'lib/synapse/service_watcher/zookeeper_dns.rb', line 191 def stop super @dns.stop @zk.stop end |