http://git-wip-us.apache.org/repos/asf/hbase-site/blob/323b17d9/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.StepHook.html
----------------------------------------------------------------------
diff --git 
a/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.StepHook.html
 
b/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.StepHook.html
index 8c7d5c9..0c87f49 100644
--- 
a/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.StepHook.html
+++ 
b/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.StepHook.html
@@ -387,7 +387,7 @@
 <span class="sourceLineNo">379</span>   */<a name="line.379"></a>
 <span class="sourceLineNo">380</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.380"></a>
 <span class="sourceLineNo">381</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.381"></a>
-<span class="sourceLineNo">382</span>      final int numSteps, final boolean 
expectExecRunning) throws Exception {<a name="line.382"></a>
+<span class="sourceLineNo">382</span>      final int lastStep, final boolean 
expectExecRunning) throws Exception {<a name="line.382"></a>
 <span class="sourceLineNo">383</span>    
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.383"></a>
 <span class="sourceLineNo">384</span>    assertEquals(false, 
procExec.isRunning());<a name="line.384"></a>
 <span class="sourceLineNo">385</span><a name="line.385"></a>
@@ -405,201 +405,204 @@
 <span class="sourceLineNo">397</span>    // fix would be get all visited 
states by the procedure and then check if user speccified<a name="line.397"></a>
 <span class="sourceLineNo">398</span>    // state is in that list. Current 
assumption of sequential proregression of steps/ states is<a 
name="line.398"></a>
 <span class="sourceLineNo">399</span>    // made at multiple places so we can 
keep while condition below for simplicity.<a name="line.399"></a>
-<span class="sourceLineNo">400</span>    Procedure proc = 
procExec.getProcedure(procId);<a name="line.400"></a>
+<span class="sourceLineNo">400</span>    Procedure&lt;?&gt; proc = 
procExec.getProcedure(procId);<a name="line.400"></a>
 <span class="sourceLineNo">401</span>    int stepNum = proc instanceof 
StateMachineProcedure ?<a name="line.401"></a>
 <span class="sourceLineNo">402</span>        ((StateMachineProcedure) 
proc).getCurrentStateId() : 0;<a name="line.402"></a>
-<span class="sourceLineNo">403</span>    while (stepNum &lt; numSteps) {<a 
name="line.403"></a>
-<span class="sourceLineNo">404</span>      LOG.info("Restart " + stepNum + " 
exec state=" + proc);<a name="line.404"></a>
-<span class="sourceLineNo">405</span>      
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.405"></a>
-<span class="sourceLineNo">406</span>      
restartMasterProcedureExecutor(procExec);<a name="line.406"></a>
-<span class="sourceLineNo">407</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.407"></a>
-<span class="sourceLineNo">408</span>      // Old proc object is stale, need 
to get the new one after ProcedureExecutor restart<a name="line.408"></a>
-<span class="sourceLineNo">409</span>      proc = 
procExec.getProcedure(procId);<a name="line.409"></a>
-<span class="sourceLineNo">410</span>      stepNum = proc instanceof 
StateMachineProcedure ?<a name="line.410"></a>
-<span class="sourceLineNo">411</span>          ((StateMachineProcedure) 
proc).getCurrentStateId() : stepNum + 1;<a name="line.411"></a>
-<span class="sourceLineNo">412</span>    }<a name="line.412"></a>
-<span class="sourceLineNo">413</span><a name="line.413"></a>
-<span class="sourceLineNo">414</span>    assertEquals(expectExecRunning, 
procExec.isRunning());<a name="line.414"></a>
-<span class="sourceLineNo">415</span>  }<a name="line.415"></a>
+<span class="sourceLineNo">403</span>    for (;;) {<a name="line.403"></a>
+<span class="sourceLineNo">404</span>      if (stepNum == lastStep) {<a 
name="line.404"></a>
+<span class="sourceLineNo">405</span>        break;<a name="line.405"></a>
+<span class="sourceLineNo">406</span>      }<a name="line.406"></a>
+<span class="sourceLineNo">407</span>      LOG.info("Restart " + stepNum + " 
exec state=" + proc);<a name="line.407"></a>
+<span class="sourceLineNo">408</span>      
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.408"></a>
+<span class="sourceLineNo">409</span>      
restartMasterProcedureExecutor(procExec);<a name="line.409"></a>
+<span class="sourceLineNo">410</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.410"></a>
+<span class="sourceLineNo">411</span>      // Old proc object is stale, need 
to get the new one after ProcedureExecutor restart<a name="line.411"></a>
+<span class="sourceLineNo">412</span>      proc = 
procExec.getProcedure(procId);<a name="line.412"></a>
+<span class="sourceLineNo">413</span>      stepNum = proc instanceof 
StateMachineProcedure ?<a name="line.413"></a>
+<span class="sourceLineNo">414</span>          ((StateMachineProcedure) 
proc).getCurrentStateId() : stepNum + 1;<a name="line.414"></a>
+<span class="sourceLineNo">415</span>    }<a name="line.415"></a>
 <span class="sourceLineNo">416</span><a name="line.416"></a>
-<span class="sourceLineNo">417</span>  /**<a name="line.417"></a>
-<span class="sourceLineNo">418</span>   * Run through all procedure flow 
states TWICE while also restarting<a name="line.418"></a>
-<span class="sourceLineNo">419</span>   * procedure executor at each step; i.e 
force a reread of procedure store.<a name="line.419"></a>
-<span class="sourceLineNo">420</span>   *<a name="line.420"></a>
-<span class="sourceLineNo">421</span>   *&lt;p&gt;It does<a 
name="line.421"></a>
-<span class="sourceLineNo">422</span>   * &lt;ol&gt;&lt;li&gt;Execute step N - 
kill the executor before store update<a name="line.422"></a>
-<span class="sourceLineNo">423</span>   * &lt;li&gt;Restart executor/store<a 
name="line.423"></a>
-<span class="sourceLineNo">424</span>   * &lt;li&gt;Executes hook for each 
step twice<a name="line.424"></a>
-<span class="sourceLineNo">425</span>   * &lt;li&gt;Execute step N - and then 
save to store<a name="line.425"></a>
-<span class="sourceLineNo">426</span>   * &lt;/ol&gt;<a name="line.426"></a>
-<span class="sourceLineNo">427</span>   *<a name="line.427"></a>
-<span class="sourceLineNo">428</span>   *&lt;p&gt;This is a good test for 
finding state that needs persisting and steps that are not<a 
name="line.428"></a>
-<span class="sourceLineNo">429</span>   * idempotent. Use this version of the 
test when the order in which flow steps are executed is<a name="line.429"></a>
-<span class="sourceLineNo">430</span>   * not start to finish; where the 
procedure may vary the flow steps dependent on circumstance<a 
name="line.430"></a>
-<span class="sourceLineNo">431</span>   * found.<a name="line.431"></a>
-<span class="sourceLineNo">432</span>   * @see 
#testRecoveryAndDoubleExecution(ProcedureExecutor, long, int, boolean)<a 
name="line.432"></a>
-<span class="sourceLineNo">433</span>   */<a name="line.433"></a>
-<span class="sourceLineNo">434</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.434"></a>
-<span class="sourceLineNo">435</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId, final 
StepHook hook)<a name="line.435"></a>
-<span class="sourceLineNo">436</span>      throws Exception {<a 
name="line.436"></a>
-<span class="sourceLineNo">437</span>    
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.437"></a>
-<span class="sourceLineNo">438</span>    assertEquals(false, 
procExec.isRunning());<a name="line.438"></a>
-<span class="sourceLineNo">439</span>    for (int i = 0; 
!procExec.isFinished(procId); ++i) {<a name="line.439"></a>
-<span class="sourceLineNo">440</span>      LOG.info("Restart " + i + " exec 
state=" + procExec.getProcedure(procId));<a name="line.440"></a>
-<span class="sourceLineNo">441</span>      if (hook != null) {<a 
name="line.441"></a>
-<span class="sourceLineNo">442</span>        assertTrue(hook.execute(i));<a 
name="line.442"></a>
-<span class="sourceLineNo">443</span>      }<a name="line.443"></a>
-<span class="sourceLineNo">444</span>      
restartMasterProcedureExecutor(procExec);<a name="line.444"></a>
-<span class="sourceLineNo">445</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    }<a name="line.446"></a>
-<span class="sourceLineNo">447</span>    assertEquals(true, 
procExec.isRunning());<a name="line.447"></a>
-<span class="sourceLineNo">448</span>    
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);<a 
name="line.448"></a>
-<span class="sourceLineNo">449</span>  }<a name="line.449"></a>
-<span class="sourceLineNo">450</span><a name="line.450"></a>
-<span class="sourceLineNo">451</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.451"></a>
-<span class="sourceLineNo">452</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId) throws 
Exception {<a name="line.452"></a>
-<span class="sourceLineNo">453</span>    
testRecoveryAndDoubleExecution(procExec, procId, null);<a name="line.453"></a>
-<span class="sourceLineNo">454</span>  }<a name="line.454"></a>
-<span class="sourceLineNo">455</span><a name="line.455"></a>
-<span class="sourceLineNo">456</span>  /**<a name="line.456"></a>
-<span class="sourceLineNo">457</span>   * Hook which will be executed on each 
step<a name="line.457"></a>
-<span class="sourceLineNo">458</span>   */<a name="line.458"></a>
-<span class="sourceLineNo">459</span>  public interface StepHook{<a 
name="line.459"></a>
-<span class="sourceLineNo">460</span>    /**<a name="line.460"></a>
-<span class="sourceLineNo">461</span>     * @param step Step no. at which this 
will be executed<a name="line.461"></a>
-<span class="sourceLineNo">462</span>     * @return false if test should fail 
otherwise true<a name="line.462"></a>
-<span class="sourceLineNo">463</span>     * @throws IOException<a 
name="line.463"></a>
-<span class="sourceLineNo">464</span>     */<a name="line.464"></a>
-<span class="sourceLineNo">465</span>    boolean execute(int step) throws 
IOException;<a name="line.465"></a>
-<span class="sourceLineNo">466</span>  }<a name="line.466"></a>
-<span class="sourceLineNo">467</span><a name="line.467"></a>
-<span class="sourceLineNo">468</span>  /**<a name="line.468"></a>
-<span class="sourceLineNo">469</span>   * Execute the procedure up to 
"lastStep" and then the ProcedureExecutor<a name="line.469"></a>
-<span class="sourceLineNo">470</span>   * is restarted and an abort() is 
injected.<a name="line.470"></a>
-<span class="sourceLineNo">471</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.471"></a>
-<span class="sourceLineNo">472</span>   * Each rollback step is called twice, 
by restarting the executor after every step.<a name="line.472"></a>
-<span class="sourceLineNo">473</span>   * At the end of this call the 
procedure should be finished and rolledback.<a name="line.473"></a>
-<span class="sourceLineNo">474</span>   * This method assert on the procedure 
being terminated with an AbortException.<a name="line.474"></a>
-<span class="sourceLineNo">475</span>   */<a name="line.475"></a>
-<span class="sourceLineNo">476</span>  public static void 
testRollbackAndDoubleExecution(<a name="line.476"></a>
-<span class="sourceLineNo">477</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.477"></a>
-<span class="sourceLineNo">478</span>      final int lastStep) throws 
Exception {<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    
testRollbackAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.479"></a>
-<span class="sourceLineNo">480</span>  }<a name="line.480"></a>
-<span class="sourceLineNo">481</span><a name="line.481"></a>
-<span class="sourceLineNo">482</span>  public static void 
testRollbackAndDoubleExecution(<a name="line.482"></a>
-<span class="sourceLineNo">483</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.483"></a>
-<span class="sourceLineNo">484</span>      final int lastStep, boolean 
waitForAsyncProcs) throws Exception {<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    // Execute up to last step<a 
name="line.485"></a>
-<span class="sourceLineNo">486</span>    
testRecoveryAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.486"></a>
-<span class="sourceLineNo">487</span><a name="line.487"></a>
-<span class="sourceLineNo">488</span>    // Restart the executor and rollback 
the step twice<a name="line.488"></a>
-<span class="sourceLineNo">489</span>    //   rollback step N - kill before 
store update<a name="line.489"></a>
-<span class="sourceLineNo">490</span>    //   restart executor/store<a 
name="line.490"></a>
-<span class="sourceLineNo">491</span>    //   rollback step N - save on 
store<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    InjectAbortOnLoadListener 
abortListener = new InjectAbortOnLoadListener(procExec);<a name="line.492"></a>
-<span class="sourceLineNo">493</span>    abortListener.addProcId(procId);<a 
name="line.493"></a>
-<span class="sourceLineNo">494</span>    
procExec.registerListener(abortListener);<a name="line.494"></a>
-<span class="sourceLineNo">495</span>    try {<a name="line.495"></a>
-<span class="sourceLineNo">496</span>      for (int i = 0; 
!procExec.isFinished(procId); ++i) {<a name="line.496"></a>
-<span class="sourceLineNo">497</span>        LOG.info("Restart " + i + " 
rollback state: " + procExec.getProcedure(procId));<a name="line.497"></a>
-<span class="sourceLineNo">498</span>        
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.498"></a>
-<span class="sourceLineNo">499</span>        
restartMasterProcedureExecutor(procExec);<a name="line.499"></a>
-<span class="sourceLineNo">500</span>        
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.500"></a>
-<span class="sourceLineNo">501</span>      }<a name="line.501"></a>
-<span class="sourceLineNo">502</span>    } finally {<a name="line.502"></a>
-<span class="sourceLineNo">503</span>      
assertTrue(procExec.unregisterListener(abortListener));<a name="line.503"></a>
-<span class="sourceLineNo">504</span>    }<a name="line.504"></a>
-<span class="sourceLineNo">505</span><a name="line.505"></a>
-<span class="sourceLineNo">506</span>    if (waitForAsyncProcs) {<a 
name="line.506"></a>
-<span class="sourceLineNo">507</span>      // Sometimes there are other 
procedures still executing (including asynchronously spawned by<a 
name="line.507"></a>
-<span class="sourceLineNo">508</span>      // procId) and due to 
KillAndToggleBeforeStoreUpdate flag ProcedureExecutor is stopped before<a 
name="line.508"></a>
-<span class="sourceLineNo">509</span>      // store update. Let all pending 
procedures finish normally.<a name="line.509"></a>
-<span class="sourceLineNo">510</span>      if (!procExec.isRunning()) {<a 
name="line.510"></a>
-<span class="sourceLineNo">511</span>        LOG.warn("ProcedureExecutor not 
running, may have been stopped by pending procedure due to"<a 
name="line.511"></a>
-<span class="sourceLineNo">512</span>            + " 
KillAndToggleBeforeStoreUpdate flag.");<a name="line.512"></a>
-<span class="sourceLineNo">513</span>        
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);<a 
name="line.513"></a>
-<span class="sourceLineNo">514</span>        
restartMasterProcedureExecutor(procExec);<a name="line.514"></a>
-<span class="sourceLineNo">515</span>        
ProcedureTestingUtility.waitNoProcedureRunning(procExec);<a name="line.515"></a>
-<span class="sourceLineNo">516</span>      }<a name="line.516"></a>
-<span class="sourceLineNo">517</span>    }<a name="line.517"></a>
-<span class="sourceLineNo">518</span><a name="line.518"></a>
-<span class="sourceLineNo">519</span>    assertEquals(true, 
procExec.isRunning());<a name="line.519"></a>
-<span class="sourceLineNo">520</span>    
ProcedureTestingUtility.assertIsAbortException(procExec.getResult(procId));<a 
name="line.520"></a>
-<span class="sourceLineNo">521</span>  }<a name="line.521"></a>
-<span class="sourceLineNo">522</span><a name="line.522"></a>
-<span class="sourceLineNo">523</span>  /**<a name="line.523"></a>
-<span class="sourceLineNo">524</span>   * Execute the procedure up to 
"lastStep" and then the ProcedureExecutor<a name="line.524"></a>
-<span class="sourceLineNo">525</span>   * is restarted and an abort() is 
injected.<a name="line.525"></a>
-<span class="sourceLineNo">526</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.526"></a>
-<span class="sourceLineNo">527</span>   * At the end of this call the 
procedure should be finished and rolledback.<a name="line.527"></a>
-<span class="sourceLineNo">528</span>   * This method assert on the procedure 
being terminated with an AbortException.<a name="line.528"></a>
-<span class="sourceLineNo">529</span>   */<a name="line.529"></a>
-<span class="sourceLineNo">530</span>  public static void 
testRollbackRetriableFailure(<a name="line.530"></a>
-<span class="sourceLineNo">531</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.531"></a>
-<span class="sourceLineNo">532</span>      final int lastStep) throws 
Exception {<a name="line.532"></a>
-<span class="sourceLineNo">533</span>    // Execute up to last step<a 
name="line.533"></a>
-<span class="sourceLineNo">534</span>    
testRecoveryAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.534"></a>
-<span class="sourceLineNo">535</span><a name="line.535"></a>
-<span class="sourceLineNo">536</span>    // execute the rollback<a 
name="line.536"></a>
-<span class="sourceLineNo">537</span>    testRestartWithAbort(procExec, 
procId);<a name="line.537"></a>
+<span class="sourceLineNo">417</span>    assertEquals(expectExecRunning, 
procExec.isRunning());<a name="line.417"></a>
+<span class="sourceLineNo">418</span>  }<a name="line.418"></a>
+<span class="sourceLineNo">419</span><a name="line.419"></a>
+<span class="sourceLineNo">420</span>  /**<a name="line.420"></a>
+<span class="sourceLineNo">421</span>   * Run through all procedure flow 
states TWICE while also restarting<a name="line.421"></a>
+<span class="sourceLineNo">422</span>   * procedure executor at each step; i.e 
force a reread of procedure store.<a name="line.422"></a>
+<span class="sourceLineNo">423</span>   *<a name="line.423"></a>
+<span class="sourceLineNo">424</span>   *&lt;p&gt;It does<a 
name="line.424"></a>
+<span class="sourceLineNo">425</span>   * &lt;ol&gt;&lt;li&gt;Execute step N - 
kill the executor before store update<a name="line.425"></a>
+<span class="sourceLineNo">426</span>   * &lt;li&gt;Restart executor/store<a 
name="line.426"></a>
+<span class="sourceLineNo">427</span>   * &lt;li&gt;Executes hook for each 
step twice<a name="line.427"></a>
+<span class="sourceLineNo">428</span>   * &lt;li&gt;Execute step N - and then 
save to store<a name="line.428"></a>
+<span class="sourceLineNo">429</span>   * &lt;/ol&gt;<a name="line.429"></a>
+<span class="sourceLineNo">430</span>   *<a name="line.430"></a>
+<span class="sourceLineNo">431</span>   *&lt;p&gt;This is a good test for 
finding state that needs persisting and steps that are not<a 
name="line.431"></a>
+<span class="sourceLineNo">432</span>   * idempotent. Use this version of the 
test when the order in which flow steps are executed is<a name="line.432"></a>
+<span class="sourceLineNo">433</span>   * not start to finish; where the 
procedure may vary the flow steps dependent on circumstance<a 
name="line.433"></a>
+<span class="sourceLineNo">434</span>   * found.<a name="line.434"></a>
+<span class="sourceLineNo">435</span>   * @see 
#testRecoveryAndDoubleExecution(ProcedureExecutor, long, int, boolean)<a 
name="line.435"></a>
+<span class="sourceLineNo">436</span>   */<a name="line.436"></a>
+<span class="sourceLineNo">437</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.437"></a>
+<span class="sourceLineNo">438</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId, final 
StepHook hook)<a name="line.438"></a>
+<span class="sourceLineNo">439</span>      throws Exception {<a 
name="line.439"></a>
+<span class="sourceLineNo">440</span>    
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.440"></a>
+<span class="sourceLineNo">441</span>    assertEquals(false, 
procExec.isRunning());<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    for (int i = 0; 
!procExec.isFinished(procId); ++i) {<a name="line.442"></a>
+<span class="sourceLineNo">443</span>      LOG.info("Restart " + i + " exec 
state=" + procExec.getProcedure(procId));<a name="line.443"></a>
+<span class="sourceLineNo">444</span>      if (hook != null) {<a 
name="line.444"></a>
+<span class="sourceLineNo">445</span>        assertTrue(hook.execute(i));<a 
name="line.445"></a>
+<span class="sourceLineNo">446</span>      }<a name="line.446"></a>
+<span class="sourceLineNo">447</span>      
restartMasterProcedureExecutor(procExec);<a name="line.447"></a>
+<span class="sourceLineNo">448</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.448"></a>
+<span class="sourceLineNo">449</span>    }<a name="line.449"></a>
+<span class="sourceLineNo">450</span>    assertEquals(true, 
procExec.isRunning());<a name="line.450"></a>
+<span class="sourceLineNo">451</span>    
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);<a 
name="line.451"></a>
+<span class="sourceLineNo">452</span>  }<a name="line.452"></a>
+<span class="sourceLineNo">453</span><a name="line.453"></a>
+<span class="sourceLineNo">454</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.454"></a>
+<span class="sourceLineNo">455</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId) throws 
Exception {<a name="line.455"></a>
+<span class="sourceLineNo">456</span>    
testRecoveryAndDoubleExecution(procExec, procId, null);<a name="line.456"></a>
+<span class="sourceLineNo">457</span>  }<a name="line.457"></a>
+<span class="sourceLineNo">458</span><a name="line.458"></a>
+<span class="sourceLineNo">459</span>  /**<a name="line.459"></a>
+<span class="sourceLineNo">460</span>   * Hook which will be executed on each 
step<a name="line.460"></a>
+<span class="sourceLineNo">461</span>   */<a name="line.461"></a>
+<span class="sourceLineNo">462</span>  public interface StepHook{<a 
name="line.462"></a>
+<span class="sourceLineNo">463</span>    /**<a name="line.463"></a>
+<span class="sourceLineNo">464</span>     * @param step Step no. at which this 
will be executed<a name="line.464"></a>
+<span class="sourceLineNo">465</span>     * @return false if test should fail 
otherwise true<a name="line.465"></a>
+<span class="sourceLineNo">466</span>     * @throws IOException<a 
name="line.466"></a>
+<span class="sourceLineNo">467</span>     */<a name="line.467"></a>
+<span class="sourceLineNo">468</span>    boolean execute(int step) throws 
IOException;<a name="line.468"></a>
+<span class="sourceLineNo">469</span>  }<a name="line.469"></a>
+<span class="sourceLineNo">470</span><a name="line.470"></a>
+<span class="sourceLineNo">471</span>  /**<a name="line.471"></a>
+<span class="sourceLineNo">472</span>   * Execute the procedure up to 
"lastStep" and then the ProcedureExecutor<a name="line.472"></a>
+<span class="sourceLineNo">473</span>   * is restarted and an abort() is 
injected.<a name="line.473"></a>
+<span class="sourceLineNo">474</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.474"></a>
+<span class="sourceLineNo">475</span>   * Each rollback step is called twice, 
by restarting the executor after every step.<a name="line.475"></a>
+<span class="sourceLineNo">476</span>   * At the end of this call the 
procedure should be finished and rolledback.<a name="line.476"></a>
+<span class="sourceLineNo">477</span>   * This method assert on the procedure 
being terminated with an AbortException.<a name="line.477"></a>
+<span class="sourceLineNo">478</span>   */<a name="line.478"></a>
+<span class="sourceLineNo">479</span>  public static void 
testRollbackAndDoubleExecution(<a name="line.479"></a>
+<span class="sourceLineNo">480</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.480"></a>
+<span class="sourceLineNo">481</span>      final int lastStep) throws 
Exception {<a name="line.481"></a>
+<span class="sourceLineNo">482</span>    
testRollbackAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.482"></a>
+<span class="sourceLineNo">483</span>  }<a name="line.483"></a>
+<span class="sourceLineNo">484</span><a name="line.484"></a>
+<span class="sourceLineNo">485</span>  public static void 
testRollbackAndDoubleExecution(<a name="line.485"></a>
+<span class="sourceLineNo">486</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.486"></a>
+<span class="sourceLineNo">487</span>      final int lastStep, boolean 
waitForAsyncProcs) throws Exception {<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    // Execute up to last step<a 
name="line.488"></a>
+<span class="sourceLineNo">489</span>    
testRecoveryAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.489"></a>
+<span class="sourceLineNo">490</span><a name="line.490"></a>
+<span class="sourceLineNo">491</span>    // Restart the executor and rollback 
the step twice<a name="line.491"></a>
+<span class="sourceLineNo">492</span>    //   rollback step N - kill before 
store update<a name="line.492"></a>
+<span class="sourceLineNo">493</span>    //   restart executor/store<a 
name="line.493"></a>
+<span class="sourceLineNo">494</span>    //   rollback step N - save on 
store<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    InjectAbortOnLoadListener 
abortListener = new InjectAbortOnLoadListener(procExec);<a name="line.495"></a>
+<span class="sourceLineNo">496</span>    abortListener.addProcId(procId);<a 
name="line.496"></a>
+<span class="sourceLineNo">497</span>    
procExec.registerListener(abortListener);<a name="line.497"></a>
+<span class="sourceLineNo">498</span>    try {<a name="line.498"></a>
+<span class="sourceLineNo">499</span>      for (int i = 0; 
!procExec.isFinished(procId); ++i) {<a name="line.499"></a>
+<span class="sourceLineNo">500</span>        LOG.info("Restart " + i + " 
rollback state: " + procExec.getProcedure(procId));<a name="line.500"></a>
+<span class="sourceLineNo">501</span>        
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.501"></a>
+<span class="sourceLineNo">502</span>        
restartMasterProcedureExecutor(procExec);<a name="line.502"></a>
+<span class="sourceLineNo">503</span>        
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.503"></a>
+<span class="sourceLineNo">504</span>      }<a name="line.504"></a>
+<span class="sourceLineNo">505</span>    } finally {<a name="line.505"></a>
+<span class="sourceLineNo">506</span>      
assertTrue(procExec.unregisterListener(abortListener));<a name="line.506"></a>
+<span class="sourceLineNo">507</span>    }<a name="line.507"></a>
+<span class="sourceLineNo">508</span><a name="line.508"></a>
+<span class="sourceLineNo">509</span>    if (waitForAsyncProcs) {<a 
name="line.509"></a>
+<span class="sourceLineNo">510</span>      // Sometimes there are other 
procedures still executing (including asynchronously spawned by<a 
name="line.510"></a>
+<span class="sourceLineNo">511</span>      // procId) and due to 
KillAndToggleBeforeStoreUpdate flag ProcedureExecutor is stopped before<a 
name="line.511"></a>
+<span class="sourceLineNo">512</span>      // store update. Let all pending 
procedures finish normally.<a name="line.512"></a>
+<span class="sourceLineNo">513</span>      if (!procExec.isRunning()) {<a 
name="line.513"></a>
+<span class="sourceLineNo">514</span>        LOG.warn("ProcedureExecutor not 
running, may have been stopped by pending procedure due to"<a 
name="line.514"></a>
+<span class="sourceLineNo">515</span>            + " 
KillAndToggleBeforeStoreUpdate flag.");<a name="line.515"></a>
+<span class="sourceLineNo">516</span>        
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);<a 
name="line.516"></a>
+<span class="sourceLineNo">517</span>        
restartMasterProcedureExecutor(procExec);<a name="line.517"></a>
+<span class="sourceLineNo">518</span>        
ProcedureTestingUtility.waitNoProcedureRunning(procExec);<a name="line.518"></a>
+<span class="sourceLineNo">519</span>      }<a name="line.519"></a>
+<span class="sourceLineNo">520</span>    }<a name="line.520"></a>
+<span class="sourceLineNo">521</span><a name="line.521"></a>
+<span class="sourceLineNo">522</span>    assertEquals(true, 
procExec.isRunning());<a name="line.522"></a>
+<span class="sourceLineNo">523</span>    
ProcedureTestingUtility.assertIsAbortException(procExec.getResult(procId));<a 
name="line.523"></a>
+<span class="sourceLineNo">524</span>  }<a name="line.524"></a>
+<span class="sourceLineNo">525</span><a name="line.525"></a>
+<span class="sourceLineNo">526</span>  /**<a name="line.526"></a>
+<span class="sourceLineNo">527</span>   * Execute the procedure up to 
"lastStep" and then the ProcedureExecutor<a name="line.527"></a>
+<span class="sourceLineNo">528</span>   * is restarted and an abort() is 
injected.<a name="line.528"></a>
+<span class="sourceLineNo">529</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.529"></a>
+<span class="sourceLineNo">530</span>   * At the end of this call the 
procedure should be finished and rolledback.<a name="line.530"></a>
+<span class="sourceLineNo">531</span>   * This method assert on the procedure 
being terminated with an AbortException.<a name="line.531"></a>
+<span class="sourceLineNo">532</span>   */<a name="line.532"></a>
+<span class="sourceLineNo">533</span>  public static void 
testRollbackRetriableFailure(<a name="line.533"></a>
+<span class="sourceLineNo">534</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.534"></a>
+<span class="sourceLineNo">535</span>      final int lastStep) throws 
Exception {<a name="line.535"></a>
+<span class="sourceLineNo">536</span>    // Execute up to last step<a 
name="line.536"></a>
+<span class="sourceLineNo">537</span>    
testRecoveryAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.537"></a>
 <span class="sourceLineNo">538</span><a name="line.538"></a>
-<span class="sourceLineNo">539</span>    assertEquals(true, 
procExec.isRunning());<a name="line.539"></a>
-<span class="sourceLineNo">540</span>    
ProcedureTestingUtility.assertIsAbortException(procExec.getResult(procId));<a 
name="line.540"></a>
-<span class="sourceLineNo">541</span>  }<a name="line.541"></a>
-<span class="sourceLineNo">542</span><a name="line.542"></a>
-<span class="sourceLineNo">543</span>  /**<a name="line.543"></a>
-<span class="sourceLineNo">544</span>   * Restart the ProcedureExecutor and 
inject an abort to the specified procedure.<a name="line.544"></a>
-<span class="sourceLineNo">545</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.545"></a>
-<span class="sourceLineNo">546</span>   * At the end of this call the 
procedure should be finished and rolledback, if abort is implemnted<a 
name="line.546"></a>
-<span class="sourceLineNo">547</span>   */<a name="line.547"></a>
-<span class="sourceLineNo">548</span>  public static void 
testRestartWithAbort(ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec,<a 
name="line.548"></a>
-<span class="sourceLineNo">549</span>      long procId) throws Exception {<a 
name="line.549"></a>
-<span class="sourceLineNo">550</span>    
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);<a 
name="line.550"></a>
-<span class="sourceLineNo">551</span>    InjectAbortOnLoadListener 
abortListener = new InjectAbortOnLoadListener(procExec);<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    abortListener.addProcId(procId);<a 
name="line.552"></a>
-<span class="sourceLineNo">553</span>    
procExec.registerListener(abortListener);<a name="line.553"></a>
-<span class="sourceLineNo">554</span>    try {<a name="line.554"></a>
-<span class="sourceLineNo">555</span>      
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.555"></a>
-<span class="sourceLineNo">556</span>      LOG.info("Restart and rollback 
procId=" + procId);<a name="line.556"></a>
-<span class="sourceLineNo">557</span>      
restartMasterProcedureExecutor(procExec);<a name="line.557"></a>
-<span class="sourceLineNo">558</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.558"></a>
-<span class="sourceLineNo">559</span>    } finally {<a name="line.559"></a>
-<span class="sourceLineNo">560</span>      
assertTrue(procExec.unregisterListener(abortListener));<a name="line.560"></a>
-<span class="sourceLineNo">561</span>    }<a name="line.561"></a>
-<span class="sourceLineNo">562</span>  }<a name="line.562"></a>
-<span class="sourceLineNo">563</span><a name="line.563"></a>
-<span class="sourceLineNo">564</span>  public static class 
InjectAbortOnLoadListener<a name="line.564"></a>
-<span class="sourceLineNo">565</span>      implements 
ProcedureExecutor.ProcedureExecutorListener {<a name="line.565"></a>
-<span class="sourceLineNo">566</span>    private final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec;<a name="line.566"></a>
-<span class="sourceLineNo">567</span>    private TreeSet&lt;Long&gt; 
procsToAbort = null;<a name="line.567"></a>
-<span class="sourceLineNo">568</span><a name="line.568"></a>
-<span class="sourceLineNo">569</span>    public 
InjectAbortOnLoadListener(final ProcedureExecutor&lt;MasterProcedureEnv&gt; 
procExec) {<a name="line.569"></a>
-<span class="sourceLineNo">570</span>      this.procExec = procExec;<a 
name="line.570"></a>
-<span class="sourceLineNo">571</span>    }<a name="line.571"></a>
-<span class="sourceLineNo">572</span><a name="line.572"></a>
-<span class="sourceLineNo">573</span>    public void addProcId(long procId) 
{<a name="line.573"></a>
-<span class="sourceLineNo">574</span>      if (procsToAbort == null) {<a 
name="line.574"></a>
-<span class="sourceLineNo">575</span>        procsToAbort = new 
TreeSet&lt;&gt;();<a name="line.575"></a>
-<span class="sourceLineNo">576</span>      }<a name="line.576"></a>
-<span class="sourceLineNo">577</span>      procsToAbort.add(procId);<a 
name="line.577"></a>
-<span class="sourceLineNo">578</span>    }<a name="line.578"></a>
-<span class="sourceLineNo">579</span><a name="line.579"></a>
-<span class="sourceLineNo">580</span>    @Override<a name="line.580"></a>
-<span class="sourceLineNo">581</span>    public void procedureLoaded(long 
procId) {<a name="line.581"></a>
-<span class="sourceLineNo">582</span>      if (procsToAbort != null &amp;&amp; 
!procsToAbort.contains(procId)) {<a name="line.582"></a>
-<span class="sourceLineNo">583</span>        return;<a name="line.583"></a>
-<span class="sourceLineNo">584</span>      }<a name="line.584"></a>
-<span class="sourceLineNo">585</span>      procExec.abort(procId);<a 
name="line.585"></a>
-<span class="sourceLineNo">586</span>    }<a name="line.586"></a>
-<span class="sourceLineNo">587</span><a name="line.587"></a>
-<span class="sourceLineNo">588</span>    @Override<a name="line.588"></a>
-<span class="sourceLineNo">589</span>    public void procedureAdded(long 
procId) { /* no-op */ }<a name="line.589"></a>
+<span class="sourceLineNo">539</span>    // execute the rollback<a 
name="line.539"></a>
+<span class="sourceLineNo">540</span>    testRestartWithAbort(procExec, 
procId);<a name="line.540"></a>
+<span class="sourceLineNo">541</span><a name="line.541"></a>
+<span class="sourceLineNo">542</span>    assertEquals(true, 
procExec.isRunning());<a name="line.542"></a>
+<span class="sourceLineNo">543</span>    
ProcedureTestingUtility.assertIsAbortException(procExec.getResult(procId));<a 
name="line.543"></a>
+<span class="sourceLineNo">544</span>  }<a name="line.544"></a>
+<span class="sourceLineNo">545</span><a name="line.545"></a>
+<span class="sourceLineNo">546</span>  /**<a name="line.546"></a>
+<span class="sourceLineNo">547</span>   * Restart the ProcedureExecutor and 
inject an abort to the specified procedure.<a name="line.547"></a>
+<span class="sourceLineNo">548</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.548"></a>
+<span class="sourceLineNo">549</span>   * At the end of this call the 
procedure should be finished and rolledback, if abort is implemnted<a 
name="line.549"></a>
+<span class="sourceLineNo">550</span>   */<a name="line.550"></a>
+<span class="sourceLineNo">551</span>  public static void 
testRestartWithAbort(ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec,<a 
name="line.551"></a>
+<span class="sourceLineNo">552</span>      long procId) throws Exception {<a 
name="line.552"></a>
+<span class="sourceLineNo">553</span>    
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);<a 
name="line.553"></a>
+<span class="sourceLineNo">554</span>    InjectAbortOnLoadListener 
abortListener = new InjectAbortOnLoadListener(procExec);<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    abortListener.addProcId(procId);<a 
name="line.555"></a>
+<span class="sourceLineNo">556</span>    
procExec.registerListener(abortListener);<a name="line.556"></a>
+<span class="sourceLineNo">557</span>    try {<a name="line.557"></a>
+<span class="sourceLineNo">558</span>      
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.558"></a>
+<span class="sourceLineNo">559</span>      LOG.info("Restart and rollback 
procId=" + procId);<a name="line.559"></a>
+<span class="sourceLineNo">560</span>      
restartMasterProcedureExecutor(procExec);<a name="line.560"></a>
+<span class="sourceLineNo">561</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.561"></a>
+<span class="sourceLineNo">562</span>    } finally {<a name="line.562"></a>
+<span class="sourceLineNo">563</span>      
assertTrue(procExec.unregisterListener(abortListener));<a name="line.563"></a>
+<span class="sourceLineNo">564</span>    }<a name="line.564"></a>
+<span class="sourceLineNo">565</span>  }<a name="line.565"></a>
+<span class="sourceLineNo">566</span><a name="line.566"></a>
+<span class="sourceLineNo">567</span>  public static class 
InjectAbortOnLoadListener<a name="line.567"></a>
+<span class="sourceLineNo">568</span>      implements 
ProcedureExecutor.ProcedureExecutorListener {<a name="line.568"></a>
+<span class="sourceLineNo">569</span>    private final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec;<a name="line.569"></a>
+<span class="sourceLineNo">570</span>    private TreeSet&lt;Long&gt; 
procsToAbort = null;<a name="line.570"></a>
+<span class="sourceLineNo">571</span><a name="line.571"></a>
+<span class="sourceLineNo">572</span>    public 
InjectAbortOnLoadListener(final ProcedureExecutor&lt;MasterProcedureEnv&gt; 
procExec) {<a name="line.572"></a>
+<span class="sourceLineNo">573</span>      this.procExec = procExec;<a 
name="line.573"></a>
+<span class="sourceLineNo">574</span>    }<a name="line.574"></a>
+<span class="sourceLineNo">575</span><a name="line.575"></a>
+<span class="sourceLineNo">576</span>    public void addProcId(long procId) 
{<a name="line.576"></a>
+<span class="sourceLineNo">577</span>      if (procsToAbort == null) {<a 
name="line.577"></a>
+<span class="sourceLineNo">578</span>        procsToAbort = new 
TreeSet&lt;&gt;();<a name="line.578"></a>
+<span class="sourceLineNo">579</span>      }<a name="line.579"></a>
+<span class="sourceLineNo">580</span>      procsToAbort.add(procId);<a 
name="line.580"></a>
+<span class="sourceLineNo">581</span>    }<a name="line.581"></a>
+<span class="sourceLineNo">582</span><a name="line.582"></a>
+<span class="sourceLineNo">583</span>    @Override<a name="line.583"></a>
+<span class="sourceLineNo">584</span>    public void procedureLoaded(long 
procId) {<a name="line.584"></a>
+<span class="sourceLineNo">585</span>      if (procsToAbort != null &amp;&amp; 
!procsToAbort.contains(procId)) {<a name="line.585"></a>
+<span class="sourceLineNo">586</span>        return;<a name="line.586"></a>
+<span class="sourceLineNo">587</span>      }<a name="line.587"></a>
+<span class="sourceLineNo">588</span>      procExec.abort(procId);<a 
name="line.588"></a>
+<span class="sourceLineNo">589</span>    }<a name="line.589"></a>
 <span class="sourceLineNo">590</span><a name="line.590"></a>
 <span class="sourceLineNo">591</span>    @Override<a name="line.591"></a>
-<span class="sourceLineNo">592</span>    public void procedureFinished(long 
procId) { /* no-op */ }<a name="line.592"></a>
-<span class="sourceLineNo">593</span>  }<a name="line.593"></a>
-<span class="sourceLineNo">594</span>}<a name="line.594"></a>
+<span class="sourceLineNo">592</span>    public void procedureAdded(long 
procId) { /* no-op */ }<a name="line.592"></a>
+<span class="sourceLineNo">593</span><a name="line.593"></a>
+<span class="sourceLineNo">594</span>    @Override<a name="line.594"></a>
+<span class="sourceLineNo">595</span>    public void procedureFinished(long 
procId) { /* no-op */ }<a name="line.595"></a>
+<span class="sourceLineNo">596</span>  }<a name="line.596"></a>
+<span class="sourceLineNo">597</span>}<a name="line.597"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/323b17d9/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.html
----------------------------------------------------------------------
diff --git 
a/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.html
 
