Processes a ZooKeeper event. This method is called back by ZooKeeper from its main event thread. So make sure you don't block. @param event The event to process.
(final WatchedEvent event)
| 4213 | * @param event The event to process. |
| 4214 | */ |
| 4215 | public void process(final WatchedEvent event) { |
| 4216 | LOG.debug("Got ZooKeeper event: {}", event); |
| 4217 | try { |
| 4218 | switch (event.getState()) { |
| 4219 | case SyncConnected: |
| 4220 | getRootRegion(); |
| 4221 | break; |
| 4222 | default: |
| 4223 | disconnectZK(); |
| 4224 | // Reconnect only if we're still trying to locate -ROOT-. |
| 4225 | synchronized (this) { |
| 4226 | if (deferred_rootregion != null) { |
| 4227 | LOG.warn("No longer connected to ZooKeeper, event=" + event); |
| 4228 | connectZK(); |
| 4229 | } |
| 4230 | } |
| 4231 | return; |
| 4232 | } |
| 4233 | } catch (Exception e) { |
| 4234 | LOG.error("Uncaught exception when handling event " + event, e); |
| 4235 | return; |
| 4236 | } |
| 4237 | LOG.debug("Done handling ZooKeeper event: {}", event); |
| 4238 | } |
| 4239 | |
| 4240 | /** |
| 4241 | * Connects to ZooKeeper. |
nothing calls this directly
no test coverage detected