private String createNonSequential(String path, byte[] data, List<ACL> acl, CreateMode createMode)
      throws KeeperException, InterruptedException {
    RetryCounter retryCounter = retryCounterFactory.create();
    while (true) {
      try {
        return zk.create(path, data, acl, createMode);
      } catch (KeeperException e) {
        switch (e.code()) {
          case NODEEXISTS:
            // Non-sequential node was successfully created
            return path;

          case CONNECTIONLOSS:
          case OPERATIONTIMEOUT:
            LOG.warn("Possibly transient ZooKeeper exception: " + e);
            if (!retryCounter.shouldRetry()) {
              LOG.error("ZooKeeper create failed after "
                  + retryCounter.getMaxRetries() + " retries");
              throw e;
            }
            break;

          default:
            throw e;
        }
      }
      LOG.info("Retrying ZooKeeper after sleeping...");
      retryCounter.sleepUntilNextRetry();
      retryCounter.useRetry();
    }
  }
private String createNonSequential ( String path , byte [ ] data , List < ACL > acl , CreateMode createMode ) throws KeeperException , InterruptedException { RetryCounter retryCounter = retryCounterFactory . create ( ) ; while ( true ) { try { return zk . create ( path , data , acl , createMode ) ; } catch ( KeeperException e ) { switch ( e . code ( ) ) { case NODEEXISTS : return path ; case CONNECTIONLOSS : case OPERATIONTIMEOUT : LOG . warn ( "Possibly transient ZooKeeper exception: " + e ) ; if ( ! retryCounter . shouldRetry ( ) ) { LOG . error ( "ZooKeeper create failed after " + retryCounter . getMaxRetries ( ) + " retries" ) ; throw e ; } break ; default : throw e ; } } LOG . info ( "Retrying ZooKeeper after sleeping..." ) ; retryCounter . sleepUntilNextRetry ( ) ; retryCounter . useRetry ( ) ; } }
------------------------- Internal Helpers ------------------------ //