public static synchronized IDGenerator generatorFor(ZooKeeperConnection zooKeeperConnection,
                                                        String znode,
                                                        Mode mode)
            throws IOException {

        if (!instances.containsKey(znode)) {
            final int clusterId = ClusterID.get(zooKeeperConnection.getActiveConnection(), znode);
            SynchronizedGeneratorIdentity generatorIdentityHolder =
                    new SynchronizedGeneratorIdentity(zooKeeperConnection, znode, clusterId, null);

            return generatorFor(generatorIdentityHolder, mode);
        }
        return instances.get(znode);
    }
public static synchronized IDGenerator generatorFor ( ZooKeeperConnection zooKeeperConnection , String znode , Mode mode ) throws IOException { if ( ! instances . containsKey ( znode ) ) { final int clusterId = ClusterID . get ( zooKeeperConnection . getActiveConnection ( ) , znode ) ; SynchronizedGeneratorIdentity generatorIdentityHolder = new SynchronizedGeneratorIdentity ( zooKeeperConnection , znode , clusterId , null ) ; return generatorFor ( generatorIdentityHolder , mode ) ; } return instances . get ( znode ) ; }
Get the synchronized ID generator instance.

@param zooKeeperConnection Connection to the ZooKeeper quorum.
@param znode               Base-path of the resource pool in ZooKeeper.
@param mode                Generator mode.
@return An instance of this class.
@throws IOException Thrown when something went wrong trying to find the cluster ID or trying to claim a
generator ID.