protected Object retryOperation ( ZooKeeperOperation operation ) throws KeeperException , InterruptedException { KeeperException exception = null ; for ( int i = 0 ; i < retryCount ; i ++ ) { try { return operation . execute ( ) ; } catch ( KeeperException . SessionExpiredException e ) { LOG . warn ( "Session expired for: " + zookeeper + " so reconnecting due to: " + e , e ) ; throw e ; } catch ( KeeperException . ConnectionLossException e ) { if ( exception == null ) { exception = e ; } LOG . debug ( "Attempt " + i + " failed with connection loss so " + "attempting to reconnect: " + e , e ) ; retryDelay ( i ) ; } } throw exception ; }
Perform the given operation retrying if the connection fails