Description
Whenever ConnectionState.handleNewConnectionString is triggered, the value of newConnectionString is always the value used to construct the FixedEnsembleProvider
in ConnectionState:
String newConnectionString = zooKeeper.getNewConnectionString(); if ( newConnectionString != null ) { handleNewConnectionString(newConnectionString); } ... if ( ensembleProvider.updateServerListEnabled() ) { zooKeeper.updateServerList(newConnectionString); } else { reset(); }
in HandleHolder:
String getNewConnectionString() { String helperConnectionString = (helper != null) ? helper.getConnectionString() : null; return ((helperConnectionString != null) && !ensembleProvider.getConnectionString().equals(helperConnectionString)) ? helperConnectionString : null; }
code above shows that the newConnectionString is provided by helper.getConnectionString(), which only instantiated on first call of getZookeeper:
@Override public ZooKeeper getZooKeeper() throws Exception { synchronized(this) { if ( zooKeeperHandle == null ) { connectionString = ensembleProvider.getConnectionString(); zooKeeperHandle = zookeeperFactory.newZooKeeper(connectionString, sessionTimeout, watcher, canBeReadOnly); } ...
As a result, when I reconfig zookeeper serverList, curator client always call updateServerList with the initial value, not the ones I just reconfigured
Attachments
Issue Links
- fixes
-
CURATOR-7 Session ids not preserved if EnsembleProvider has changed the ensemble
- Closed
- is related to
-
CURATOR-570 Excessive calls to ZooKeeper.updateServerList (which can result in session death)
- Open
- links to