code: static String takeQueueTicket(ZooKeeper zookeeper, String lockNode) throws InterruptedException, KeeperException {
          // The ticket number includes a random component to decrease the chances of collision. Collision is handled
          // neatly, but it saves a few actions if there is no need to retry ticket acquisition.
          String ticket = String.format("nr-%014d-%04d", System.currentTimeMillis(), random.nextInt(10000));
          if (grabTicket(zookeeper, lockNode, ticket)) {
              return ticket;
          } else {
              return takeQueueTicket(zookeeper, lockNode);
          }
      }
docs: Take a ticket for the queue. If the ticket was already claimed by another process,
  this method retries until it succeeds.
  
  @param zookeeper ZooKeeper connection to use.
  @param lockNode Path to the znode representing the locking queue.
  @return The claimed ticket.