hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From mi...@apache.org
Subject [16/49] hbase-site git commit: Published site at 4b3e38705cb24aee82615b1b9af47ed549ea1358.
Date Thu, 03 Mar 2016 17:17:02 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestProcEnv.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestProcEnv.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestProcEnv.html
index 9fdc021..b3a6ee0 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestProcEnv.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestProcEnv.html
@@ -345,217 +345,243 @@
 <span class="sourceLineNo">337</span><a name="line.337"></a>
 <span class="sourceLineNo">338</span>    public TestStateMachineProcedure() {}<a name="line.338"></a>
 <span class="sourceLineNo">339</span><a name="line.339"></a>
-<span class="sourceLineNo">340</span>    private AtomicBoolean aborted = new AtomicBoolean(false);<a name="line.340"></a>
-<span class="sourceLineNo">341</span>    private int iResult = 0;<a name="line.341"></a>
-<span class="sourceLineNo">342</span><a name="line.342"></a>
-<span class="sourceLineNo">343</span>    @Override<a name="line.343"></a>
-<span class="sourceLineNo">344</span>    protected StateMachineProcedure.Flow executeFromState(TestProcEnv env, State state) {<a name="line.344"></a>
-<span class="sourceLineNo">345</span>      switch (state) {<a name="line.345"></a>
-<span class="sourceLineNo">346</span>        case STATE_1:<a name="line.346"></a>
-<span class="sourceLineNo">347</span>          LOG.info("execute step 1 " + this);<a name="line.347"></a>
-<span class="sourceLineNo">348</span>          setNextState(State.STATE_2);<a name="line.348"></a>
-<span class="sourceLineNo">349</span>          iResult += 3;<a name="line.349"></a>
-<span class="sourceLineNo">350</span>          break;<a name="line.350"></a>
-<span class="sourceLineNo">351</span>        case STATE_2:<a name="line.351"></a>
-<span class="sourceLineNo">352</span>          LOG.info("execute step 2 " + this);<a name="line.352"></a>
-<span class="sourceLineNo">353</span>          setNextState(State.STATE_3);<a name="line.353"></a>
-<span class="sourceLineNo">354</span>          iResult += 5;<a name="line.354"></a>
+<span class="sourceLineNo">340</span>    public TestStateMachineProcedure(final boolean testSubmitChildProc) {<a name="line.340"></a>
+<span class="sourceLineNo">341</span>      this.submitChildProc = testSubmitChildProc;<a name="line.341"></a>
+<span class="sourceLineNo">342</span>    }<a name="line.342"></a>
+<span class="sourceLineNo">343</span><a name="line.343"></a>
+<span class="sourceLineNo">344</span>    private AtomicBoolean aborted = new AtomicBoolean(false);<a name="line.344"></a>
+<span class="sourceLineNo">345</span>    private int iResult = 0;<a name="line.345"></a>
+<span class="sourceLineNo">346</span>    private boolean submitChildProc = false;<a name="line.346"></a>
+<span class="sourceLineNo">347</span><a name="line.347"></a>
+<span class="sourceLineNo">348</span>    @Override<a name="line.348"></a>
+<span class="sourceLineNo">349</span>    protected StateMachineProcedure.Flow executeFromState(TestProcEnv env, State state) {<a name="line.349"></a>
+<span class="sourceLineNo">350</span>      switch (state) {<a name="line.350"></a>
+<span class="sourceLineNo">351</span>        case STATE_1:<a name="line.351"></a>
+<span class="sourceLineNo">352</span>          LOG.info("execute step 1 " + this);<a name="line.352"></a>
+<span class="sourceLineNo">353</span>          setNextState(State.STATE_2);<a name="line.353"></a>
+<span class="sourceLineNo">354</span>          iResult += 3;<a name="line.354"></a>
 <span class="sourceLineNo">355</span>          break;<a name="line.355"></a>
-<span class="sourceLineNo">356</span>        case STATE_3:<a name="line.356"></a>
-<span class="sourceLineNo">357</span>          LOG.info("execute step 3 " + this);<a name="line.357"></a>
-<span class="sourceLineNo">358</span>          Threads.sleepWithoutInterrupt(procSleepInterval);<a name="line.358"></a>
-<span class="sourceLineNo">359</span>          if (aborted.get()) {<a name="line.359"></a>
-<span class="sourceLineNo">360</span>            LOG.info("aborted step 3 " + this);<a name="line.360"></a>
-<span class="sourceLineNo">361</span>            setAbortFailure("test", "aborted");<a name="line.361"></a>
-<span class="sourceLineNo">362</span>            break;<a name="line.362"></a>
-<span class="sourceLineNo">363</span>          }<a name="line.363"></a>
-<span class="sourceLineNo">364</span>          setNextState(State.DONE);<a name="line.364"></a>
-<span class="sourceLineNo">365</span>          iResult += 7;<a name="line.365"></a>
-<span class="sourceLineNo">366</span>          setResult(Bytes.toBytes(iResult));<a name="line.366"></a>
-<span class="sourceLineNo">367</span>          return Flow.NO_MORE_STATE;<a name="line.367"></a>
-<span class="sourceLineNo">368</span>        default:<a name="line.368"></a>
-<span class="sourceLineNo">369</span>          throw new UnsupportedOperationException();<a name="line.369"></a>
-<span class="sourceLineNo">370</span>      }<a name="line.370"></a>
-<span class="sourceLineNo">371</span>      return Flow.HAS_MORE_STATE;<a name="line.371"></a>
-<span class="sourceLineNo">372</span>    }<a name="line.372"></a>
-<span class="sourceLineNo">373</span><a name="line.373"></a>
-<span class="sourceLineNo">374</span>    @Override<a name="line.374"></a>
-<span class="sourceLineNo">375</span>    protected void rollbackState(TestProcEnv env, final State state) {<a name="line.375"></a>
-<span class="sourceLineNo">376</span>      switch (state) {<a name="line.376"></a>
-<span class="sourceLineNo">377</span>        case STATE_1:<a name="line.377"></a>
-<span class="sourceLineNo">378</span>          LOG.info("rollback step 1 " + this);<a name="line.378"></a>
-<span class="sourceLineNo">379</span>          break;<a name="line.379"></a>
-<span class="sourceLineNo">380</span>        case STATE_2:<a name="line.380"></a>
-<span class="sourceLineNo">381</span>          LOG.info("rollback step 2 " + this);<a name="line.381"></a>
-<span class="sourceLineNo">382</span>          break;<a name="line.382"></a>
-<span class="sourceLineNo">383</span>        case STATE_3:<a name="line.383"></a>
-<span class="sourceLineNo">384</span>          LOG.info("rollback step 3 " + this);<a name="line.384"></a>
-<span class="sourceLineNo">385</span>          break;<a name="line.385"></a>
-<span class="sourceLineNo">386</span>        default:<a name="line.386"></a>
-<span class="sourceLineNo">387</span>          throw new UnsupportedOperationException();<a name="line.387"></a>
-<span class="sourceLineNo">388</span>      }<a name="line.388"></a>
-<span class="sourceLineNo">389</span>    }<a name="line.389"></a>
-<span class="sourceLineNo">390</span><a name="line.390"></a>
-<span class="sourceLineNo">391</span>    @Override<a name="line.391"></a>
-<span class="sourceLineNo">392</span>    protected State getState(final int stateId) {<a name="line.392"></a>
-<span class="sourceLineNo">393</span>      return State.values()[stateId];<a name="line.393"></a>
-<span class="sourceLineNo">394</span>    }<a name="line.394"></a>
-<span class="sourceLineNo">395</span><a name="line.395"></a>
-<span class="sourceLineNo">396</span>    @Override<a name="line.396"></a>
-<span class="sourceLineNo">397</span>    protected int getStateId(final State state) {<a name="line.397"></a>
-<span class="sourceLineNo">398</span>      return state.ordinal();<a name="line.398"></a>
-<span class="sourceLineNo">399</span>    }<a name="line.399"></a>
-<span class="sourceLineNo">400</span><a name="line.400"></a>
-<span class="sourceLineNo">401</span>    @Override<a name="line.401"></a>
-<span class="sourceLineNo">402</span>    protected State getInitialState() {<a name="line.402"></a>
-<span class="sourceLineNo">403</span>      return State.STATE_1;<a name="line.403"></a>
-<span class="sourceLineNo">404</span>    }<a name="line.404"></a>
-<span class="sourceLineNo">405</span><a name="line.405"></a>
-<span class="sourceLineNo">406</span>    @Override<a name="line.406"></a>
-<span class="sourceLineNo">407</span>    protected boolean abort(TestProcEnv env) {<a name="line.407"></a>
-<span class="sourceLineNo">408</span>      aborted.set(true);<a name="line.408"></a>
-<span class="sourceLineNo">409</span>      return true;<a name="line.409"></a>
-<span class="sourceLineNo">410</span>    }<a name="line.410"></a>
-<span class="sourceLineNo">411</span><a name="line.411"></a>
-<span class="sourceLineNo">412</span>    @Override<a name="line.412"></a>
-<span class="sourceLineNo">413</span>    protected void serializeStateData(final OutputStream stream) throws IOException {<a name="line.413"></a>
-<span class="sourceLineNo">414</span>      super.serializeStateData(stream);<a name="line.414"></a>
-<span class="sourceLineNo">415</span>      stream.write(Bytes.toBytes(iResult));<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>    @Override<a name="line.418"></a>
-<span class="sourceLineNo">419</span>    protected void deserializeStateData(final InputStream stream) throws IOException {<a name="line.419"></a>
-<span class="sourceLineNo">420</span>      super.deserializeStateData(stream);<a name="line.420"></a>
-<span class="sourceLineNo">421</span>      byte[] data = new byte[4];<a name="line.421"></a>
-<span class="sourceLineNo">422</span>      stream.read(data);<a name="line.422"></a>
-<span class="sourceLineNo">423</span>      iResult = Bytes.toInt(data);<a name="line.423"></a>
-<span class="sourceLineNo">424</span>    }<a name="line.424"></a>
-<span class="sourceLineNo">425</span>  }<a name="line.425"></a>
-<span class="sourceLineNo">426</span><a name="line.426"></a>
-<span class="sourceLineNo">427</span>  @Test(timeout=30000)<a name="line.427"></a>
-<span class="sourceLineNo">428</span>  public void testStateMachineRecovery() throws Exception {<a name="line.428"></a>
-<span class="sourceLineNo">429</span>    ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExecutor, true);<a name="line.429"></a>
-<span class="sourceLineNo">430</span>    ProcedureTestingUtility.setKillBeforeStoreUpdate(procExecutor, true);<a name="line.430"></a>
-<span class="sourceLineNo">431</span><a name="line.431"></a>
-<span class="sourceLineNo">432</span>    // Step 1 - kill<a name="line.432"></a>
-<span class="sourceLineNo">433</span>    Procedure proc = new TestStateMachineProcedure();<a name="line.433"></a>
-<span class="sourceLineNo">434</span>    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);<a name="line.434"></a>
-<span class="sourceLineNo">435</span>    assertFalse(procExecutor.isRunning());<a name="line.435"></a>
-<span class="sourceLineNo">436</span><a name="line.436"></a>
-<span class="sourceLineNo">437</span>    // Step 1 exec &amp;&amp; Step 2 - kill<a name="line.437"></a>
-<span class="sourceLineNo">438</span>    restart();<a name="line.438"></a>
-<span class="sourceLineNo">439</span>    waitProcedure(procId);<a name="line.439"></a>
-<span class="sourceLineNo">440</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.440"></a>
-<span class="sourceLineNo">441</span>    assertFalse(procExecutor.isRunning());<a name="line.441"></a>
-<span class="sourceLineNo">442</span><a name="line.442"></a>
-<span class="sourceLineNo">443</span>    // Step 2 exec &amp;&amp; step 3 - kill<a name="line.443"></a>
-<span class="sourceLineNo">444</span>    restart();<a name="line.444"></a>
-<span class="sourceLineNo">445</span>    waitProcedure(procId);<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.446"></a>
-<span class="sourceLineNo">447</span>    assertFalse(procExecutor.isRunning());<a name="line.447"></a>
-<span class="sourceLineNo">448</span><a name="line.448"></a>
-<span class="sourceLineNo">449</span>    // Step 3 exec<a name="line.449"></a>
-<span class="sourceLineNo">450</span>    restart();<a name="line.450"></a>
-<span class="sourceLineNo">451</span>    waitProcedure(procId);<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    assertTrue(procExecutor.isRunning());<a name="line.452"></a>
-<span class="sourceLineNo">453</span><a name="line.453"></a>
-<span class="sourceLineNo">454</span>    // The procedure is completed<a name="line.454"></a>
-<span class="sourceLineNo">455</span>    ProcedureInfo result = procExecutor.getResult(procId);<a name="line.455"></a>
-<span class="sourceLineNo">456</span>    ProcedureTestingUtility.assertProcNotFailed(result);<a name="line.456"></a>
-<span class="sourceLineNo">457</span>    assertEquals(15, Bytes.toInt(result.getResult()));<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>  @Test(timeout=30000)<a name="line.460"></a>
-<span class="sourceLineNo">461</span>  public void testStateMachineRollbackRecovery() throws Exception {<a name="line.461"></a>
-<span class="sourceLineNo">462</span>    ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExecutor, true);<a name="line.462"></a>
-<span class="sourceLineNo">463</span>    ProcedureTestingUtility.setKillBeforeStoreUpdate(procExecutor, true);<a name="line.463"></a>
-<span class="sourceLineNo">464</span><a name="line.464"></a>
-<span class="sourceLineNo">465</span>    // Step 1 - kill<a name="line.465"></a>
-<span class="sourceLineNo">466</span>    Procedure proc = new TestStateMachineProcedure();<a name="line.466"></a>
-<span class="sourceLineNo">467</span>    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);<a name="line.467"></a>
-<span class="sourceLineNo">468</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.468"></a>
-<span class="sourceLineNo">469</span>    assertFalse(procExecutor.isRunning());<a name="line.469"></a>
-<span class="sourceLineNo">470</span><a name="line.470"></a>
-<span class="sourceLineNo">471</span>    // Step 1 exec &amp;&amp; Step 2 - kill<a name="line.471"></a>
-<span class="sourceLineNo">472</span>    restart();<a name="line.472"></a>
-<span class="sourceLineNo">473</span>    waitProcedure(procId);<a name="line.473"></a>
-<span class="sourceLineNo">474</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.474"></a>
-<span class="sourceLineNo">475</span>    assertFalse(procExecutor.isRunning());<a name="line.475"></a>
-<span class="sourceLineNo">476</span><a name="line.476"></a>
-<span class="sourceLineNo">477</span>    // Step 2 exec &amp;&amp; step 3 - kill<a name="line.477"></a>
-<span class="sourceLineNo">478</span>    restart();<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    waitProcedure(procId);<a name="line.479"></a>
-<span class="sourceLineNo">480</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.480"></a>
-<span class="sourceLineNo">481</span>    assertFalse(procExecutor.isRunning());<a name="line.481"></a>
-<span class="sourceLineNo">482</span><a name="line.482"></a>
-<span class="sourceLineNo">483</span>    // Step 3 exec - rollback step 3 - kill<a name="line.483"></a>
-<span class="sourceLineNo">484</span>    procSleepInterval = 2500;<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    restart();<a name="line.485"></a>
-<span class="sourceLineNo">486</span>    assertTrue(procExecutor.abort(procId));<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    waitProcedure(procId);<a name="line.487"></a>
-<span class="sourceLineNo">488</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.488"></a>
-<span class="sourceLineNo">489</span>    assertFalse(procExecutor.isRunning());<a name="line.489"></a>
+<span class="sourceLineNo">356</span>        case STATE_2:<a name="line.356"></a>
+<span class="sourceLineNo">357</span>          LOG.info("execute step 2 " + this);<a name="line.357"></a>
+<span class="sourceLineNo">358</span>          if (submitChildProc) {<a name="line.358"></a>
+<span class="sourceLineNo">359</span>            addChildProcedure(new TestStateMachineProcedure());<a name="line.359"></a>
+<span class="sourceLineNo">360</span>            addChildProcedure(new TestStateMachineProcedure());<a name="line.360"></a>
+<span class="sourceLineNo">361</span>            setNextState(State.DONE);<a name="line.361"></a>
+<span class="sourceLineNo">362</span>          } else {<a name="line.362"></a>
+<span class="sourceLineNo">363</span>            setNextState(State.STATE_3);<a name="line.363"></a>
+<span class="sourceLineNo">364</span>          }<a name="line.364"></a>
+<span class="sourceLineNo">365</span>          iResult += 5;<a name="line.365"></a>
+<span class="sourceLineNo">366</span>          break;<a name="line.366"></a>
+<span class="sourceLineNo">367</span>        case STATE_3:<a name="line.367"></a>
+<span class="sourceLineNo">368</span>          LOG.info("execute step 3 " + this);<a name="line.368"></a>
+<span class="sourceLineNo">369</span>          Threads.sleepWithoutInterrupt(procSleepInterval);<a name="line.369"></a>
+<span class="sourceLineNo">370</span>          if (aborted.get()) {<a name="line.370"></a>
+<span class="sourceLineNo">371</span>            LOG.info("aborted step 3 " + this);<a name="line.371"></a>
+<span class="sourceLineNo">372</span>            setAbortFailure("test", "aborted");<a name="line.372"></a>
+<span class="sourceLineNo">373</span>            break;<a name="line.373"></a>
+<span class="sourceLineNo">374</span>          }<a name="line.374"></a>
+<span class="sourceLineNo">375</span>          setNextState(State.DONE);<a name="line.375"></a>
+<span class="sourceLineNo">376</span>          iResult += 7;<a name="line.376"></a>
+<span class="sourceLineNo">377</span>          break;<a name="line.377"></a>
+<span class="sourceLineNo">378</span>        case DONE:<a name="line.378"></a>
+<span class="sourceLineNo">379</span>          setResult(Bytes.toBytes(iResult));<a name="line.379"></a>
+<span class="sourceLineNo">380</span>          return Flow.NO_MORE_STATE;<a name="line.380"></a>
+<span class="sourceLineNo">381</span>        default:<a name="line.381"></a>
+<span class="sourceLineNo">382</span>          throw new UnsupportedOperationException();<a name="line.382"></a>
+<span class="sourceLineNo">383</span>      }<a name="line.383"></a>
+<span class="sourceLineNo">384</span>      return Flow.HAS_MORE_STATE;<a name="line.384"></a>
+<span class="sourceLineNo">385</span>    }<a name="line.385"></a>
+<span class="sourceLineNo">386</span><a name="line.386"></a>
+<span class="sourceLineNo">387</span>    @Override<a name="line.387"></a>
+<span class="sourceLineNo">388</span>    protected void rollbackState(TestProcEnv env, final State state) {<a name="line.388"></a>
+<span class="sourceLineNo">389</span>      switch (state) {<a name="line.389"></a>
+<span class="sourceLineNo">390</span>        case STATE_1:<a name="line.390"></a>
+<span class="sourceLineNo">391</span>          LOG.info("rollback step 1 " + this);<a name="line.391"></a>
+<span class="sourceLineNo">392</span>          break;<a name="line.392"></a>
+<span class="sourceLineNo">393</span>        case STATE_2:<a name="line.393"></a>
+<span class="sourceLineNo">394</span>          LOG.info("rollback step 2 " + this);<a name="line.394"></a>
+<span class="sourceLineNo">395</span>          break;<a name="line.395"></a>
+<span class="sourceLineNo">396</span>        case STATE_3:<a name="line.396"></a>
+<span class="sourceLineNo">397</span>          LOG.info("rollback step 3 " + this);<a name="line.397"></a>
+<span class="sourceLineNo">398</span>          break;<a name="line.398"></a>
+<span class="sourceLineNo">399</span>        default:<a name="line.399"></a>
+<span class="sourceLineNo">400</span>          throw new UnsupportedOperationException();<a name="line.400"></a>
+<span class="sourceLineNo">401</span>      }<a name="line.401"></a>
+<span class="sourceLineNo">402</span>    }<a name="line.402"></a>
+<span class="sourceLineNo">403</span><a name="line.403"></a>
+<span class="sourceLineNo">404</span>    @Override<a name="line.404"></a>
+<span class="sourceLineNo">405</span>    protected State getState(final int stateId) {<a name="line.405"></a>
+<span class="sourceLineNo">406</span>      return State.values()[stateId];<a name="line.406"></a>
+<span class="sourceLineNo">407</span>    }<a name="line.407"></a>
+<span class="sourceLineNo">408</span><a name="line.408"></a>
+<span class="sourceLineNo">409</span>    @Override<a name="line.409"></a>
+<span class="sourceLineNo">410</span>    protected int getStateId(final State state) {<a name="line.410"></a>
+<span class="sourceLineNo">411</span>      return state.ordinal();<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>    @Override<a name="line.414"></a>
+<span class="sourceLineNo">415</span>    protected State getInitialState() {<a name="line.415"></a>
+<span class="sourceLineNo">416</span>      return State.STATE_1;<a name="line.416"></a>
+<span class="sourceLineNo">417</span>    }<a name="line.417"></a>
+<span class="sourceLineNo">418</span><a name="line.418"></a>
+<span class="sourceLineNo">419</span>    @Override<a name="line.419"></a>
+<span class="sourceLineNo">420</span>    protected boolean abort(TestProcEnv env) {<a name="line.420"></a>
+<span class="sourceLineNo">421</span>      aborted.set(true);<a name="line.421"></a>
+<span class="sourceLineNo">422</span>      return true;<a name="line.422"></a>
+<span class="sourceLineNo">423</span>    }<a name="line.423"></a>
+<span class="sourceLineNo">424</span><a name="line.424"></a>
+<span class="sourceLineNo">425</span>    @Override<a name="line.425"></a>
+<span class="sourceLineNo">426</span>    protected void serializeStateData(final OutputStream stream) throws IOException {<a name="line.426"></a>
+<span class="sourceLineNo">427</span>      super.serializeStateData(stream);<a name="line.427"></a>
+<span class="sourceLineNo">428</span>      stream.write(Bytes.toBytes(iResult));<a name="line.428"></a>
+<span class="sourceLineNo">429</span>    }<a name="line.429"></a>
+<span class="sourceLineNo">430</span><a name="line.430"></a>
+<span class="sourceLineNo">431</span>    @Override<a name="line.431"></a>
+<span class="sourceLineNo">432</span>    protected void deserializeStateData(final InputStream stream) throws IOException {<a name="line.432"></a>
+<span class="sourceLineNo">433</span>      super.deserializeStateData(stream);<a name="line.433"></a>
+<span class="sourceLineNo">434</span>      byte[] data = new byte[4];<a name="line.434"></a>
+<span class="sourceLineNo">435</span>      stream.read(data);<a name="line.435"></a>
+<span class="sourceLineNo">436</span>      iResult = Bytes.toInt(data);<a name="line.436"></a>
+<span class="sourceLineNo">437</span>    }<a name="line.437"></a>
+<span class="sourceLineNo">438</span>  }<a name="line.438"></a>
+<span class="sourceLineNo">439</span><a name="line.439"></a>
+<span class="sourceLineNo">440</span>  @Test(timeout=30000)<a name="line.440"></a>
+<span class="sourceLineNo">441</span>  public void testStateMachineMultipleLevel() throws Exception {<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    long procId = procExecutor.submitProcedure(new TestStateMachineProcedure(true));<a name="line.442"></a>
+<span class="sourceLineNo">443</span>    // Wait the completion<a name="line.443"></a>
+<span class="sourceLineNo">444</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.444"></a>
+<span class="sourceLineNo">445</span>    ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);<a name="line.445"></a>
+<span class="sourceLineNo">446</span>  }<a name="line.446"></a>
+<span class="sourceLineNo">447</span><a name="line.447"></a>
+<span class="sourceLineNo">448</span>  @Test(timeout=30000)<a name="line.448"></a>
+<span class="sourceLineNo">449</span>  public void testStateMachineRecovery() throws Exception {<a name="line.449"></a>
+<span class="sourceLineNo">450</span>    ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExecutor, true);<a name="line.450"></a>
+<span class="sourceLineNo">451</span>    ProcedureTestingUtility.setKillBeforeStoreUpdate(procExecutor, true);<a name="line.451"></a>
+<span class="sourceLineNo">452</span><a name="line.452"></a>
+<span class="sourceLineNo">453</span>    // Step 1 - kill<a name="line.453"></a>
+<span class="sourceLineNo">454</span>    Procedure proc = new TestStateMachineProcedure();<a name="line.454"></a>
+<span class="sourceLineNo">455</span>    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);<a name="line.455"></a>
+<span class="sourceLineNo">456</span>    assertFalse(procExecutor.isRunning());<a name="line.456"></a>
+<span class="sourceLineNo">457</span><a name="line.457"></a>
+<span class="sourceLineNo">458</span>    // Step 1 exec &amp;&amp; Step 2 - kill<a name="line.458"></a>
+<span class="sourceLineNo">459</span>    restart();<a name="line.459"></a>
+<span class="sourceLineNo">460</span>    waitProcedure(procId);<a name="line.460"></a>
+<span class="sourceLineNo">461</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.461"></a>
+<span class="sourceLineNo">462</span>    assertFalse(procExecutor.isRunning());<a name="line.462"></a>
+<span class="sourceLineNo">463</span><a name="line.463"></a>
+<span class="sourceLineNo">464</span>    // Step 2 exec &amp;&amp; step 3 - kill<a name="line.464"></a>
+<span class="sourceLineNo">465</span>    restart();<a name="line.465"></a>
+<span class="sourceLineNo">466</span>    waitProcedure(procId);<a name="line.466"></a>
+<span class="sourceLineNo">467</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.467"></a>
+<span class="sourceLineNo">468</span>    assertFalse(procExecutor.isRunning());<a name="line.468"></a>
+<span class="sourceLineNo">469</span><a name="line.469"></a>
+<span class="sourceLineNo">470</span>    // Step 3 exec<a name="line.470"></a>
+<span class="sourceLineNo">471</span>    restart();<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    waitProcedure(procId);<a name="line.472"></a>
+<span class="sourceLineNo">473</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.473"></a>
+<span class="sourceLineNo">474</span>    assertFalse(procExecutor.isRunning());<a name="line.474"></a>
+<span class="sourceLineNo">475</span><a name="line.475"></a>
+<span class="sourceLineNo">476</span>    restart();<a name="line.476"></a>
+<span class="sourceLineNo">477</span>    waitProcedure(procId);<a name="line.477"></a>
+<span class="sourceLineNo">478</span>    assertTrue(procExecutor.isRunning());<a name="line.478"></a>
+<span class="sourceLineNo">479</span><a name="line.479"></a>
+<span class="sourceLineNo">480</span>    // The procedure is completed<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    ProcedureInfo result = procExecutor.getResult(procId);<a name="line.481"></a>
+<span class="sourceLineNo">482</span>    ProcedureTestingUtility.assertProcNotFailed(result);<a name="line.482"></a>
+<span class="sourceLineNo">483</span>    assertEquals(15, Bytes.toInt(result.getResult()));<a name="line.483"></a>
+<span class="sourceLineNo">484</span>  }<a name="line.484"></a>
+<span class="sourceLineNo">485</span><a name="line.485"></a>
+<span class="sourceLineNo">486</span>  @Test(timeout=30000)<a name="line.486"></a>
+<span class="sourceLineNo">487</span>  public void testStateMachineRollbackRecovery() throws Exception {<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExecutor, true);<a name="line.488"></a>
+<span class="sourceLineNo">489</span>    ProcedureTestingUtility.setKillBeforeStoreUpdate(procExecutor, true);<a name="line.489"></a>
 <span class="sourceLineNo">490</span><a name="line.490"></a>
