public boolean     enter(long maxWait, TimeUnit unit) throws Exception
    {
        long            startMs = System.currentTimeMillis();
        boolean         hasMaxWait = (unit != null);
        long            maxWaitMs = hasMaxWait ? TimeUnit.MILLISECONDS.convert(maxWait, unit) : Long.MAX_VALUE;

        boolean         readyPathExists = (client.checkExists().usingWatcher(watcher).forPath(readyPath) != null);
        client.create().creatingParentContainersIfNeeded().withMode(CreateMode.EPHEMERAL).forPath(ourPath);

        boolean         result = (readyPathExists || internalEnter(startMs, hasMaxWait, maxWaitMs));
        if ( connectionLost.get() )
        {
            throw new KeeperException.ConnectionLossException();
        }

        return result;
    }
public boolean enter ( long maxWait , TimeUnit unit ) throws Exception { long startMs = System . currentTimeMillis ( ) ; boolean hasMaxWait = ( unit != null ) ; long maxWaitMs = hasMaxWait ? TimeUnit . MILLISECONDS . convert ( maxWait , unit ) : Long . MAX_VALUE ; boolean readyPathExists = ( client . checkExists ( ) . usingWatcher ( watcher ) . forPath ( readyPath ) != null ) ; client . create ( ) . creatingParentContainersIfNeeded ( ) . withMode ( CreateMode . EPHEMERAL ) . forPath ( ourPath ) ; boolean result = ( readyPathExists || internalEnter ( startMs , hasMaxWait , maxWaitMs ) ) ; if ( connectionLost . get ( ) ) { throw new KeeperException . ConnectionLossException ( ) ; } return result ; }
Enter the barrier and block until all members have entered or the timeout has
elapsed

@param maxWait max time to block
@param unit time unit
@return true if the entry was successful, false if the timeout elapsed first
@throws Exception interruptions, errors, etc.