public static long getGcTimestamp ( String zookeepers ) { ZooKeeper zk = null ; try { zk = new ZooKeeper ( zookeepers , 30000 , null ) ; // wait until zookeeper is connected long start = System . currentTimeMillis ( ) ; while ( ! zk . getState ( ) . isConnected ( ) && System . currentTimeMillis ( ) - start < 30000 ) { Uninterruptibles . sleepUninterruptibly ( 10 , TimeUnit . MILLISECONDS ) ; } byte [ ] d = zk . getData ( ZookeeperPath . ORACLE_GC_TIMESTAMP , false , null ) ; return LongUtil . fromByteArray ( d ) ; } catch ( KeeperException | InterruptedException | IOException e ) { log . warn ( "Failed to get oldest timestamp of Oracle from Zookeeper" , e ) ; return OLDEST_POSSIBLE ; } finally { if ( zk != null ) { try { zk . close ( ) ; } catch ( InterruptedException e ) { log . error ( "Failed to close zookeeper client" , e ) ; } } } }
Retrieves the GC timestamp set by the Oracle from zookeeper