public void startHBase() throws IOException {
    startDaemonLogTailer();
    cleanupOldState();

    // start ZK
    LOG.info("Starting ZooKeeper on port " + zkClientPort);
    startZK();

    HBaseTestingUtil.waitForHostPort(HConstants.LOCALHOST, zkClientPort);

    for (int masterPort : masterPorts) {
      startMaster(masterPort);
    }

    ZKUtil.waitForBaseZNode(conf);

    for (int rsPort : rsPorts) {
      startRegionServer(rsPort);
    }

    LOG.info("Waiting for HBase startup by scanning META");
    int attemptsLeft = 10;
    while (attemptsLeft-- > 0) {
      try {
        testUtil.getConnection().getTable(TableName.META_TABLE_NAME);
      } catch (Exception e) {
        LOG.info("Waiting for HBase to startup. Retries left: " + attemptsLeft, e);
        Threads.sleep(1000);
      }
    }

    LOG.info("Process-based HBase Cluster with " + numRegionServers
      + " region servers up and running... \n\n");
  }
Generates a list of random port numbers in the sorted order. A sorted order makes sense if we
ever want to refer to these servers by their index in the returned array, e.g. server #0, #1,
etc.
hbase-diagnostics/src/test/java/org/apache/hadoop/hbase/util/ProcessBasedLocalHBaseCluster.java