public void setPersistentTimestamp ( long newTimestamp ) throws FatalChronosException , ChronosException { if ( newTimestamp <= persistentTimestamp ) { throw new FatalChronosException ( "Fatal error to set a smaller timestamp" ) ; } if ( LOG . isDebugEnabled ( ) ) { LOG . debug ( "Setting persistent timestamp " + newTimestamp + " in ZooKeeper" ) ; } for ( int i = 0 ; i <= connectRetryTimes ; ++ i ) { try { ZooKeeperUtil . setData ( this , persistentTimestampZnode , ZooKeeperUtil . longToBytes ( newTimestamp ) ) ; persistentTimestamp = newTimestamp ; break ; } catch ( KeeperException e ) { if ( i == connectRetryTimes ) { throw new ChronosException ( "Error to set persistent timestamp in ZooKeeper after retrying" , e ) ; } LOG . info ( "Exception to set persistent timestamp in ZooKeeper, retry " + ( i + 1 ) + " times" ) ; } } }
Set persistent timestamp in ZooKeeper .