-<span class="sourceLineNo">491</span>    // Rollback step 3 - rollback step 2 - kill<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    restart();<a name="line.492"></a>
-<span class="sourceLineNo">493</span>    waitProcedure(procId);<a name="line.493"></a>
-<span class="sourceLineNo">494</span>    assertFalse(procExecutor.isRunning());<a name="line.494"></a>
-<span class="sourceLineNo">495</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.495"></a>
+<span class="sourceLineNo">491</span>    // Step 1 - kill<a name="line.491"></a>
+<span class="sourceLineNo">492</span>    Procedure proc = new TestStateMachineProcedure();<a name="line.492"></a>
+<span class="sourceLineNo">493</span>    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);<a name="line.493"></a>
+<span class="sourceLineNo">494</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    assertFalse(procExecutor.isRunning());<a name="line.495"></a>
 <span class="sourceLineNo">496</span><a name="line.496"></a>
-<span class="sourceLineNo">497</span>    // Rollback step 2 - step 1 - kill<a name="line.497"></a>
+<span class="sourceLineNo">497</span>    // Step 1 exec &amp;&amp; Step 2 - kill<a name="line.497"></a>
 <span class="sourceLineNo">498</span>    restart();<a name="line.498"></a>
 <span class="sourceLineNo">499</span>    waitProcedure(procId);<a name="line.499"></a>
