Java Code Examples for org.apache.zookeeper.Watcher.Event.KeeperState#Disconnected
The following examples show how to use
org.apache.zookeeper.Watcher.Event.KeeperState#Disconnected .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ClusterManagerService.java From blog with MIT License | 6 votes |
@Override public void process(WatchedEvent event) { LOGGER.debug("Got Event from ZooKeeper: " + event + " Connection state: " + event.getState()); if (event.getState() == KeeperState.Expired) { previousState = KeeperState.Disconnected; goToSlaveMode(); try { init(); } catch (IOException | ClusterManagerException e) { LOGGER.error("Failed to init after session timeout", e); } return; } if (event.getState() != KeeperState.SyncConnected) { previousState = event.getState(); goToSlaveMode(); return; } handleStateChange(event); }
Example 2
Source File: ZooKeeperSessionWatcherTest.java From pulsar with Apache License 2.0 | 5 votes |
@Test public void testProcess2() { WatchedEvent event = new WatchedEvent(EventType.None, KeeperState.Disconnected, null); sessionWatcher.process(event); assertFalse(sessionWatcher.isShutdownStarted()); assertEquals(shutdownService.getExitCode(), 0); }
Example 3
Source File: ZkTestHelper.java From helix with Apache License 2.0 | 5 votes |
/** * Simulate a zk state change by calling {@link ZkClient#process(WatchedEvent)} directly */ public static void simulateZkStateReconnected(RealmAwareZkClient client) { ZkClient zkClient = (ZkClient) client; WatchedEvent event = new WatchedEvent(EventType.None, KeeperState.Disconnected, null); zkClient.process(event); event = new WatchedEvent(EventType.None, KeeperState.SyncConnected, null); zkClient.process(event); }
Example 4
Source File: ZkTestHelper.java From helix with Apache License 2.0 | 5 votes |
/** * Simulate a zk state change by calling {@link ZkClient#process(WatchedEvent)} directly */ public static void simulateZkStateReconnected(RealmAwareZkClient client) { ZkClient zkClient = (ZkClient) client; WatchedEvent event = new WatchedEvent(EventType.None, KeeperState.Disconnected, null); zkClient.process(event); event = new WatchedEvent(EventType.None, KeeperState.SyncConnected, null); zkClient.process(event); }
Example 5
Source File: SimpleZKTest.java From blazingcache with Apache License 2.0 | 4 votes |
private synchronized void reset() { clientConnected = new CountDownLatch(1); state = KeeperState.Disconnected; connected = false; expired = false; }
Example 6
Source File: SimpleZKSecureTest.java From blazingcache with Apache License 2.0 | 4 votes |
private synchronized void reset() { clientConnected = new CountDownLatch(1); state = KeeperState.Disconnected; connected = false; expired = false; }
Example 7
Source File: TestZkFlapping.java From helix with Apache License 2.0 | 4 votes |
@Override public void handleStateChanged(KeeperState state) { if (state == KeeperState.Disconnected) { count++; } }
Example 8
Source File: NodeWatcher.java From disconf with Apache License 2.0 | 4 votes |
/** * 回调函数 */ @Override public void process(WatchedEvent event) { // // 结点更新时 // if (event.getType() == EventType.NodeDataChanged) { try { LOGGER.info("============GOT UPDATE EVENT " + event.toString() + ": (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); // 调用回调函数, 回调函数里会重新进行监控 callback(); } catch (Exception e) { LOGGER.error("monitor node exception. " + monitorPath, e); } } // // 结点断开连接,这时不要进行处理 // if (event.getState() == KeeperState.Disconnected) { if (!debug) { LOGGER.warn("============GOT Disconnected EVENT " + event.toString() + ": (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); } else { LOGGER.debug("============DEBUG MODE: GOT Disconnected EVENT " + event.toString() + ": (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); } } // // session expired,需要重新关注哦 // if (event.getState() == KeeperState.Expired) { if (!debug) { LOGGER.error("============GOT Expired " + event.toString() + ": (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); // 重新连接 ZookeeperMgr.getInstance().reconnect(); callback(); } else { LOGGER.debug("============DEBUG MODE: GOT Expired " + event.toString() + ": (" + monitorPath + "," + "" + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); } } }
Example 9
Source File: NodeWatcher.java From disconf with Apache License 2.0 | 4 votes |
/** * 回调函数 */ @Override public void process(WatchedEvent event) { // // 结点更新时 // if (event.getType() == EventType.NodeDataChanged) { try { LOGGER.info("============GOT UPDATE EVENT " + event.toString() + ": (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); // 调用回调函数, 回调函数里会重新进行监控 callback(); } catch (Exception e) { LOGGER.error("monitor node exception. " + monitorPath, e); } } // // 结点断开连接,这时不要进行处理 // if (event.getState() == KeeperState.Disconnected) { if (!debug) { LOGGER.warn("============GOT Disconnected EVENT " + event.toString() + ": (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); } else { LOGGER.debug("============DEBUG MODE: GOT Disconnected EVENT " + event.toString() + ": (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); } } // // session expired,需要重新关注哦 // if (event.getState() == KeeperState.Expired) { if (!debug) { LOGGER.error("============GOT Expired " + event.toString() + ": (" + monitorPath + "," + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); // 重新连接 ZookeeperMgr.getInstance().reconnect(); callback(); } else { LOGGER.debug("============DEBUG MODE: GOT Expired " + event.toString() + ": (" + monitorPath + "," + "" + keyName + "," + disConfigTypeEnum.getModelName() + ")======================"); } } }