private void waitForSplittingCompletion(TaskBatch batch, MonitoredTask status) {
    synchronized (batch) {
      while ((batch.done + batch.error) != batch.installed) {
        try {
          status.setStatus("Waiting for distributed tasks to finish. " + " scheduled="
            + batch.installed + " done=" + batch.done + " error=" + batch.error);
          int remaining = batch.installed - (batch.done + batch.error);
          int actual = activeTasks(batch);
          if (remaining != actual) {
            LOG.warn("Expected " + remaining + " active tasks, but actually there are " + actual);
          }
          int remainingTasks = getSplitLogManagerCoordination().remainingTasksInCoordination();
          if (remainingTasks >= 0 && actual > remainingTasks) {
            LOG.warn("Expected at least" + actual + " tasks remaining, but actually there are "
              + remainingTasks);
          }
          if (remainingTasks == 0 || actual == 0) {
            LOG.warn(
              "No more task remaining, splitting " + "should have completed. Remaining tasks is "
                + remainingTasks + ", active tasks in map " + actual);
            if (remainingTasks == 0 && actual == 0) {
              return;
            }
          }
          batch.wait(getBatchWaitTimeMillis(remainingTasks));
          if (server.isStopped()) {
            LOG.warn("Stopped while waiting for log splits to be completed");
            return;
          }
        } catch (InterruptedException e) {
          LOG.warn("Interrupted while waiting for log splits to be completed");
          Thread.currentThread().interrupt();
          return;
        }
      }
    }
  }
Get the amount of time in milliseconds to wait till next check. Check less frequently if a
bunch of work to do still. At a max, check every minute. At a minimum, check every 100ms. This
is to alleviate case where perhaps there are a bunch of threads waiting on a completion. For
example, if the zk-based implementation, we will scan the '/hbase/splitWAL' dir every time
through this loop. If there are lots of WALs to split -- could be tens of thousands if big
cluster -- then it will take a while. If the Master has many SCPs waiting on wal splitting --
could be up to 10 x the configured PE thread count (default would be 160) -- then the Master
will be putting up a bunch of load on zk.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/SplitLogManager.java