public int randomFreePort() {
      int port = 0;
      do {
        port = randomPort();
        if (takenRandomPorts.contains(port)) {
          port = 0;
          continue;
        }
        takenRandomPorts.add(port);

        if (!portChecker.available(port)) {
          port = 0;
        }
      } while (port == 0);
      return port;
    }
Returns a random free port and marks that port as taken. Not thread-safe. Expected to be
called from single-threaded test setup code/
hbase-testing-util/src/main/java/org/apache/hadoop/hbase/HBaseCommonTestingUtility.java