private Procedure<TEnvironment>[] initializeChildren(RootProcedureState<TEnvironment> procStack,
    Procedure<TEnvironment> procedure, Procedure<TEnvironment>[] subprocs) {
    assert subprocs != null : "expected subprocedures";
    final long rootProcId = getRootProcedureId(procedure);
    for (int i = 0; i < subprocs.length; ++i) {
      Procedure<TEnvironment> subproc = subprocs[i];
      if (subproc == null) {
        String msg = "subproc[" + i + "] is null, aborting the procedure";
        procedure
          .setFailure(new RemoteProcedureException(msg, new IllegalArgumentIOException(msg)));
        return null;
      }

      assert subproc.getState() == ProcedureState.INITIALIZING : subproc;
      subproc.setParentProcId(procedure.getProcId());
      subproc.setRootProcId(rootProcId);
      subproc.setProcId(nextProcId());
      procStack.addSubProcedure(subproc);
    }

    if (!procedure.isFailed()) {
      procedure.setChildrenLatch(subprocs.length);
      switch (procedure.getState()) {
        case RUNNABLE:
          procedure.setState(ProcedureState.WAITING);
          break;
        case WAITING_TIMEOUT:
          timeoutExecutor.add(procedure);
          break;
        default:
          break;
      }
    }
    return subprocs;
  }
Executes <code>procedure</code>
<ul>
<li>Calls the doExecute() of the procedure
<li>If the procedure execution didn't fail (i.e. valid user input)
<ul>
<li>...and returned subprocedures
<ul>
<li>The subprocedures are initialized.
<li>The subprocedures are added to the store
<li>The subprocedures are added to the runnable queue
<li>The procedure is now in a WAITING state, waiting for the subprocedures to complete
</ul>
</li>
<li>...if there are no subprocedure
<ul>
<li>the procedure completed successfully
<li>if there is a parent (WAITING)
<li>the parent state will be set to RUNNABLE
</ul>
</li>
</ul>
</li>
<li>In case of failure
<ul>
<li>The store is updated with the new state</li>
<li>The executor (caller of this method) will start the rollback of the procedure</li>
</ul>
</li>
</ul>
hbase-procedure/src/main/java/org/apache/hadoop/hbase/procedure2/ProcedureExecutor.java