Details
-
Improvement
-
Status: Resolved
-
Major
-
Resolution: Fixed
-
0.5.0
-
None
Description
Currently we are handling ZK state changes a bit differently in two places.
org.apache.s4.comm.topology.AssignmentFromZK:
@Override public void handleStateChanged(KeeperState state) throws Exception { this.state = state; if (!state.equals(KeeperState.SyncConnected)) { logger.warn("Session not connected for cluster [{}]: [{}]. Trying to reconnect", clusterName, state.name()); zkClient.close(); zkClient.connect(connectionTimeout, null); handleNewSession(); } }
org.apache.s4.comm.topology.ClusterFromZK:
@Override public void handleStateChanged(KeeperState state) throws Exception { this.state = state; if (!state.equals(KeeperState.SyncConnected)) { logger.warn("Session not connected for cluster [{}]: [{}]. Trying to reconnect", clusterName, state.name()); zkClient.connect(connectionTimeout, null); handleNewSession(); } }
In the first case we explicitly close the connection before trying to reconnect. Furthermore, I think we should only try to reconnect when the state is equals to KeeperState.Expired, since now we are closing the connection on a Disconnected event too.