public static int get ( ZooKeeper zookeeper , String znode ) throws IOException { try { Stat stat = zookeeper . exists ( znode + CLUSTER_ID_NODE , false ) ; if ( stat == null ) { mkdirp ( zookeeper , znode ) ; create ( zookeeper , znode + CLUSTER_ID_NODE , String . valueOf ( DEFAULT_CLUSTER_ID ) . getBytes ( ) ) ; } byte [ ] id = zookeeper . getData ( znode + CLUSTER_ID_NODE , false , null ) ; return Integer . valueOf ( new String ( id ) ) ; } catch ( KeeperException e ) { throw new IOException ( String . format ( "Failed to retrieve the cluster ID from the ZooKeeper quorum. " + "Expected to find it at znode %s." , znode + CLUSTER_ID_NODE ) , e ) ; } catch ( InterruptedException e ) { Thread . currentThread ( ) . interrupt ( ) ; throw new IOException ( e ) ; } }
Retrieves the numeric cluster ID from the ZooKeeper quorum .