-<span class="sourceLineNo">500</span>    assertFalse(procExecutor.isRunning());<a name="line.500"></a>
-<span class="sourceLineNo">501</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.501"></a>
+<span class="sourceLineNo">500</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.500"></a>
+<span class="sourceLineNo">501</span>    assertFalse(procExecutor.isRunning());<a name="line.501"></a>
 <span class="sourceLineNo">502</span><a name="line.502"></a>
-<span class="sourceLineNo">503</span>    // Rollback step 1 - complete<a name="line.503"></a>
+<span class="sourceLineNo">503</span>    // Step 2 exec &amp;&amp; step 3 - kill<a name="line.503"></a>
 <span class="sourceLineNo">504</span>    restart();<a name="line.504"></a>
 <span class="sourceLineNo">505</span>    waitProcedure(procId);<a name="line.505"></a>
-<span class="sourceLineNo">506</span>    assertTrue(procExecutor.isRunning());<a name="line.506"></a>
-<span class="sourceLineNo">507</span><a name="line.507"></a>
-<span class="sourceLineNo">508</span>    // The procedure is completed<a name="line.508"></a>
-<span class="sourceLineNo">509</span>    ProcedureInfo result = procExecutor.getResult(procId);<a name="line.509"></a>
-<span class="sourceLineNo">510</span>    ProcedureTestingUtility.assertIsAbortException(result);<a name="line.510"></a>
-<span class="sourceLineNo">511</span>  }<a name="line.511"></a>
-<span class="sourceLineNo">512</span><a name="line.512"></a>
-<span class="sourceLineNo">513</span>  private void waitProcedure(final long procId) {<a name="line.513"></a>
-<span class="sourceLineNo">514</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.514"></a>
-<span class="sourceLineNo">515</span>    dumpLogDirState();<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>  private void dumpLogDirState() {<a name="line.518"></a>
-<span class="sourceLineNo">519</span>    try {<a name="line.519"></a>
-<span class="sourceLineNo">520</span>      FileStatus[] files = fs.listStatus(logDir);<a name="line.520"></a>
-<span class="sourceLineNo">521</span>      if (files != null &amp;&amp; files.length &gt; 0) {<a name="line.521"></a>
-<span class="sourceLineNo">522</span>        for (FileStatus file: files) {<a name="line.522"></a>
-<span class="sourceLineNo">523</span>          assertTrue(file.toString(), file.isFile());<a name="line.523"></a>
-<span class="sourceLineNo">524</span>          LOG.debug("log file " + file.getPath() + " size=" + file.getLen());<a name="line.524"></a>
-<span class="sourceLineNo">525</span>        }<a name="line.525"></a>
-<span class="sourceLineNo">526</span>      } else {<a name="line.526"></a>
-<span class="sourceLineNo">527</span>        LOG.debug("no files under: " + logDir);<a name="line.527"></a>
-<span class="sourceLineNo">528</span>      }<a name="line.528"></a>
-<span class="sourceLineNo">529</span>    } catch (IOException e) {<a name="line.529"></a>
-<span class="sourceLineNo">530</span>      LOG.warn("Unable to dump " + logDir, e);<a name="line.530"></a>
-<span class="sourceLineNo">531</span>    }<a name="line.531"></a>
-<span class="sourceLineNo">532</span>  }<a name="line.532"></a>
+<span class="sourceLineNo">506</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.506"></a>
+<span class="sourceLineNo">507</span>    assertFalse(procExecutor.isRunning());<a name="line.507"></a>
+<span class="sourceLineNo">508</span><a name="line.508"></a>
+<span class="sourceLineNo">509</span>    // Step 3 exec - rollback step 3 - kill<a name="line.509"></a>
+<span class="sourceLineNo">510</span>    procSleepInterval = 2500;<a name="line.510"></a>
+<span class="sourceLineNo">511</span>    restart();<a name="line.511"></a>
+<span class="sourceLineNo">512</span>    assertTrue(procExecutor.abort(procId));<a name="line.512"></a>
+<span class="sourceLineNo">513</span>    waitProcedure(procId);<a name="line.513"></a>
+<span class="sourceLineNo">514</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.514"></a>
+<span class="sourceLineNo">515</span>    assertFalse(procExecutor.isRunning());<a name="line.515"></a>
+<span class="sourceLineNo">516</span><a name="line.516"></a>
+<span class="sourceLineNo">517</span>    // Rollback step 3 - rollback step 2 - kill<a name="line.517"></a>
+<span class="sourceLineNo">518</span>    restart();<a name="line.518"></a>
+<span class="sourceLineNo">519</span>    waitProcedure(procId);<a name="line.519"></a>
+<span class="sourceLineNo">520</span>    assertFalse(procExecutor.isRunning());<a name="line.520"></a>
+<span class="sourceLineNo">521</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.521"></a>
+<span class="sourceLineNo">522</span><a name="line.522"></a>
+<span class="sourceLineNo">523</span>    // Rollback step 2 - step 1 - kill<a name="line.523"></a>
+<span class="sourceLineNo">524</span>    restart();<a name="line.524"></a>
+<span class="sourceLineNo">525</span>    waitProcedure(procId);<a name="line.525"></a>
+<span class="sourceLineNo">526</span>    assertFalse(procExecutor.isRunning());<a name="line.526"></a>
+<span class="sourceLineNo">527</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.527"></a>
+<span class="sourceLineNo">528</span><a name="line.528"></a>
+<span class="sourceLineNo">529</span>    // Rollback step 1 - complete<a name="line.529"></a>
+<span class="sourceLineNo">530</span>    restart();<a name="line.530"></a>
+<span class="sourceLineNo">531</span>    waitProcedure(procId);<a name="line.531"></a>
+<span class="sourceLineNo">532</span>    assertTrue(procExecutor.isRunning());<a name="line.532"></a>
 <span class="sourceLineNo">533</span><a name="line.533"></a>
-<span class="sourceLineNo">534</span>  private static class TestProcEnv {<a name="line.534"></a>
-<span class="sourceLineNo">535</span>    private CountDownLatch latch = null;<a name="line.535"></a>
-<span class="sourceLineNo">536</span><a name="line.536"></a>
-<span class="sourceLineNo">537</span>    /**<a name="line.537"></a>
-<span class="sourceLineNo">538</span>     * set/unset a latch. every procedure execute() step will wait on the latch if any.<a name="line.538"></a>
-<span class="sourceLineNo">539</span>     */<a name="line.539"></a>
-<span class="sourceLineNo">540</span>    public void setWaitLatch(CountDownLatch latch) {<a name="line.540"></a>
-<span class="sourceLineNo">541</span>      this.latch = latch;<a name="line.541"></a>
-<span class="sourceLineNo">542</span>    }<a name="line.542"></a>
+<span class="sourceLineNo">534</span>    // The procedure is completed<a name="line.534"></a>
+<span class="sourceLineNo">535</span>    ProcedureInfo result = procExecutor.getResult(procId);<a name="line.535"></a>
+<span class="sourceLineNo">536</span>    ProcedureTestingUtility.assertIsAbortException(result);<a name="line.536"></a>
+<span class="sourceLineNo">537</span>  }<a name="line.537"></a>
+<span class="sourceLineNo">538</span><a name="line.538"></a>
+<span class="sourceLineNo">539</span>  private void waitProcedure(final long procId) {<a name="line.539"></a>
+<span class="sourceLineNo">540</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.540"></a>
+<span class="sourceLineNo">541</span>    dumpLogDirState();<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>    public void waitOnLatch() throws InterruptedException {<a name="line.544"></a>
-<span class="sourceLineNo">545</span>      if (latch != null) {<a name="line.545"></a>
-<span class="sourceLineNo">546</span>        latch.await();<a name="line.546"></a>
-<span class="sourceLineNo">547</span>      }<a name="line.547"></a>
-<span class="sourceLineNo">548</span>    }<a name="line.548"></a>
-<span class="sourceLineNo">549</span>  }<a name="line.549"></a>
-<span class="sourceLineNo">550</span>}<a name="line.550"></a>
+<span class="sourceLineNo">544</span>  private void dumpLogDirState() {<a name="line.544"></a>
+<span class="sourceLineNo">545</span>    try {<a name="line.545"></a>
+<span class="sourceLineNo">546</span>      FileStatus[] files = fs.listStatus(logDir);<a name="line.546"></a>
+<span class="sourceLineNo">547</span>      if (files != null &amp;&amp; files.length &gt; 0) {<a name="line.547"></a>
+<span class="sourceLineNo">548</span>        for (FileStatus file: files) {<a name="line.548"></a>
+<span class="sourceLineNo">549</span>          assertTrue(file.toString(), file.isFile());<a name="line.549"></a>
+<span class="sourceLineNo">550</span>          LOG.debug("log file " + file.getPath() + " size=" + file.getLen());<a name="line.550"></a>
+<span class="sourceLineNo">551</span>        }<a name="line.551"></a>
+<span class="sourceLineNo">552</span>      } else {<a name="line.552"></a>
+<span class="sourceLineNo">553</span>        LOG.debug("no files under: " + logDir);<a name="line.553"></a>
+<span class="sourceLineNo">554</span>      }<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    } catch (IOException e) {<a name="line.555"></a>
+<span class="sourceLineNo">556</span>      LOG.warn("Unable to dump " + logDir, e);<a name="line.556"></a>
+<span class="sourceLineNo">557</span>    }<a name="line.557"></a>
+<span class="sourceLineNo">558</span>  }<a name="line.558"></a>
+<span class="sourceLineNo">559</span><a name="line.559"></a>
+<span class="sourceLineNo">560</span>  private static class TestProcEnv {<a name="line.560"></a>
+<span class="sourceLineNo">561</span>    private CountDownLatch latch = null;<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>     * set/unset a latch. every procedure execute() step will wait on the latch if any.<a name="line.564"></a>
+<span class="sourceLineNo">565</span>     */<a name="line.565"></a>
+<span class="sourceLineNo">566</span>    public void setWaitLatch(CountDownLatch latch) {<a name="line.566"></a>
+<span class="sourceLineNo">567</span>      this.latch = latch;<a name="line.567"></a>
+<span class="sourceLineNo">568</span>    }<a name="line.568"></a>
+<span class="sourceLineNo">569</span><a name="line.569"></a>
+<span class="sourceLineNo">570</span>    public void waitOnLatch() throws InterruptedException {<a name="line.570"></a>
+<span class="sourceLineNo">571</span>      if (latch != null) {<a name="line.571"></a>
+<span class="sourceLineNo">572</span>        latch.await();<a name="line.572"></a>
+<span class="sourceLineNo">573</span>      }<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>}<a name="line.576"></a>
 
 
 

http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestSingleStepProcedure.html
----------------------------------------------------------------------
diff --git a/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestSingleStepProcedure.html b/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestSingleStepProcedure.html
index 9fdc021..b3a6ee0 100644
--- a/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestSingleStepProcedure.html
+++ b/testdevapidocs/src-html/org/apache/hadoop/hbase/procedure2/TestProcedureRecovery.TestSingleStepProcedure.html
@@ -345,217 +345,243 @@
 <span class="sourceLineNo">337</span><a name="line.337"></a>
 <span class="sourceLineNo">338</span>    public TestStateMachineProcedure() {}<a name="line.338"></a>
 <span class="sourceLineNo">339</span><a name="line.339"></a>
-<span class="sourceLineNo">340</span>    private AtomicBoolean aborted = new AtomicBoolean(false);<a name="line.340"></a>
-<span class="sourceLineNo">341</span>    private int iResult = 0;<a name="line.341"></a>
-<span class="sourceLineNo">342</span><a name="line.342"></a>
-<span class="sourceLineNo">343</span>    @Override<a name="line.343"></a>
-<span class="sourceLineNo">344</span>    protected StateMachineProcedure.Flow executeFromState(TestProcEnv env, State state) {<a name="line.344"></a>
-<span class="sourceLineNo">345</span>      switch (state) {<a name="line.345"></a>
-<span class="sourceLineNo">346</span>        case STATE_1:<a name="line.346"></a>
-<span class="sourceLineNo">347</span>          LOG.info("execute step 1 " + this);<a name="line.347"></a>
-<span class="sourceLineNo">348</span>          setNextState(State.STATE_2);<a name="line.348"></a>
-<span class="sourceLineNo">349</span>          iResult += 3;<a name="line.349"></a>
-<span class="sourceLineNo">350</span>          break;<a name="line.350"></a>
-<span class="sourceLineNo">351</span>        case STATE_2:<a name="line.351"></a>
-<span class="sourceLineNo">352</span>          LOG.info("execute step 2 " + this);<a name="line.352"></a>
-<span class="sourceLineNo">353</span>          setNextState(State.STATE_3);<a name="line.353"></a>
-<span class="sourceLineNo">354</span>          iResult += 5;<a name="line.354"></a>
+<span class="sourceLineNo">340</span>    public TestStateMachineProcedure(final boolean testSubmitChildProc) {<a name="line.340"></a>
+<span class="sourceLineNo">341</span>      this.submitChildProc = testSubmitChildProc;<a name="line.341"></a>
+<span class="sourceLineNo">342</span>    }<a name="line.342"></a>
+<span class="sourceLineNo">343</span><a name="line.343"></a>
+<span class="sourceLineNo">344</span>    private AtomicBoolean aborted = new AtomicBoolean(false);<a name="line.344"></a>
+<span class="sourceLineNo">345</span>    private int iResult = 0;<a name="line.345"></a>
+<span class="sourceLineNo">346</span>    private boolean submitChildProc = false;<a name="line.346"></a>
+<span class="sourceLineNo">347</span><a name="line.347"></a>
+<span class="sourceLineNo">348</span>    @Override<a name="line.348"></a>
+<span class="sourceLineNo">349</span>    protected StateMachineProcedure.Flow executeFromState(TestProcEnv env, State state) {<a name="line.349"></a>
+<span class="sourceLineNo">350</span>      switch (state) {<a name="line.350"></a>
+<span class="sourceLineNo">351</span>        case STATE_1:<a name="line.351"></a>
+<span class="sourceLineNo">352</span>          LOG.info("execute step 1 " + this);<a name="line.352"></a>
+<span class="sourceLineNo">353</span>          setNextState(State.STATE_2);<a name="line.353"></a>
+<span class="sourceLineNo">354</span>          iResult += 3;<a name="line.354"></a>
 <span class="sourceLineNo">355</span>          break;<a name="line.355"></a>
-<span class="sourceLineNo">356</span>        case STATE_3:<a name="line.356"></a>
-<span class="sourceLineNo">357</span>          LOG.info("execute step 3 " + this);<a name="line.357"></a>
-<span class="sourceLineNo">358</span>          Threads.sleepWithoutInterrupt(procSleepInterval);<a name="line.358"></a>
-<span class="sourceLineNo">359</span>          if (aborted.get()) {<a name="line.359"></a>
-<span class="sourceLineNo">360</span>            LOG.info("aborted step 3 " + this);<a name="line.360"></a>
-<span class="sourceLineNo">361</span>            setAbortFailure("test", "aborted");<a name="line.361"></a>
-<span class="sourceLineNo">362</span>            break;<a name="line.362"></a>
-<span class="sourceLineNo">363</span>          }<a name="line.363"></a>
-<span class="sourceLineNo">364</span>          setNextState(State.DONE);<a name="line.364"></a>
-<span class="sourceLineNo">365</span>          iResult += 7;<a name="line.365"></a>
-<span class="sourceLineNo">366</span>          setResult(Bytes.toBytes(iResult));<a name="line.366"></a>
-<span class="sourceLineNo">367</span>          return Flow.NO_MORE_STATE;<a name="line.367"></a>
-<span class="sourceLineNo">368</span>        default:<a name="line.368"></a>
-<span class="sourceLineNo">369</span>          throw new UnsupportedOperationException();<a name="line.369"></a>
-<span class="sourceLineNo">370</span>      }<a name="line.370"></a>
-<span class="sourceLineNo">371</span>      return Flow.HAS_MORE_STATE;<a name="line.371"></a>
-<span class="sourceLineNo">372</span>    }<a name="line.372"></a>
-<span class="sourceLineNo">373</span><a name="line.373"></a>
-<span class="sourceLineNo">374</span>    @Override<a name="line.374"></a>
-<span class="sourceLineNo">375</span>    protected void rollbackState(TestProcEnv env, final State state) {<a name="line.375"></a>
-<span class="sourceLineNo">376</span>      switch (state) {<a name="line.376"></a>
-<span class="sourceLineNo">377</span>        case STATE_1:<a name="line.377"></a>
-<span class="sourceLineNo">378</span>          LOG.info("rollback step 1 " + this);<a name="line.378"></a>
-<span class="sourceLineNo">379</span>          break;<a name="line.379"></a>
-<span class="sourceLineNo">380</span>        case STATE_2:<a name="line.380"></a>
-<span class="sourceLineNo">381</span>          LOG.info("rollback step 2 " + this);<a name="line.381"></a>
-<span class="sourceLineNo">382</span>          break;<a name="line.382"></a>
-<span class="sourceLineNo">383</span>        case STATE_3:<a name="line.383"></a>
-<span class="sourceLineNo">384</span>          LOG.info("rollback step 3 " + this);<a name="line.384"></a>
-<span class="sourceLineNo">385</span>          break;<a name="line.385"></a>
-<span class="sourceLineNo">386</span>        default:<a name="line.386"></a>
-<span class="sourceLineNo">387</span>          throw new UnsupportedOperationException();<a name="line.387"></a>
-<span class="sourceLineNo">388</span>      }<a name="line.388"></a>
-<span class="sourceLineNo">389</span>    }<a name="line.389"></a>
-<span class="sourceLineNo">390</span><a name="line.390"></a>
-<span class="sourceLineNo">391</span>    @Override<a name="line.391"></a>
-<span class="sourceLineNo">392</span>    protected State getState(final int stateId) {<a name="line.392"></a>
-<span class="sourceLineNo">393</span>      return State.values()[stateId];<a name="line.393"></a>
-<span class="sourceLineNo">394</span>    }<a name="line.394"></a>
-<span class="sourceLineNo">395</span><a name="line.395"></a>
-<span class="sourceLineNo">396</span>    @Override<a name="line.396"></a>
-<span class="sourceLineNo">397</span>    protected int getStateId(final State state) {<a name="line.397"></a>
-<span class="sourceLineNo">398</span>      return state.ordinal();<a name="line.398"></a>
-<span class="sourceLineNo">399</span>    }<a name="line.399"></a>
-<span class="sourceLineNo">400</span><a name="line.400"></a>
-<span class="sourceLineNo">401</span>    @Override<a name="line.401"></a>
-<span class="sourceLineNo">402</span>    protected State getInitialState() {<a name="line.402"></a>
-<span class="sourceLineNo">403</span>      return State.STATE_1;<a name="line.403"></a>
-<span class="sourceLineNo">404</span>    }<a name="line.404"></a>
-<span class="sourceLineNo">405</span><a name="line.405"></a>
-<span class="sourceLineNo">406</span>    @Override<a name="line.406"></a>
-<span class="sourceLineNo">407</span>    protected boolean abort(TestProcEnv env) {<a name="line.407"></a>
-<span class="sourceLineNo">408</span>      aborted.set(true);<a name="line.408"></a>
-<span class="sourceLineNo">409</span>      return true;<a name="line.409"></a>
-<span class="sourceLineNo">410</span>    }<a name="line.410"></a>
-<span class="sourceLineNo">411</span><a name="line.411"></a>
-<span class="sourceLineNo">412</span>    @Override<a name="line.412"></a>
-<span class="sourceLineNo">413</span>    protected void serializeStateData(final OutputStream stream) throws IOException {<a name="line.413"></a>
-<span class="sourceLineNo">414</span>      super.serializeStateData(stream);<a name="line.414"></a>
-<span class="sourceLineNo">415</span>      stream.write(Bytes.toBytes(iResult));<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>    @Override<a name="line.418"></a>
-<span class="sourceLineNo">419</span>    protected void deserializeStateData(final InputStream stream) throws IOException {<a name="line.419"></a>
-<span class="sourceLineNo">420</span>      super.deserializeStateData(stream);<a name="line.420"></a>
-<span class="sourceLineNo">421</span>      byte[] data = new byte[4];<a name="line.421"></a>
-<span class="sourceLineNo">422</span>      stream.read(data);<a name="line.422"></a>
-<span class="sourceLineNo">423</span>      iResult = Bytes.toInt(data);<a name="line.423"></a>
-<span class="sourceLineNo">424</span>    }<a name="line.424"></a>
-<span class="sourceLineNo">425</span>  }<a name="line.425"></a>
-<span class="sourceLineNo">426</span><a name="line.426"></a>
-<span class="sourceLineNo">427</span>  @Test(timeout=30000)<a name="line.427"></a>
-<span class="sourceLineNo">428</span>  public void testStateMachineRecovery() throws Exception {<a name="line.428"></a>
-<span class="sourceLineNo">429</span>    ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExecutor, true);<a name="line.429"></a>
-<span class="sourceLineNo">430</span>    ProcedureTestingUtility.setKillBeforeStoreUpdate(procExecutor, true);<a name="line.430"></a>
-<span class="sourceLineNo">431</span><a name="line.431"></a>
-<span class="sourceLineNo">432</span>    // Step 1 - kill<a name="line.432"></a>
-<span class="sourceLineNo">433</span>    Procedure proc = new TestStateMachineProcedure();<a name="line.433"></a>
-<span class="sourceLineNo">434</span>    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);<a name="line.434"></a>
-<span class="sourceLineNo">435</span>    assertFalse(procExecutor.isRunning());<a name="line.435"></a>
-<span class="sourceLineNo">436</span><a name="line.436"></a>
-<span class="sourceLineNo">437</span>    // Step 1 exec &amp;&amp; Step 2 - kill<a name="line.437"></a>
-<span class="sourceLineNo">438</span>    restart();<a name="line.438"></a>
-<span class="sourceLineNo">439</span>    waitProcedure(procId);<a name="line.439"></a>
-<span class="sourceLineNo">440</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.440"></a>
-<span class="sourceLineNo">441</span>    assertFalse(procExecutor.isRunning());<a name="line.441"></a>
-<span class="sourceLineNo">442</span><a name="line.442"></a>
-<span class="sourceLineNo">443</span>    // Step 2 exec &amp;&amp; step 3 - kill<a name="line.443"></a>
-<span class="sourceLineNo">444</span>    restart();<a name="line.444"></a>
-<span class="sourceLineNo">445</span>    waitProcedure(procId);<a name="line.445"></a>
-<span class="sourceLineNo">446</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.446"></a>
-<span class="sourceLineNo">447</span>    assertFalse(procExecutor.isRunning());<a name="line.447"></a>
-<span class="sourceLineNo">448</span><a name="line.448"></a>
-<span class="sourceLineNo">449</span>    // Step 3 exec<a name="line.449"></a>
-<span class="sourceLineNo">450</span>    restart();<a name="line.450"></a>
-<span class="sourceLineNo">451</span>    waitProcedure(procId);<a name="line.451"></a>
-<span class="sourceLineNo">452</span>    assertTrue(procExecutor.isRunning());<a name="line.452"></a>
-<span class="sourceLineNo">453</span><a name="line.453"></a>
-<span class="sourceLineNo">454</span>    // The procedure is completed<a name="line.454"></a>
-<span class="sourceLineNo">455</span>    ProcedureInfo result = procExecutor.getResult(procId);<a name="line.455"></a>
-<span class="sourceLineNo">456</span>    ProcedureTestingUtility.assertProcNotFailed(result);<a name="line.456"></a>
-<span class="sourceLineNo">457</span>    assertEquals(15, Bytes.toInt(result.getResult()));<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>  @Test(timeout=30000)<a name="line.460"></a>
-<span class="sourceLineNo">461</span>  public void testStateMachineRollbackRecovery() throws Exception {<a name="line.461"></a>
-<span class="sourceLineNo">462</span>    ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExecutor, true);<a name="line.462"></a>
-<span class="sourceLineNo">463</span>    ProcedureTestingUtility.setKillBeforeStoreUpdate(procExecutor, true);<a name="line.463"></a>
-<span class="sourceLineNo">464</span><a name="line.464"></a>
-<span class="sourceLineNo">465</span>    // Step 1 - kill<a name="line.465"></a>
-<span class="sourceLineNo">466</span>    Procedure proc = new TestStateMachineProcedure();<a name="line.466"></a>
-<span class="sourceLineNo">467</span>    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);<a name="line.467"></a>
-<span class="sourceLineNo">468</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.468"></a>
-<span class="sourceLineNo">469</span>    assertFalse(procExecutor.isRunning());<a name="line.469"></a>
-<span class="sourceLineNo">470</span><a name="line.470"></a>
-<span class="sourceLineNo">471</span>    // Step 1 exec &amp;&amp; Step 2 - kill<a name="line.471"></a>
-<span class="sourceLineNo">472</span>    restart();<a name="line.472"></a>
-<span class="sourceLineNo">473</span>    waitProcedure(procId);<a name="line.473"></a>
-<span class="sourceLineNo">474</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.474"></a>
-<span class="sourceLineNo">475</span>    assertFalse(procExecutor.isRunning());<a name="line.475"></a>
-<span class="sourceLineNo">476</span><a name="line.476"></a>
-<span class="sourceLineNo">477</span>    // Step 2 exec &amp;&amp; step 3 - kill<a name="line.477"></a>
-<span class="sourceLineNo">478</span>    restart();<a name="line.478"></a>
-<span class="sourceLineNo">479</span>    waitProcedure(procId);<a name="line.479"></a>
-<span class="sourceLineNo">480</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.480"></a>
-<span class="sourceLineNo">481</span>    assertFalse(procExecutor.isRunning());<a name="line.481"></a>
-<span class="sourceLineNo">482</span><a name="line.482"></a>
-<span class="sourceLineNo">483</span>    // Step 3 exec - rollback step 3 - kill<a name="line.483"></a>
-<span class="sourceLineNo">484</span>    procSleepInterval = 2500;<a name="line.484"></a>
-<span class="sourceLineNo">485</span>    restart();<a name="line.485"></a>
-<span class="sourceLineNo">486</span>    assertTrue(procExecutor.abort(procId));<a name="line.486"></a>
-<span class="sourceLineNo">487</span>    waitProcedure(procId);<a name="line.487"></a>
-<span class="sourceLineNo">488</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.488"></a>
-<span class="sourceLineNo">489</span>    assertFalse(procExecutor.isRunning());<a name="line.489"></a>
+<span class="sourceLineNo">356</span>        case STATE_2:<a name="line.356"></a>
+<span class="sourceLineNo">357</span>          LOG.info("execute step 2 " + this);<a name="line.357"></a>
+<span class="sourceLineNo">358</span>          if (submitChildProc) {<a name="line.358"></a>
+<span class="sourceLineNo">359</span>            addChildProcedure(new TestStateMachineProcedure());<a name="line.359"></a>
+<span class="sourceLineNo">360</span>            addChildProcedure(new TestStateMachineProcedure());<a name="line.360"></a>
+<span class="sourceLineNo">361</span>            setNextState(State.DONE);<a name="line.361"></a>
+<span class="sourceLineNo">362</span>          } else {<a name="line.362"></a>
+<span class="sourceLineNo">363</span>            setNextState(State.STATE_3);<a name="line.363"></a>
+<span class="sourceLineNo">364</span>          }<a name="line.364"></a>
+<span class="sourceLineNo">365</span>          iResult += 5;<a name="line.365"></a>
+<span class="sourceLineNo">366</span>          break;<a name="line.366"></a>
+<span class="sourceLineNo">367</span>        case STATE_3:<a name="line.367"></a>
+<span class="sourceLineNo">368</span>          LOG.info("execute step 3 " + this);<a name="line.368"></a>
+<span class="sourceLineNo">369</span>          Threads.sleepWithoutInterrupt(procSleepInterval);<a name="line.369"></a>
+<span class="sourceLineNo">370</span>          if (aborted.get()) {<a name="line.370"></a>
+<span class="sourceLineNo">371</span>            LOG.info("aborted step 3 " + this);<a name="line.371"></a>
+<span class="sourceLineNo">372</span>            setAbortFailure("test", "aborted");<a name="line.372"></a>
+<span class="sourceLineNo">373</span>            break;<a name="line.373"></a>
+<span class="sourceLineNo">374</span>          }<a name="line.374"></a>
+<span class="sourceLineNo">375</span>          setNextState(State.DONE);<a name="line.375"></a>
+<span class="sourceLineNo">376</span>          iResult += 7;<a name="line.376"></a>
+<span class="sourceLineNo">377</span>          break;<a name="line.377"></a>
+<span class="sourceLineNo">378</span>        case DONE:<a name="line.378"></a>
+<span class="sourceLineNo">379</span>          setResult(Bytes.toBytes(iResult));<a name="line.379"></a>
+<span class="sourceLineNo">380</span>          return Flow.NO_MORE_STATE;<a name="line.380"></a>
+<span class="sourceLineNo">381</span>        default:<a name="line.381"></a>
+<span class="sourceLineNo">382</span>          throw new UnsupportedOperationException();<a name="line.382"></a>
+<span class="sourceLineNo">383</span>      }<a name="line.383"></a>
+<span class="sourceLineNo">384</span>      return Flow.HAS_MORE_STATE;<a name="line.384"></a>
+<span class="sourceLineNo">385</span>    }<a name="line.385"></a>
+<span class="sourceLineNo">386</span><a name="line.386"></a>
+<span class="sourceLineNo">387</span>    @Override<a name="line.387"></a>
+<span class="sourceLineNo">388</span>    protected void rollbackState(TestProcEnv env, final State state) {<a name="line.388"></a>
+<span class="sourceLineNo">389</span>      switch (state) {<a name="line.389"></a>
+<span class="sourceLineNo">390</span>        case STATE_1:<a name="line.390"></a>
+<span class="sourceLineNo">391</span>          LOG.info("rollback step 1 " + this);<a name="line.391"></a>
+<span class="sourceLineNo">392</span>          break;<a name="line.392"></a>
+<span class="sourceLineNo">393</span>        case STATE_2:<a name="line.393"></a>
+<span class="sourceLineNo">394</span>          LOG.info("rollback step 2 " + this);<a name="line.394"></a>
+<span class="sourceLineNo">395</span>          break;<a name="line.395"></a>
+<span class="sourceLineNo">396</span>        case STATE_3:<a name="line.396"></a>
+<span class="sourceLineNo">397</span>          LOG.info("rollback step 3 " + this);<a name="line.397"></a>
+<span class="sourceLineNo">398</span>          break;<a name="line.398"></a>
+<span class="sourceLineNo">399</span>        default:<a name="line.399"></a>
+<span class="sourceLineNo">400</span>          throw new UnsupportedOperationException();<a name="line.400"></a>
+<span class="sourceLineNo">401</span>      }<a name="line.401"></a>
+<span class="sourceLineNo">402</span>    }<a name="line.402"></a>
+<span class="sourceLineNo">403</span><a name="line.403"></a>
+<span class="sourceLineNo">404</span>    @Override<a name="line.404"></a>
+<span class="sourceLineNo">405</span>    protected State getState(final int stateId) {<a name="line.405"></a>
+<span class="sourceLineNo">406</span>      return State.values()[stateId];<a name="line.406"></a>
+<span class="sourceLineNo">407</span>    }<a name="line.407"></a>
+<span class="sourceLineNo">408</span><a name="line.408"></a>
+<span class="sourceLineNo">409</span>    @Override<a name="line.409"></a>
+<span class="sourceLineNo">410</span>    protected int getStateId(final State state) {<a name="line.410"></a>
+<span class="sourceLineNo">411</span>      return state.ordinal();<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>    @Override<a name="line.414"></a>
+<span class="sourceLineNo">415</span>    protected State getInitialState() {<a name="line.415"></a>
+<span class="sourceLineNo">416</span>      return State.STATE_1;<a name="line.416"></a>
+<span class="sourceLineNo">417</span>    }<a name="line.417"></a>
+<span class="sourceLineNo">418</span><a name="line.418"></a>
+<span class="sourceLineNo">419</span>    @Override<a name="line.419"></a>
+<span class="sourceLineNo">420</span>    protected boolean abort(TestProcEnv env) {<a name="line.420"></a>
+<span class="sourceLineNo">421</span>      aborted.set(true);<a name="line.421"></a>
+<span class="sourceLineNo">422</span>      return true;<a name="line.422"></a>
+<span class="sourceLineNo">423</span>    }<a name="line.423"></a>
+<span class="sourceLineNo">424</span><a name="line.424"></a>
+<span class="sourceLineNo">425</span>    @Override<a name="line.425"></a>
+<span class="sourceLineNo">426</span>    protected void serializeStateData(final OutputStream stream) throws IOException {<a name="line.426"></a>
+<span class="sourceLineNo">427</span>      super.serializeStateData(stream);<a name="line.427"></a>
+<span class="sourceLineNo">428</span>      stream.write(Bytes.toBytes(iResult));<a name="line.428"></a>
+<span class="sourceLineNo">429</span>    }<a name="line.429"></a>
+<span class="sourceLineNo">430</span><a name="line.430"></a>
+<span class="sourceLineNo">431</span>    @Override<a name="line.431"></a>
+<span class="sourceLineNo">432</span>    protected void deserializeStateData(final InputStream stream) throws IOException {<a name="line.432"></a>
+<span class="sourceLineNo">433</span>      super.deserializeStateData(stream);<a name="line.433"></a>
+<span class="sourceLineNo">434</span>      byte[] data = new byte[4];<a name="line.434"></a>
+<span class="sourceLineNo">435</span>      stream.read(data);<a name="line.435"></a>
+<span class="sourceLineNo">436</span>      iResult = Bytes.toInt(data);<a name="line.436"></a>
+<span class="sourceLineNo">437</span>    }<a name="line.437"></a>
+<span class="sourceLineNo">438</span>  }<a name="line.438"></a>
+<span class="sourceLineNo">439</span><a name="line.439"></a>
+<span class="sourceLineNo">440</span>  @Test(timeout=30000)<a name="line.440"></a>
+<span class="sourceLineNo">441</span>  public void testStateMachineMultipleLevel() throws Exception {<a name="line.441"></a>
+<span class="sourceLineNo">442</span>    long procId = procExecutor.submitProcedure(new TestStateMachineProcedure(true));<a name="line.442"></a>
+<span class="sourceLineNo">443</span>    // Wait the completion<a name="line.443"></a>
+<span class="sourceLineNo">444</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.444"></a>
+<span class="sourceLineNo">445</span>    ProcedureTestingUtility.assertProcNotFailed(procExecutor, procId);<a name="line.445"></a>
+<span class="sourceLineNo">446</span>  }<a name="line.446"></a>
+<span class="sourceLineNo">447</span><a name="line.447"></a>
+<span class="sourceLineNo">448</span>  @Test(timeout=30000)<a name="line.448"></a>
+<span class="sourceLineNo">449</span>  public void testStateMachineRecovery() throws Exception {<a name="line.449"></a>
+<span class="sourceLineNo">450</span>    ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExecutor, true);<a name="line.450"></a>
+<span class="sourceLineNo">451</span>    ProcedureTestingUtility.setKillBeforeStoreUpdate(procExecutor, true);<a name="line.451"></a>
+<span class="sourceLineNo">452</span><a name="line.452"></a>
+<span class="sourceLineNo">453</span>    // Step 1 - kill<a name="line.453"></a>
+<span class="sourceLineNo">454</span>    Procedure proc = new TestStateMachineProcedure();<a name="line.454"></a>
+<span class="sourceLineNo">455</span>    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);<a name="line.455"></a>
+<span class="sourceLineNo">456</span>    assertFalse(procExecutor.isRunning());<a name="line.456"></a>
+<span class="sourceLineNo">457</span><a name="line.457"></a>
+<span class="sourceLineNo">458</span>    // Step 1 exec &amp;&amp; Step 2 - kill<a name="line.458"></a>
+<span class="sourceLineNo">459</span>    restart();<a name="line.459"></a>
+<span class="sourceLineNo">460</span>    waitProcedure(procId);<a name="line.460"></a>
+<span class="sourceLineNo">461</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.461"></a>
+<span class="sourceLineNo">462</span>    assertFalse(procExecutor.isRunning());<a name="line.462"></a>
+<span class="sourceLineNo">463</span><a name="line.463"></a>
+<span class="sourceLineNo">464</span>    // Step 2 exec &amp;&amp; step 3 - kill<a name="line.464"></a>
+<span class="sourceLineNo">465</span>    restart();<a name="line.465"></a>
+<span class="sourceLineNo">466</span>    waitProcedure(procId);<a name="line.466"></a>
+<span class="sourceLineNo">467</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.467"></a>
+<span class="sourceLineNo">468</span>    assertFalse(procExecutor.isRunning());<a name="line.468"></a>
+<span class="sourceLineNo">469</span><a name="line.469"></a>
+<span class="sourceLineNo">470</span>    // Step 3 exec<a name="line.470"></a>
+<span class="sourceLineNo">471</span>    restart();<a name="line.471"></a>
+<span class="sourceLineNo">472</span>    waitProcedure(procId);<a name="line.472"></a>
+<span class="sourceLineNo">473</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.473"></a>
+<span class="sourceLineNo">474</span>    assertFalse(procExecutor.isRunning());<a name="line.474"></a>
+<span class="sourceLineNo">475</span><a name="line.475"></a>
+<span class="sourceLineNo">476</span>    restart();<a name="line.476"></a>
+<span class="sourceLineNo">477</span>    waitProcedure(procId);<a name="line.477"></a>
+<span class="sourceLineNo">478</span>    assertTrue(procExecutor.isRunning());<a name="line.478"></a>
+<span class="sourceLineNo">479</span><a name="line.479"></a>
+<span class="sourceLineNo">480</span>    // The procedure is completed<a name="line.480"></a>
+<span class="sourceLineNo">481</span>    ProcedureInfo result = procExecutor.getResult(procId);<a name="line.481"></a>
+<span class="sourceLineNo">482</span>    ProcedureTestingUtility.assertProcNotFailed(result);<a name="line.482"></a>
+<span class="sourceLineNo">483</span>    assertEquals(15, Bytes.toInt(result.getResult()));<a name="line.483"></a>
+<span class="sourceLineNo">484</span>  }<a name="line.484"></a>
+<span class="sourceLineNo">485</span><a name="line.485"></a>
+<span class="sourceLineNo">486</span>  @Test(timeout=30000)<a name="line.486"></a>
+<span class="sourceLineNo">487</span>  public void testStateMachineRollbackRecovery() throws Exception {<a name="line.487"></a>
+<span class="sourceLineNo">488</span>    ProcedureTestingUtility.setToggleKillBeforeStoreUpdate(procExecutor, true);<a name="line.488"></a>
+<span class="sourceLineNo">489</span>    ProcedureTestingUtility.setKillBeforeStoreUpdate(procExecutor, true);<a name="line.489"></a>
 <span class="sourceLineNo">490</span><a name="line.490"></a>
-<span class="sourceLineNo">491</span>    // Rollback step 3 - rollback step 2 - kill<a name="line.491"></a>
-<span class="sourceLineNo">492</span>    restart();<a name="line.492"></a>
-<span class="sourceLineNo">493</span>    waitProcedure(procId);<a name="line.493"></a>
-<span class="sourceLineNo">494</span>    assertFalse(procExecutor.isRunning());<a name="line.494"></a>
-<span class="sourceLineNo">495</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.495"></a>
+<span class="sourceLineNo">491</span>    // Step 1 - kill<a name="line.491"></a>
+<span class="sourceLineNo">492</span>    Procedure proc = new TestStateMachineProcedure();<a name="line.492"></a>
+<span class="sourceLineNo">493</span>    long procId = ProcedureTestingUtility.submitAndWait(procExecutor, proc);<a name="line.493"></a>
+<span class="sourceLineNo">494</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.494"></a>
+<span class="sourceLineNo">495</span>    assertFalse(procExecutor.isRunning());<a name="line.495"></a>
 <span class="sourceLineNo">496</span><a name="line.496"></a>
-<span class="sourceLineNo">497</span>    // Rollback step 2 - step 1 - kill<a name="line.497"></a>
+<span class="sourceLineNo">497</span>    // Step 1 exec &amp;&amp; Step 2 - kill<a name="line.497"></a>
 <span class="sourceLineNo">498</span>    restart();<a name="line.498"></a>
 <span class="sourceLineNo">499</span>    waitProcedure(procId);<a name="line.499"></a>
-<span class="sourceLineNo">500</span>    assertFalse(procExecutor.isRunning());<a name="line.500"></a>
-<span class="sourceLineNo">501</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.501"></a>
+<span class="sourceLineNo">500</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.500"></a>
+<span class="sourceLineNo">501</span>    assertFalse(procExecutor.isRunning());<a name="line.501"></a>
 <span class="sourceLineNo">502</span><a name="line.502"></a>
-<span class="sourceLineNo">503</span>    // Rollback step 1 - complete<a name="line.503"></a>
+<span class="sourceLineNo">503</span>    // Step 2 exec &amp;&amp; step 3 - kill<a name="line.503"></a>
 <span class="sourceLineNo">504</span>    restart();<a name="line.504"></a>
 <span class="sourceLineNo">505</span>    waitProcedure(procId);<a name="line.505"></a>
-<span class="sourceLineNo">506</span>    assertTrue(procExecutor.isRunning());<a name="line.506"></a>
-<span class="sourceLineNo">507</span><a name="line.507"></a>
-<span class="sourceLineNo">508</span>    // The procedure is completed<a name="line.508"></a>
-<span class="sourceLineNo">509</span>    ProcedureInfo result = procExecutor.getResult(procId);<a name="line.509"></a>
-<span class="sourceLineNo">510</span>    ProcedureTestingUtility.assertIsAbortException(result);<a name="line.510"></a>
-<span class="sourceLineNo">511</span>  }<a name="line.511"></a>
-<span class="sourceLineNo">512</span><a name="line.512"></a>
-<span class="sourceLineNo">513</span>  private void waitProcedure(final long procId) {<a name="line.513"></a>
-<span class="sourceLineNo">514</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.514"></a>
-<span class="sourceLineNo">515</span>    dumpLogDirState();<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>  private void dumpLogDirState() {<a name="line.518"></a>
-<span class="sourceLineNo">519</span>    try {<a name="line.519"></a>
-<span class="sourceLineNo">520</span>      FileStatus[] files = fs.listStatus(logDir);<a name="line.520"></a>
-<span class="sourceLineNo">521</span>      if (files != null &amp;&amp; files.length &gt; 0) {<a name="line.521"></a>
-<span class="sourceLineNo">522</span>        for (FileStatus file: files) {<a name="line.522"></a>
-<span class="sourceLineNo">523</span>          assertTrue(file.toString(), file.isFile());<a name="line.523"></a>
-<span class="sourceLineNo">524</span>          LOG.debug("log file " + file.getPath() + " size=" + file.getLen());<a name="line.524"></a>
-<span class="sourceLineNo">525</span>        }<a name="line.525"></a>
-<span class="sourceLineNo">526</span>      } else {<a name="line.526"></a>
-<span class="sourceLineNo">527</span>        LOG.debug("no files under: " + logDir);<a name="line.527"></a>
-<span class="sourceLineNo">528</span>      }<a name="line.528"></a>
-<span class="sourceLineNo">529</span>    } catch (IOException e) {<a name="line.529"></a>
-<span class="sourceLineNo">530</span>      LOG.warn("Unable to dump " + logDir, e);<a name="line.530"></a>
-<span class="sourceLineNo">531</span>    }<a name="line.531"></a>
-<span class="sourceLineNo">532</span>  }<a name="line.532"></a>
+<span class="sourceLineNo">506</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.506"></a>
+<span class="sourceLineNo">507</span>    assertFalse(procExecutor.isRunning());<a name="line.507"></a>
+<span class="sourceLineNo">508</span><a name="line.508"></a>
+<span class="sourceLineNo">509</span>    // Step 3 exec - rollback step 3 - kill<a name="line.509"></a>
+<span class="sourceLineNo">510</span>    procSleepInterval = 2500;<a name="line.510"></a>
+<span class="sourceLineNo">511</span>    restart();<a name="line.511"></a>
+<span class="sourceLineNo">512</span>    assertTrue(procExecutor.abort(procId));<a name="line.512"></a>
+<span class="sourceLineNo">513</span>    waitProcedure(procId);<a name="line.513"></a>
+<span class="sourceLineNo">514</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.514"></a>
+<span class="sourceLineNo">515</span>    assertFalse(procExecutor.isRunning());<a name="line.515"></a>
+<span class="sourceLineNo">516</span><a name="line.516"></a>
+<span class="sourceLineNo">517</span>    // Rollback step 3 - rollback step 2 - kill<a name="line.517"></a>
+<span class="sourceLineNo">518</span>    restart();<a name="line.518"></a>
+<span class="sourceLineNo">519</span>    waitProcedure(procId);<a name="line.519"></a>
+<span class="sourceLineNo">520</span>    assertFalse(procExecutor.isRunning());<a name="line.520"></a>
+<span class="sourceLineNo">521</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.521"></a>
+<span class="sourceLineNo">522</span><a name="line.522"></a>
+<span class="sourceLineNo">523</span>    // Rollback step 2 - step 1 - kill<a name="line.523"></a>
+<span class="sourceLineNo">524</span>    restart();<a name="line.524"></a>
+<span class="sourceLineNo">525</span>    waitProcedure(procId);<a name="line.525"></a>
+<span class="sourceLineNo">526</span>    assertFalse(procExecutor.isRunning());<a name="line.526"></a>
+<span class="sourceLineNo">527</span>    ProcedureTestingUtility.assertProcNotYetCompleted(procExecutor, procId);<a name="line.527"></a>
+<span class="sourceLineNo">528</span><a name="line.528"></a>
+<span class="sourceLineNo">529</span>    // Rollback step 1 - complete<a name="line.529"></a>
+<span class="sourceLineNo">530</span>    restart();<a name="line.530"></a>
+<span class="sourceLineNo">531</span>    waitProcedure(procId);<a name="line.531"></a>
+<span class="sourceLineNo">532</span>    assertTrue(procExecutor.isRunning());<a name="line.532"></a>
 <span class="sourceLineNo">533</span><a name="line.533"></a>
-<span class="sourceLineNo">534</span>  private static class TestProcEnv {<a name="line.534"></a>
-<span class="sourceLineNo">535</span>    private CountDownLatch latch = null;<a name="line.535"></a>
-<span class="sourceLineNo">536</span><a name="line.536"></a>
-<span class="sourceLineNo">537</span>    /**<a name="line.537"></a>
-<span class="sourceLineNo">538</span>     * set/unset a latch. every procedure execute() step will wait on the latch if any.<a name="line.538"></a>
-<span class="sourceLineNo">539</span>     */<a name="line.539"></a>
-<span class="sourceLineNo">540</span>    public void setWaitLatch(CountDownLatch latch) {<a name="line.540"></a>
-<span class="sourceLineNo">541</span>      this.latch = latch;<a name="line.541"></a>
-<span class="sourceLineNo">542</span>    }<a name="line.542"></a>
+<span class="sourceLineNo">534</span>    // The procedure is completed<a name="line.534"></a>
+<span class="sourceLineNo">535</span>    ProcedureInfo result = procExecutor.getResult(procId);<a name="line.535"></a>
+<span class="sourceLineNo">536</span>    ProcedureTestingUtility.assertIsAbortException(result);<a name="line.536"></a>
+<span class="sourceLineNo">537</span>  }<a name="line.537"></a>
+<span class="sourceLineNo">538</span><a name="line.538"></a>
+<span class="sourceLineNo">539</span>  private void waitProcedure(final long procId) {<a name="line.539"></a>
+<span class="sourceLineNo">540</span>    ProcedureTestingUtility.waitProcedure(procExecutor, procId);<a name="line.540"></a>
+<span class="sourceLineNo">541</span>    dumpLogDirState();<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>    public void waitOnLatch() throws InterruptedException {<a name="line.544"></a>
-<span class="sourceLineNo">545</span>      if (latch != null) {<a name="line.545"></a>
-<span class="sourceLineNo">546</span>        latch.await();<a name="line.546"></a>
-<span class="sourceLineNo">547</span>      }<a name="line.547"></a>
-<span class="sourceLineNo">548</span>    }<a name="line.548"></a>
-<span class="sourceLineNo">549</span>  }<a name="line.549"></a>
-<span class="sourceLineNo">550</span>}<a name="line.550"></a>
+<span class="sourceLineNo">544</span>  private void dumpLogDirState() {<a name="line.544"></a>
+<span class="sourceLineNo">545</span>    try {<a name="line.545"></a>
+<span class="sourceLineNo">546</span>      FileStatus[] files = fs.listStatus(logDir);<a name="line.546"></a>
+<span class="sourceLineNo">547</span>      if (files != null &amp;&amp; files.length &gt; 0) {<a name="line.547"></a>
+<span class="sourceLineNo">548</span>        for (FileStatus file: files) {<a name="line.548"></a>
+<span class="sourceLineNo">549</span>          assertTrue(file.toString(), file.isFile());<a name="line.549"></a>
+<span class="sourceLineNo">550</span>          LOG.debug("log file " + file.getPath() + " size=" + file.getLen());<a name="line.550"></a>
+<span class="sourceLineNo">551</span>        }<a name="line.551"></a>
+<span class="sourceLineNo">552</span>      } else {<a name="line.552"></a>
+<span class="sourceLineNo">553</span>        LOG.debug("no files under: " + logDir);<a name="line.553"></a>
+<span class="sourceLineNo">554</span>      }<a name="line.554"></a>
+<span class="sourceLineNo">555</span>    } catch (IOException e) {<a name="line.555"></a>
+<span class="sourceLineNo">556</span>      LOG.warn("Unable to dump " + logDir, e);<a name="line.556"></a>
+<span class="sourceLineNo">557</span>    }<a name="line.557"></a>
+<span class="sourceLineNo">558</span>  }<a name="line.558"></a>
+<span class="sourceLineNo">559</span><a name="line.559"></a>
+<span class="sourceLineNo">560</span>  private static class TestProcEnv {<a name="line.560"></a>
+<span class="sourceLineNo">561</span>    private CountDownLatch latch = null;<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>     * set/unset a latch. every procedure execute() step will wait on the latch if any.<a name="line.564"></a>
+<span class="sourceLineNo">565</span>     */<a name="line.565"></a>
+<span class="sourceLineNo">566</span>    public void setWaitLatch(CountDownLatch latch) {<a name="line.566"></a>
+<span class="sourceLineNo">567</span>      this.latch = latch;<a name="line.567"></a>
+<span class="sourceLineNo">568</span>    }<a name="line.568"></a>
+<span class="sourceLineNo">569</span><a name="line.569"></a>
+<span class="sourceLineNo">570</span>    public void waitOnLatch() throws InterruptedException {<a name="line.570"></a>
+<span class="sourceLineNo">571</span>      if (latch != null) {<a name="line.571"></a>
+<span class="sourceLineNo">572</span>        latch.await();<a name="line.572"></a>
+<span class="sourceLineNo">573</span>      }<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>}<a name="line.576"></a>
 
 
 


Mime
View raw message