b/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.html
index 8c7d5c9..0c87f49 100644
--- 
a/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.html
+++ 
b/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/MasterProcedureTestingUtility.html
@@ -387,7 +387,7 @@
 <span class="sourceLineNo">379</span>   */<a name="line.379"></a>
 <span class="sourceLineNo">380</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.380"></a>
 <span class="sourceLineNo">381</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.381"></a>
-<span class="sourceLineNo">382</span>      final int numSteps, final boolean 
expectExecRunning) throws Exception {<a name="line.382"></a>
+<span class="sourceLineNo">382</span>      final int lastStep, final boolean 
expectExecRunning) throws Exception {<a name="line.382"></a>
 <span class="sourceLineNo">383</span>    
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.383"></a>
 <span class="sourceLineNo">384</span>    assertEquals(false, 
procExec.isRunning());<a name="line.384"></a>
 <span class="sourceLineNo">385</span><a name="line.385"></a>
@@ -405,201 +405,204 @@
 <span class="sourceLineNo">397</span>    // fix would be get all visited 
states by the procedure and then check if user speccified<a name="line.397"></a>
 <span class="sourceLineNo">398</span>    // state is in that list. Current 
assumption of sequential proregression of steps/ states is<a 
name="line.398"></a>
 <span class="sourceLineNo">399</span>    // made at multiple places so we can 
keep while condition below for simplicity.<a name="line.399"></a>
-<span class="sourceLineNo">400</span>    Procedure proc = 
procExec.getProcedure(procId);<a name="line.400"></a>
+<span class="sourceLineNo">400</span>    Procedure&lt;?&gt; proc = 
procExec.getProcedure(procId);<a name="line.400"></a>
 <span class="sourceLineNo">401</span>    int stepNum = proc instanceof 
StateMachineProcedure ?<a name="line.401"></a>
 <span class="sourceLineNo">402</span>        ((StateMachineProcedure) 
proc).getCurrentStateId() : 0;<a name="line.402"></a>
-<span class="sourceLineNo">403</span>    while (stepNum &lt; numSteps) {<a 
name="line.403"></a>
-<span class="sourceLineNo">404</span>      LOG.info("Restart " + stepNum + " 
exec state=" + proc);<a name="line.404"></a>
-<span class="sourceLineNo">405</span>      
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.405"></a>
-<span class="sourceLineNo">406</span>      
restartMasterProcedureExecutor(procExec);<a name="line.406"></a>
-<span class="sourceLineNo">407</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.407"></a>
-<span class="sourceLineNo">408</span>      // Old proc object is stale, need 
to get the new one after ProcedureExecutor restart<a name="line.408"></a>
-<span class="sourceLineNo">409</span>      proc = 
procExec.getProcedure(procId);<a name="line.409"></a>
-<span class="sourceLineNo">410</span>      stepNum = proc instanceof 
StateMachineProcedure ?<a name="line.410"></a>
-<span class="sourceLineNo">411</span>          ((StateMachineProcedure) 
proc).getCurrentStateId() : stepNum + 1;<a name="line.411"></a>
-<span class="sourceLineNo">412</span>    }<a name="line.412"></a>
-<span class="sourceLineNo">413</span><a name="line.413"></a>
-<span class="sourceLineNo">414</span>    assertEquals(expectExecRunning, 
procExec.isRunning());<a name="line.414"></a>
-<span class="sourceLineNo">415</span>  }<a name="line.415"></a>
+<span class="sourceLineNo">403</span>    for (;;) {<a name="line.403"></a>
+<span class="sourceLineNo">404</span>      if (stepNum == lastStep) {<a 
name="line.404"></a>
+<span class="sourceLineNo">405</span>        break;<a name="line.405"></a>
+<span class="sourceLineNo">406</span>      }<a name="line.406"></a>
+<span class="sourceLineNo">407</span>      LOG.info("Restart " + stepNum + " 
exec state=" + proc);<a name="line.407"></a>
+<span class="sourceLineNo">408</span>      
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.408"></a>
+<span class="sourceLineNo">409</span>      
restartMasterProcedureExecutor(procExec);<a name="line.409"></a>
+<span class="sourceLineNo">410</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.410"></a>
+<span class="sourceLineNo">411</span>      // Old proc object is stale, need 
to get the new one after ProcedureExecutor restart<a name="line.411"></a>
+<span class="sourceLineNo">412</span>      proc = 
procExec.getProcedure(procId);<a name="line.412"></a>
+<span class="sourceLineNo">413</span>      stepNum = proc instanceof 
StateMachineProcedure ?<a name="line.413"></a>
+<span class="sourceLineNo">414</span>          ((StateMachineProcedure) 
proc).getCurrentStateId() : stepNum + 1;<a name="line.414"></a>
+<span class="sourceLineNo">415</span>    }<a name="line.415"></a>
 <span class="sourceLineNo">416</span><a name="line.416"></a>
-<span class="sourceLineNo">417</span>  /**<a name="line.417"></a>
-<span class="sourceLineNo">418</span>   * Run through all procedure flow 
states TWICE while also restarting<a name="line.418"></a>
-<span class="sourceLineNo">419</span>   * procedure executor at each step; i.e 
force a reread of procedure store.<a name="line.419"></a>
-<span class="sourceLineNo">420</span>   *<a name="line.420"></a>
-<span class="sourceLineNo">421</span>   *&lt;p&gt;It does<a 
name="line.421"></a>
-<span class="sourceLineNo">422</span>   * &lt;ol&gt;&lt;li&gt;Execute step N - 
kill the executor before store update<a name="line.422"></a>
-<span class="sourceLineNo">423</span>   * &lt;li&gt;Restart executor/store<a 
name="line.423"></a>
-<span class="sourceLineNo">424</span>   * &lt;li&gt;Executes hook for each 
step twice<a name="line.424"></a>
-<span class="sourceLineNo">425</span>   * &lt;li&gt;Execute step N - and then 
save to store<a name="line.425"></a>
-<span class="sourceLineNo">426</span>   * &lt;/ol&gt;<a name="line.426"></a>
-<span class="sourceLineNo">427</span>   *<a name="line.427"></a>
-<span class="sourceLineNo">428</span>   *&lt;p&gt;This is a good test for 
finding state that needs persisting and steps that are not<a 
name="line.428"></a>
-<span class="sourceLineNo">429</span>   * idempotent. Use this version of the 
test when the order in which flow steps are executed is<a name="line.429"></a>
-<span class="sourceLineNo">430</span>   * not start to finish; where the 
procedure may vary the flow steps dependent on circumstance<a 
name="line.430"></a>
-<span class="sourceLineNo">431</span>   * found.<a name="line.431"></a>
-<span class="sourceLineNo">432</span>   * @see 
#testRecoveryAndDoubleExecution(ProcedureExecutor, long, int, boolean)<a 
name="line.432"></a>
-<span class="sourceLineNo">433</span>   */<a name="line.433"></a>
-<span class="sourceLineNo">434</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.434"></a>
-<span class="sourceLineNo">435</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId, final 
StepHook hook)<a name="line.435"></a>
-<span class="sourceLineNo">436</span>      throws Exception {<a 
name="line.436"></a>
-<span class="sourceLineNo">437</span>    
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.437"></a>
-<span class="sourceLineNo">438</span>    assertEquals(false, 
procExec.isRunning());<a name="line.438"></a>
-<span class="sourceLineNo">439</span>    for (int i = 0; 
!procExec.isFinished(procId); ++i) {<a name="line.439"></a>
-<span class="sourceLineNo">440</span>      LOG.info("Restart " + i + " exec 
state=" + procExec.getProcedure(procId));<a name="line.440"></a>
-<span class="sourceLineNo">441</span>      if (hook != null) {<a 
name="line.441"></a>
-<span class="sourceLineNo">442</span>        assertTrue(hook.execute(i));<a 
name="line.442"></a>
-<span class="sourceLineNo">443</span>      }<a name="line.443"></a>
-<span class="sourceLineNo">444</span>      
restartMasterProcedureExecutor(procExec);<a name="line.444"></a>
-<span class="sourceLineNo">445</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    }<a name="line.446"></a>
-<span class="sourceLineNo">447</span>    assertEquals(true, 
procExec.isRunning());<a name="line.447"></a>
-<span class="sourceLineNo">448</span>    
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);<a 
name="line.448"></a>
-<span class="sourceLineNo">449</span>  }<a name="line.449"></a>
-<span class="sourceLineNo">450</span><a name="line.450"></a>
-<span class="sourceLineNo">451</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.451"></a>
-<span class="sourceLineNo">452</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId) throws 
Exception {<a name="line.452"></a>
-<span class="sourceLineNo">453</span>    
testRecoveryAndDoubleExecution(procExec, procId, null);<a name="line.453"></a>
-<span class="sourceLineNo">454</span>  }<a name="line.454"></a>
-<span class="sourceLineNo">455</span><a name="line.455"></a>
-<span class="sourceLineNo">456</span>  /**<a name="line.456"></a>
-<span class="sourceLineNo">457</span>   * Hook which will be executed on each 
step<a name="line.457"></a>
-<span class="sourceLineNo">458</span>   */<a name="line.458"></a>
-<span class="sourceLineNo">459</span>  public interface StepHook{<a 
name="line.459"></a>
-<span class="sourceLineNo">460</span>    /**<a name="line.460"></a>
-<span class="sourceLineNo">461</span>     * @param step Step no. at which this 
will be executed<a name="line.461"></a>
-<span class="sourceLineNo">462</span>     * @return false if test should fail 
otherwise true<a name="line.462"></a>
-<span class="sourceLineNo">463</span>     * @throws IOException<a 
name="line.463"></a>
-<span class="sourceLineNo">464</span>     */<a name="line.464"></a>
-<span class="sourceLineNo">465</span>    boolean execute(int step) throws 
IOException;<a name="line.465"></a>
-<span class="sourceLineNo">466</span>  }<a name="line.466"></a>
-<span class="sourceLineNo">467</span><a name="line.467"></a>
-<span class="sourceLineNo">468</span>  /**<a name="line.468"></a>
-<span class="sourceLineNo">469</span>   * Execute the procedure up to 
"lastStep" and then the ProcedureExecutor<a name="line.469"></a>
-<span class="sourceLineNo">470</span>   * is restarted and an abort() is 
injected.<a name="line.470"></a>
-<span class="sourceLineNo">471</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.471"></a>
-<span class="sourceLineNo">472</span>   * Each rollback step is called twice, 
by restarting the executor after every step.<a name="line.472"></a>
-<span class="sourceLineNo">473</span>   * At the end of this call the 
procedure should be finished and rolledback.<a name="line.473"></a>
-<span class="sourceLineNo">474</span>   * This method assert on the procedure 
being terminated with an AbortException.<a name="line.474"></a>
-<span class="sourceLineNo">475</span>   */<a name="line.475"></a>
-<span class="sourceLineNo">476</span>  public static void 
testRollbackAndDoubleExecution(<a name="line.476"></a>
-<span class="sourceLineNo">477</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.477"></a>
-<span class="sourceLineNo">478</span>      final int lastStep) throws 
Exception {<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    
testRollbackAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.479"></a>
-<span class="sourceLineNo">480</span>  }<a name="line.480"></a>
-<span class="sourceLineNo">481</span><a name="line.481"></a>
-<span class="sourceLineNo">482</span>  public static void 
testRollbackAndDoubleExecution(<a name="line.482"></a>
-<span class="sourceLineNo">483</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.483"></a>
-<span class="sourceLineNo">484</span>      final int lastStep, boolean 
waitForAsyncProcs) throws Exception {<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    // Execute up to last step<a 
name="line.485"></a>
-<span class="sourceLineNo">486</span>    
testRecoveryAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.486"></a>
-<span class="sourceLineNo">487</span><a name="line.487"></a>
-<span class="sourceLineNo">488</span>    // Restart the executor and rollback 
the step twice<a name="line.488"></a>
-<span class="sourceLineNo">489</span>    //   rollback step N - kill before 
store update<a name="line.489"></a>
-<span class="sourceLineNo">490</span>    //   restart executor/store<a 
name="line.490"></a>
-<span class="sourceLineNo">491</span>    //   rollback step N - save on 
store<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    InjectAbortOnLoadListener 
abortListener = new InjectAbortOnLoadListener(procExec);<a name="line.492"></a>
-<span class="sourceLineNo">493</span>    abortListener.addProcId(procId);<a 
name="line.493"></a>
-<span class="sourceLineNo">494</span>    
procExec.registerListener(abortListener);<a name="line.494"></a>
-<span class="sourceLineNo">495</span>    try {<a name="line.495"></a>
-<span class="sourceLineNo">496</span>      for (int i = 0; 
!procExec.isFinished(procId); ++i) {<a name="line.496"></a>
-<span class="sourceLineNo">497</span>        LOG.info("Restart " + i + " 
rollback state: " + procExec.getProcedure(procId));<a name="line.497"></a>
-<span class="sourceLineNo">498</span>        
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.498"></a>
-<span class="sourceLineNo">499</span>        
restartMasterProcedureExecutor(procExec);<a name="line.499"></a>
-<span class="sourceLineNo">500</span>        
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.500"></a>
-<span class="sourceLineNo">501</span>      }<a name="line.501"></a>
-<span class="sourceLineNo">502</span>    } finally {<a name="line.502"></a>
-<span class="sourceLineNo">503</span>      
assertTrue(procExec.unregisterListener(abortListener));<a name="line.503"></a>
-<span class="sourceLineNo">504</span>    }<a name="line.504"></a>
-<span class="sourceLineNo">505</span><a name="line.505"></a>
-<span class="sourceLineNo">506</span>    if (waitForAsyncProcs) {<a 
name="line.506"></a>
-<span class="sourceLineNo">507</span>      // Sometimes there are other 
procedures still executing (including asynchronously spawned by<a 
name="line.507"></a>
-<span class="sourceLineNo">508</span>      // procId) and due to 
KillAndToggleBeforeStoreUpdate flag ProcedureExecutor is stopped before<a 
name="line.508"></a>
-<span class="sourceLineNo">509</span>      // store update. Let all pending 
procedures finish normally.<a name="line.509"></a>
-<span class="sourceLineNo">510</span>      if (!procExec.isRunning()) {<a 
name="line.510"></a>
-<span class="sourceLineNo">511</span>        LOG.warn("ProcedureExecutor not 
running, may have been stopped by pending procedure due to"<a 
name="line.511"></a>
-<span class="sourceLineNo">512</span>            + " 
KillAndToggleBeforeStoreUpdate flag.");<a name="line.512"></a>
-<span class="sourceLineNo">513</span>        
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);<a 
name="line.513"></a>
-<span class="sourceLineNo">514</span>        
restartMasterProcedureExecutor(procExec);<a name="line.514"></a>
-<span class="sourceLineNo">515</span>        
ProcedureTestingUtility.waitNoProcedureRunning(procExec);<a name="line.515"></a>
-<span class="sourceLineNo">516</span>      }<a name="line.516"></a>
-<span class="sourceLineNo">517</span>    }<a name="line.517"></a>
-<span class="sourceLineNo">518</span><a name="line.518"></a>
-<span class="sourceLineNo">519</span>    assertEquals(true, 
procExec.isRunning());<a name="line.519"></a>
-<span class="sourceLineNo">520</span>    
ProcedureTestingUtility.assertIsAbortException(procExec.getResult(procId));<a 
name="line.520"></a>
-<span class="sourceLineNo">521</span>  }<a name="line.521"></a>
-<span class="sourceLineNo">522</span><a name="line.522"></a>
-<span class="sourceLineNo">523</span>  /**<a name="line.523"></a>
-<span class="sourceLineNo">524</span>   * Execute the procedure up to 
"lastStep" and then the ProcedureExecutor<a name="line.524"></a>
-<span class="sourceLineNo">525</span>   * is restarted and an abort() is 
injected.<a name="line.525"></a>
-<span class="sourceLineNo">526</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.526"></a>
-<span class="sourceLineNo">527</span>   * At the end of this call the 
procedure should be finished and rolledback.<a name="line.527"></a>
-<span class="sourceLineNo">528</span>   * This method assert on the procedure 
being terminated with an AbortException.<a name="line.528"></a>
-<span class="sourceLineNo">529</span>   */<a name="line.529"></a>
-<span class="sourceLineNo">530</span>  public static void 
testRollbackRetriableFailure(<a name="line.530"></a>
-<span class="sourceLineNo">531</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.531"></a>
-<span class="sourceLineNo">532</span>      final int lastStep) throws 
Exception {<a name="line.532"></a>
-<span class="sourceLineNo">533</span>    // Execute up to last step<a 
name="line.533"></a>
-<span class="sourceLineNo">534</span>    
testRecoveryAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.534"></a>
-<span class="sourceLineNo">535</span><a name="line.535"></a>
-<span class="sourceLineNo">536</span>    // execute the rollback<a 
name="line.536"></a>
-<span class="sourceLineNo">537</span>    testRestartWithAbort(procExec, 
procId);<a name="line.537"></a>
+<span class="sourceLineNo">417</span>    assertEquals(expectExecRunning, 
procExec.isRunning());<a name="line.417"></a>
+<span class="sourceLineNo">418</span>  }<a name="line.418"></a>
+<span class="sourceLineNo">419</span><a name="line.419"></a>
+<span class="sourceLineNo">420</span>  /**<a name="line.420"></a>
+<span class="sourceLineNo">421</span>   * Run through all procedure flow 
states TWICE while also restarting<a name="line.421"></a>
+<span class="sourceLineNo">422</span>   * procedure executor at each step; i.e 
force a reread of procedure store.<a name="line.422"></a>
+<span class="sourceLineNo">423</span>   *<a name="line.423"></a>
+<span class="sourceLineNo">424</span>   *&lt;p&gt;It does<a 
name="line.424"></a>
+<span class="sourceLineNo">425</span>   * &lt;ol&gt;&lt;li&gt;Execute step N - 
kill the executor before store update<a name="line.425"></a>
+<span class="sourceLineNo">426</span>   * &lt;li&gt;Restart executor/store<a 
name="line.426"></a>
+<span class="sourceLineNo">427</span>   * &lt;li&gt;Executes hook for each 
step twice<a name="line.427"></a>
+<span class="sourceLineNo">428</span>   * &lt;li&gt;Execute step N - and then 
save to store<a name="line.428"></a>
+<span class="sourceLineNo">429</span>   * &lt;/ol&gt;<a name="line.429"></a>
+<span class="sourceLineNo">430</span>   *<a name="line.430"></a>
+<span class="sourceLineNo">431</span>   *&lt;p&gt;This is a good test for 
finding state that needs persisting and steps that are not<a 
name="line.431"></a>
+<span class="sourceLineNo">432</span>   * idempotent. Use this version of the 
test when the order in which flow steps are executed is<a name="line.432"></a>
+<span class="sourceLineNo">433</span>   * not start to finish; where the 
procedure may vary the flow steps dependent on circumstance<a 
name="line.433"></a>
+<span class="sourceLineNo">434</span>   * found.<a name="line.434"></a>
+<span class="sourceLineNo">435</span>   * @see 
#testRecoveryAndDoubleExecution(ProcedureExecutor, long, int, boolean)<a 
name="line.435"></a>
+<span class="sourceLineNo">436</span>   */<a name="line.436"></a>
+<span class="sourceLineNo">437</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.437"></a>
+<span class="sourceLineNo">438</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId, final 
StepHook hook)<a name="line.438"></a>
+<span class="sourceLineNo">439</span>      throws Exception {<a 
name="line.439"></a>
+<span class="sourceLineNo">440</span>    
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.440"></a>
+<span class="sourceLineNo">441</span>    assertEquals(false, 
procExec.isRunning());<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    for (int i = 0; 
!procExec.isFinished(procId); ++i) {<a name="line.442"></a>
+<span class="sourceLineNo">443</span>      LOG.info("Restart " + i + " exec 
state=" + procExec.getProcedure(procId));<a name="line.443"></a>
+<span class="sourceLineNo">444</span>      if (hook != null) {<a 
name="line.444"></a>
+<span class="sourceLineNo">445</span>        assertTrue(hook.execute(i));<a 
name="line.445"></a>
+<span class="sourceLineNo">446</span>      }<a name="line.446"></a>
+<span class="sourceLineNo">447</span>      
restartMasterProcedureExecutor(procExec);<a name="line.447"></a>
+<span class="sourceLineNo">448</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.448"></a>
+<span class="sourceLineNo">449</span>    }<a name="line.449"></a>
+<span class="sourceLineNo">450</span>    assertEquals(true, 
procExec.isRunning());<a name="line.450"></a>
+<span class="sourceLineNo">451</span>    
ProcedureTestingUtility.assertProcNotFailed(procExec, procId);<a 
name="line.451"></a>
+<span class="sourceLineNo">452</span>  }<a name="line.452"></a>
+<span class="sourceLineNo">453</span><a name="line.453"></a>
+<span class="sourceLineNo">454</span>  public static void 
testRecoveryAndDoubleExecution(<a name="line.454"></a>
+<span class="sourceLineNo">455</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId) throws 
Exception {<a name="line.455"></a>
+<span class="sourceLineNo">456</span>    
testRecoveryAndDoubleExecution(procExec, procId, null);<a name="line.456"></a>
+<span class="sourceLineNo">457</span>  }<a name="line.457"></a>
+<span class="sourceLineNo">458</span><a name="line.458"></a>
+<span class="sourceLineNo">459</span>  /**<a name="line.459"></a>
+<span class="sourceLineNo">460</span>   * Hook which will be executed on each 
step<a name="line.460"></a>
+<span class="sourceLineNo">461</span>   */<a name="line.461"></a>
+<span class="sourceLineNo">462</span>  public interface StepHook{<a 
name="line.462"></a>
+<span class="sourceLineNo">463</span>    /**<a name="line.463"></a>
+<span class="sourceLineNo">464</span>     * @param step Step no. at which this 
will be executed<a name="line.464"></a>
+<span class="sourceLineNo">465</span>     * @return false if test should fail 
otherwise true<a name="line.465"></a>
+<span class="sourceLineNo">466</span>     * @throws IOException<a 
name="line.466"></a>
+<span class="sourceLineNo">467</span>     */<a name="line.467"></a>
+<span class="sourceLineNo">468</span>    boolean execute(int step) throws 
IOException;<a name="line.468"></a>
+<span class="sourceLineNo">469</span>  }<a name="line.469"></a>
+<span class="sourceLineNo">470</span><a name="line.470"></a>
+<span class="sourceLineNo">471</span>  /**<a name="line.471"></a>
+<span class="sourceLineNo">472</span>   * Execute the procedure up to 
"lastStep" and then the ProcedureExecutor<a name="line.472"></a>
+<span class="sourceLineNo">473</span>   * is restarted and an abort() is 
injected.<a name="line.473"></a>
+<span class="sourceLineNo">474</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.474"></a>
+<span class="sourceLineNo">475</span>   * Each rollback step is called twice, 
by restarting the executor after every step.<a name="line.475"></a>
+<span class="sourceLineNo">476</span>   * At the end of this call the 
procedure should be finished and rolledback.<a name="line.476"></a>
+<span class="sourceLineNo">477</span>   * This method assert on the procedure 
being terminated with an AbortException.<a name="line.477"></a>
+<span class="sourceLineNo">478</span>   */<a name="line.478"></a>
+<span class="sourceLineNo">479</span>  public static void 
testRollbackAndDoubleExecution(<a name="line.479"></a>
+<span class="sourceLineNo">480</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.480"></a>
+<span class="sourceLineNo">481</span>      final int lastStep) throws 
Exception {<a name="line.481"></a>
+<span class="sourceLineNo">482</span>    
testRollbackAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.482"></a>
+<span class="sourceLineNo">483</span>  }<a name="line.483"></a>
+<span class="sourceLineNo">484</span><a name="line.484"></a>
+<span class="sourceLineNo">485</span>  public static void 
testRollbackAndDoubleExecution(<a name="line.485"></a>
+<span class="sourceLineNo">486</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.486"></a>
+<span class="sourceLineNo">487</span>      final int lastStep, boolean 
waitForAsyncProcs) throws Exception {<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    // Execute up to last step<a 
name="line.488"></a>
+<span class="sourceLineNo">489</span>    
testRecoveryAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.489"></a>
+<span class="sourceLineNo">490</span><a name="line.490"></a>
+<span class="sourceLineNo">491</span>    // Restart the executor and rollback 
the step twice<a name="line.491"></a>
+<span class="sourceLineNo">492</span>    //   rollback step N - kill before 
store update<a name="line.492"></a>
+<span class="sourceLineNo">493</span>    //   restart executor/store<a 
name="line.493"></a>
+<span class="sourceLineNo">494</span>    //   rollback step N - save on 
store<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    InjectAbortOnLoadListener 
abortListener = new InjectAbortOnLoadListener(procExec);<a name="line.495"></a>
+<span class="sourceLineNo">496</span>    abortListener.addProcId(procId);<a 
name="line.496"></a>
+<span class="sourceLineNo">497</span>    
procExec.registerListener(abortListener);<a name="line.497"></a>
+<span class="sourceLineNo">498</span>    try {<a name="line.498"></a>
+<span class="sourceLineNo">499</span>      for (int i = 0; 
!procExec.isFinished(procId); ++i) {<a name="line.499"></a>
+<span class="sourceLineNo">500</span>        LOG.info("Restart " + i + " 
rollback state: " + procExec.getProcedure(procId));<a name="line.500"></a>
+<span class="sourceLineNo">501</span>        
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.501"></a>
+<span class="sourceLineNo">502</span>        
restartMasterProcedureExecutor(procExec);<a name="line.502"></a>
+<span class="sourceLineNo">503</span>        
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.503"></a>
+<span class="sourceLineNo">504</span>      }<a name="line.504"></a>
+<span class="sourceLineNo">505</span>    } finally {<a name="line.505"></a>
+<span class="sourceLineNo">506</span>      
assertTrue(procExec.unregisterListener(abortListener));<a name="line.506"></a>
+<span class="sourceLineNo">507</span>    }<a name="line.507"></a>
+<span class="sourceLineNo">508</span><a name="line.508"></a>
+<span class="sourceLineNo">509</span>    if (waitForAsyncProcs) {<a 
name="line.509"></a>
+<span class="sourceLineNo">510</span>      // Sometimes there are other 
procedures still executing (including asynchronously spawned by<a 
name="line.510"></a>
+<span class="sourceLineNo">511</span>      // procId) and due to 
KillAndToggleBeforeStoreUpdate flag ProcedureExecutor is stopped before<a 
name="line.511"></a>
+<span class="sourceLineNo">512</span>      // store update. Let all pending 
procedures finish normally.<a name="line.512"></a>
+<span class="sourceLineNo">513</span>      if (!procExec.isRunning()) {<a 
name="line.513"></a>
+<span class="sourceLineNo">514</span>        LOG.warn("ProcedureExecutor not 
running, may have been stopped by pending procedure due to"<a 
name="line.514"></a>
+<span class="sourceLineNo">515</span>            + " 
KillAndToggleBeforeStoreUpdate flag.");<a name="line.515"></a>
+<span class="sourceLineNo">516</span>        
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);<a 
name="line.516"></a>
+<span class="sourceLineNo">517</span>        
restartMasterProcedureExecutor(procExec);<a name="line.517"></a>
+<span class="sourceLineNo">518</span>        
ProcedureTestingUtility.waitNoProcedureRunning(procExec);<a name="line.518"></a>
+<span class="sourceLineNo">519</span>      }<a name="line.519"></a>
+<span class="sourceLineNo">520</span>    }<a name="line.520"></a>
+<span class="sourceLineNo">521</span><a name="line.521"></a>
+<span class="sourceLineNo">522</span>    assertEquals(true, 
procExec.isRunning());<a name="line.522"></a>
+<span class="sourceLineNo">523</span>    
ProcedureTestingUtility.assertIsAbortException(procExec.getResult(procId));<a 
name="line.523"></a>
+<span class="sourceLineNo">524</span>  }<a name="line.524"></a>
+<span class="sourceLineNo">525</span><a name="line.525"></a>
+<span class="sourceLineNo">526</span>  /**<a name="line.526"></a>
+<span class="sourceLineNo">527</span>   * Execute the procedure up to 
"lastStep" and then the ProcedureExecutor<a name="line.527"></a>
+<span class="sourceLineNo">528</span>   * is restarted and an abort() is 
injected.<a name="line.528"></a>
+<span class="sourceLineNo">529</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.529"></a>
+<span class="sourceLineNo">530</span>   * At the end of this call the 
procedure should be finished and rolledback.<a name="line.530"></a>
+<span class="sourceLineNo">531</span>   * This method assert on the procedure 
being terminated with an AbortException.<a name="line.531"></a>
+<span class="sourceLineNo">532</span>   */<a name="line.532"></a>
+<span class="sourceLineNo">533</span>  public static void 
testRollbackRetriableFailure(<a name="line.533"></a>
+<span class="sourceLineNo">534</span>      final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec, final long procId,<a 
name="line.534"></a>
+<span class="sourceLineNo">535</span>      final int lastStep) throws 
Exception {<a name="line.535"></a>
+<span class="sourceLineNo">536</span>    // Execute up to last step<a 
name="line.536"></a>
+<span class="sourceLineNo">537</span>    
testRecoveryAndDoubleExecution(procExec, procId, lastStep, false);<a 
name="line.537"></a>
 <span class="sourceLineNo">538</span><a name="line.538"></a>
-<span class="sourceLineNo">539</span>    assertEquals(true, 
procExec.isRunning());<a name="line.539"></a>
-<span class="sourceLineNo">540</span>    
ProcedureTestingUtility.assertIsAbortException(procExec.getResult(procId));<a 
name="line.540"></a>
-<span class="sourceLineNo">541</span>  }<a name="line.541"></a>
-<span class="sourceLineNo">542</span><a name="line.542"></a>
-<span class="sourceLineNo">543</span>  /**<a name="line.543"></a>
-<span class="sourceLineNo">544</span>   * Restart the ProcedureExecutor and 
inject an abort to the specified procedure.<a name="line.544"></a>
-<span class="sourceLineNo">545</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.545"></a>
-<span class="sourceLineNo">546</span>   * At the end of this call the 
procedure should be finished and rolledback, if abort is implemnted<a 
name="line.546"></a>
-<span class="sourceLineNo">547</span>   */<a name="line.547"></a>
-<span class="sourceLineNo">548</span>  public static void 
testRestartWithAbort(ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec,<a 
name="line.548"></a>
-<span class="sourceLineNo">549</span>      long procId) throws Exception {<a 
name="line.549"></a>
-<span class="sourceLineNo">550</span>    
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);<a 
name="line.550"></a>
-<span class="sourceLineNo">551</span>    InjectAbortOnLoadListener 
abortListener = new InjectAbortOnLoadListener(procExec);<a name="line.551"></a>
-<span class="sourceLineNo">552</span>    abortListener.addProcId(procId);<a 
name="line.552"></a>
-<span class="sourceLineNo">553</span>    
procExec.registerListener(abortListener);<a name="line.553"></a>
-<span class="sourceLineNo">554</span>    try {<a name="line.554"></a>
-<span class="sourceLineNo">555</span>      
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.555"></a>
-<span class="sourceLineNo">556</span>      LOG.info("Restart and rollback 
procId=" + procId);<a name="line.556"></a>
-<span class="sourceLineNo">557</span>      
restartMasterProcedureExecutor(procExec);<a name="line.557"></a>
-<span class="sourceLineNo">558</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.558"></a>
-<span class="sourceLineNo">559</span>    } finally {<a name="line.559"></a>
-<span class="sourceLineNo">560</span>      
assertTrue(procExec.unregisterListener(abortListener));<a name="line.560"></a>
-<span class="sourceLineNo">561</span>    }<a name="line.561"></a>
-<span class="sourceLineNo">562</span>  }<a name="line.562"></a>
-<span class="sourceLineNo">563</span><a name="line.563"></a>
-<span class="sourceLineNo">564</span>  public static class 
InjectAbortOnLoadListener<a name="line.564"></a>
-<span class="sourceLineNo">565</span>      implements 
ProcedureExecutor.ProcedureExecutorListener {<a name="line.565"></a>
-<span class="sourceLineNo">566</span>    private final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec;<a name="line.566"></a>
-<span class="sourceLineNo">567</span>    private TreeSet&lt;Long&gt; 
procsToAbort = null;<a name="line.567"></a>
-<span class="sourceLineNo">568</span><a name="line.568"></a>
-<span class="sourceLineNo">569</span>    public 
InjectAbortOnLoadListener(final ProcedureExecutor&lt;MasterProcedureEnv&gt; 
procExec) {<a name="line.569"></a>
-<span class="sourceLineNo">570</span>      this.procExec = procExec;<a 
name="line.570"></a>
-<span class="sourceLineNo">571</span>    }<a name="line.571"></a>
-<span class="sourceLineNo">572</span><a name="line.572"></a>
-<span class="sourceLineNo">573</span>    public void addProcId(long procId) 
{<a name="line.573"></a>
-<span class="sourceLineNo">574</span>      if (procsToAbort == null) {<a 
name="line.574"></a>
-<span class="sourceLineNo">575</span>        procsToAbort = new 
TreeSet&lt;&gt;();<a name="line.575"></a>
-<span class="sourceLineNo">576</span>      }<a name="line.576"></a>
-<span class="sourceLineNo">577</span>      procsToAbort.add(procId);<a 
name="line.577"></a>
-<span class="sourceLineNo">578</span>    }<a name="line.578"></a>
-<span class="sourceLineNo">579</span><a name="line.579"></a>
-<span class="sourceLineNo">580</span>    @Override<a name="line.580"></a>
-<span class="sourceLineNo">581</span>    public void procedureLoaded(long 
procId) {<a name="line.581"></a>
-<span class="sourceLineNo">582</span>      if (procsToAbort != null &amp;&amp; 
!procsToAbort.contains(procId)) {<a name="line.582"></a>
-<span class="sourceLineNo">583</span>        return;<a name="line.583"></a>
-<span class="sourceLineNo">584</span>      }<a name="line.584"></a>
-<span class="sourceLineNo">585</span>      procExec.abort(procId);<a 
name="line.585"></a>
-<span class="sourceLineNo">586</span>    }<a name="line.586"></a>
-<span class="sourceLineNo">587</span><a name="line.587"></a>
-<span class="sourceLineNo">588</span>    @Override<a name="line.588"></a>
-<span class="sourceLineNo">589</span>    public void procedureAdded(long 
procId) { /* no-op */ }<a name="line.589"></a>
+<span class="sourceLineNo">539</span>    // execute the rollback<a 
name="line.539"></a>
+<span class="sourceLineNo">540</span>    testRestartWithAbort(procExec, 
procId);<a name="line.540"></a>
+<span class="sourceLineNo">541</span><a name="line.541"></a>
+<span class="sourceLineNo">542</span>    assertEquals(true, 
procExec.isRunning());<a name="line.542"></a>
+<span class="sourceLineNo">543</span>    
ProcedureTestingUtility.assertIsAbortException(procExec.getResult(procId));<a 
name="line.543"></a>
+<span class="sourceLineNo">544</span>  }<a name="line.544"></a>
+<span class="sourceLineNo">545</span><a name="line.545"></a>
+<span class="sourceLineNo">546</span>  /**<a name="line.546"></a>
+<span class="sourceLineNo">547</span>   * Restart the ProcedureExecutor and 
inject an abort to the specified procedure.<a name="line.547"></a>
+<span class="sourceLineNo">548</span>   * If the procedure implement abort() 
this should result in rollback being triggered.<a name="line.548"></a>
+<span class="sourceLineNo">549</span>   * At the end of this call the 
procedure should be finished and rolledback, if abort is implemnted<a 
name="line.549"></a>
+<span class="sourceLineNo">550</span>   */<a name="line.550"></a>
+<span class="sourceLineNo">551</span>  public static void 
testRestartWithAbort(ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec,<a 
name="line.551"></a>
+<span class="sourceLineNo">552</span>      long procId) throws Exception {<a 
name="line.552"></a>
+<span class="sourceLineNo">553</span>    
ProcedureTestingUtility.setKillAndToggleBeforeStoreUpdate(procExec, false);<a 
name="line.553"></a>
+<span class="sourceLineNo">554</span>    InjectAbortOnLoadListener 
abortListener = new InjectAbortOnLoadListener(procExec);<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    abortListener.addProcId(procId);<a 
name="line.555"></a>
+<span class="sourceLineNo">556</span>    
procExec.registerListener(abortListener);<a name="line.556"></a>
+<span class="sourceLineNo">557</span>    try {<a name="line.557"></a>
+<span class="sourceLineNo">558</span>      
ProcedureTestingUtility.assertProcNotYetCompleted(procExec, procId);<a 
name="line.558"></a>
+<span class="sourceLineNo">559</span>      LOG.info("Restart and rollback 
procId=" + procId);<a name="line.559"></a>
+<span class="sourceLineNo">560</span>      
restartMasterProcedureExecutor(procExec);<a name="line.560"></a>
+<span class="sourceLineNo">561</span>      
ProcedureTestingUtility.waitProcedure(procExec, procId);<a name="line.561"></a>
+<span class="sourceLineNo">562</span>    } finally {<a name="line.562"></a>
+<span class="sourceLineNo">563</span>      
assertTrue(procExec.unregisterListener(abortListener));<a name="line.563"></a>
+<span class="sourceLineNo">564</span>    }<a name="line.564"></a>
+<span class="sourceLineNo">565</span>  }<a name="line.565"></a>
+<span class="sourceLineNo">566</span><a name="line.566"></a>
+<span class="sourceLineNo">567</span>  public static class 
InjectAbortOnLoadListener<a name="line.567"></a>
+<span class="sourceLineNo">568</span>      implements 
ProcedureExecutor.ProcedureExecutorListener {<a name="line.568"></a>
+<span class="sourceLineNo">569</span>    private final 
ProcedureExecutor&lt;MasterProcedureEnv&gt; procExec;<a name="line.569"></a>
+<span class="sourceLineNo">570</span>    private TreeSet&lt;Long&gt; 
procsToAbort = null;<a name="line.570"></a>
+<span class="sourceLineNo">571</span><a name="line.571"></a>
+<span class="sourceLineNo">572</span>    public 
InjectAbortOnLoadListener(final ProcedureExecutor&lt;MasterProcedureEnv&gt; 
procExec) {<a name="line.572"></a>
+<span class="sourceLineNo">573</span>      this.procExec = procExec;<a 
name="line.573"></a>
+<span class="sourceLineNo">574</span>    }<a name="line.574"></a>
+<span class="sourceLineNo">575</span><a name="line.575"></a>
+<span class="sourceLineNo">576</span>    public void addProcId(long procId) 
{<a name="line.576"></a>
+<span class="sourceLineNo">577</span>      if (procsToAbort == null) {<a 
name="line.577"></a>
+<span class="sourceLineNo">578</span>        procsToAbort = new 
TreeSet&lt;&gt;();<a name="line.578"></a>
+<span class="sourceLineNo">579</span>      }<a name="line.579"></a>
+<span class="sourceLineNo">580</span>      procsToAbort.add(procId);<a 
name="line.580"></a>
+<span class="sourceLineNo">581</span>    }<a name="line.581"></a>
+<span class="sourceLineNo">582</span><a name="line.582"></a>
+<span class="sourceLineNo">583</span>    @Override<a name="line.583"></a>
+<span class="sourceLineNo">584</span>    public void procedureLoaded(long 
procId) {<a name="line.584"></a>
+<span class="sourceLineNo">585</span>      if (procsToAbort != null &amp;&amp; 
!procsToAbort.contains(procId)) {<a name="line.585"></a>
+<span class="sourceLineNo">586</span>        return;<a name="line.586"></a>
+<span class="sourceLineNo">587</span>      }<a name="line.587"></a>
+<span class="sourceLineNo">588</span>      procExec.abort(procId);<a 
name="line.588"></a>
+<span class="sourceLineNo">589</span>    }<a name="line.589"></a>
 <span class="sourceLineNo">590</span><a name="line.590"></a>
 <span class="sourceLineNo">591</span>    @Override<a name="line.591"></a>
-<span class="sourceLineNo">592</span>    public void procedureFinished(long 
procId) { /* no-op */ }<a name="line.592"></a>
-<span class="sourceLineNo">593</span>  }<a name="line.593"></a>
-<span class="sourceLineNo">594</span>}<a name="line.594"></a>
+<span class="sourceLineNo">592</span>    public void procedureAdded(long 
procId) { /* no-op */ }<a name="line.592"></a>
+<span class="sourceLineNo">593</span><a name="line.593"></a>
+<span class="sourceLineNo">594</span>    @Override<a name="line.594"></a>
+<span class="sourceLineNo">595</span>    public void procedureFinished(long 
procId) { /* no-op */ }<a name="line.595"></a>
+<span class="sourceLineNo">596</span>  }<a name="line.596"></a>
+<span class="sourceLineNo">597</span>}<a name="line.597"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/323b17d9/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCloneSnapshotProcedure.html
----------------------------------------------------------------------
diff --git 
a/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCloneSnapshotProcedure.html
 
b/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCloneSnapshotProcedure.html
index 570bb2f..8008ec1 100644
--- 
a/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCloneSnapshotProcedure.html
+++ 
b/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCloneSnapshotProcedure.html
@@ -185,8 +185,8 @@
 <span class="sourceLineNo">177</span>    long procId = 
procExec.submitProcedure(<a name="line.177"></a>
 <span class="sourceLineNo">178</span>      new 
CloneSnapshotProcedure(procExec.getEnvironment(), htd, snapshotDesc));<a 
name="line.178"></a>
 <span class="sourceLineNo">179</span><a name="line.179"></a>
-<span class="sourceLineNo">180</span>    int numberOfSteps = 0; // failing at 
pre operation<a name="line.180"></a>
-<span class="sourceLineNo">181</span>    
MasterProcedureTestingUtility.testRollbackAndDoubleExecution(procExec, procId, 
numberOfSteps);<a name="line.181"></a>
+<span class="sourceLineNo">180</span>    int lastStep = 2; // failing before 
CLONE_SNAPSHOT_WRITE_FS_LAYOUT<a name="line.180"></a>
+<span class="sourceLineNo">181</span>    
MasterProcedureTestingUtility.testRollbackAndDoubleExecution(procExec, procId, 
lastStep);<a name="line.181"></a>
 <span class="sourceLineNo">182</span><a name="line.182"></a>
 <span class="sourceLineNo">183</span>    
MasterProcedureTestingUtility.validateTableDeletion(<a name="line.183"></a>
 <span class="sourceLineNo">184</span>      UTIL.getHBaseCluster().getMaster(), 
clonedTableName);<a name="line.184"></a>

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/323b17d9/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.html
----------------------------------------------------------------------
diff --git 
a/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.html
 
b/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.html
index 613769c..816f2f5 100644
--- 
a/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.html
+++ 
b/testdevapidocs/src-html/org/apache/hadoop/hbase/master/procedure/TestCreateNamespaceProcedure.html
@@ -223,8 +223,8 @@
 <span class="sourceLineNo">215</span>    long procId = 
procExec.submitProcedure(<a name="line.215"></a>
 <span class="sourceLineNo">216</span>      new 
CreateNamespaceProcedure(procExec.getEnvironment(), nsd));<a 
name="line.216"></a>
 <span class="sourceLineNo">217</span><a name="line.217"></a>
-<span class="sourceLineNo">218</span>    int numberOfSteps = 0; // failing at 
pre operation<a name="line.218"></a>
-<span class="sourceLineNo">219</span>    
MasterProcedureTestingUtility.testRollbackAndDoubleExecution(procExec, procId, 
numberOfSteps);<a name="line.219"></a>
+<span class="sourceLineNo">218</span>    int lastStep = 2; // failing before 
CREATE_NAMESPACE_CREATE_DIRECTORY<a name="line.218"></a>
+<span class="sourceLineNo">219</span>    
MasterProcedureTestingUtility.testRollbackAndDoubleExecution(procExec, procId, 
lastStep);<a name="line.219"></a>
 <span class="sourceLineNo">220</span><a name="line.220"></a>
 <span class="sourceLineNo">221</span>    // Validate the non-existence of 
namespace<a name="line.221"></a>
 <span class="sourceLineNo">222</span>    try {<a name="line.222"></a>

Reply via email to