Optional<Procedure<?>> procedureCompleted(Procedure<?> proc) {
    Preconditions.checkState(enqueuedProc != null, "enqueued procedure should not be null");
    if (enqueuedProc == proc) {
      if (!queue.isEmpty()) {
        enqueuedProc = queue.poll();
        return Optional.of(enqueuedProc);
      } else {
        enqueuedProc = null;
        return Optional.empty();
      }
    } else {
      Preconditions.checkState(isSubProcedure(proc),
        "procedure %s is not a sub procedure of enqueued procedure %s", proc, enqueuedProc);
      return Optional.empty();
    }
  }
Return the next procedure which can be enqueued to ProcedureScheduler.
hbase-server/src/main/java/org/apache/hadoop/hbase/master/procedure/TableProcedureWaitingQueue.java