Apache curator loses all hours after reconnecting
I am using Apache Curator in my project. After CuratorFramework loses the connection to the ZooKeeper server, it automatically recovers, but it seems like it loses all the hours I set up and I don't get any notifications anymore. The clock works as expected unless the connection drops and restarts.
Is this a curator error or am I doing something wrong? The code for setting the clock looks like this:
CuratorFramework framework = CuratorFrameworkFactory.newClient(connectString, SESSION_TIMEOUT_MS, 0, new ExponentialBackoffRetry(CONNECT_TIMEOUT_MS, CONNECT_RETRY_COUNT));
framework.start();
framework.getChildren().usingWatcher(watcher).forPath(path);
thank,
+4
source to share
1 answer
Yours Watcher
should notify you of the connection change. If so, EventType
at WatchedEvent
will None
, using it as an opportunity to restart the clock:
@Override
public void process(WatchedEvent event) {
if (event.getType == Event.EventType.None && event.getState() == Event.KeeperState.SyncConnected){
framework.getChildren().usingWatcher(this).forPath(path);
...
+5
source to share