private CuratorFramework getNewCuratorClient ( ) { CuratorFramework client = CuratorFrameworkFactory . newClient ( mZookeeperAddress , ( int ) ServerConfiguration . getMs ( PropertyKey . ZOOKEEPER_SESSION_TIMEOUT ) , ( int ) ServerConfiguration . getMs ( PropertyKey . ZOOKEEPER_CONNECTION_TIMEOUT ) , new ExponentialBackoffRetry ( Constants . SECOND_MS , 3 ) ) ; client . start ( ) ; // Sometimes, if the master crashes and restarts too quickly (faster than the zookeeper // timeout), zookeeper thinks the new client is still an old one. In order to ensure a clean // state, explicitly close the "old" client and recreate a new one. client . close ( ) ; client = CuratorFrameworkFactory . newClient ( mZookeeperAddress , ( int ) ServerConfiguration . getMs ( PropertyKey . ZOOKEEPER_SESSION_TIMEOUT ) , ( int ) ServerConfiguration . getMs ( PropertyKey . ZOOKEEPER_CONNECTION_TIMEOUT ) , new ExponentialBackoffRetry ( Constants . SECOND_MS , 3 ) ) ; client . start ( ) ; return client ; }
Returns a new client for the zookeeper connection . The client is already started before returning .