hbase-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From git-site-r...@apache.org
Subject [18/39] hbase-site git commit: Published site at 66469733ec9bffb236c143b858e5748182ad71b3.
Date Thu, 25 Oct 2018 14:54:55 GMT
http://git-wip-us.apache.org/repos/asf/hbase-site/blob/5f45c993/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/Procedure.LockState.html
----------------------------------------------------------------------
diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/Procedure.LockState.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/Procedure.LockState.html
index a01c301..2658e1b 100644
--- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/Procedure.LockState.html
+++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/Procedure.LockState.html
@@ -725,370 +725,380 @@
 <span class="sourceLineNo">717</span>    this.lockedWhenLoading = true;<a name="line.717"></a>
 <span class="sourceLineNo">718</span>  }<a name="line.718"></a>
 <span class="sourceLineNo">719</span><a name="line.719"></a>
-<span class="sourceLineNo">720</span>  // ==============================================================================================<a name="line.720"></a>
-<span class="sourceLineNo">721</span>  //  Runtime state, updated every operation by the ProcedureExecutor<a name="line.721"></a>
-<span class="sourceLineNo">722</span>  //<a name="line.722"></a>
-<span class="sourceLineNo">723</span>  //  There is always 1 thread at the time operating on the state of the procedure.<a name="line.723"></a>
-<span class="sourceLineNo">724</span>  //  The ProcedureExecutor may check and set states, or some Procecedure may<a name="line.724"></a>
-<span class="sourceLineNo">725</span>  //  update its own state. but no concurrent updates. we use synchronized here<a name="line.725"></a>
-<span class="sourceLineNo">726</span>  //  just because the procedure can get scheduled on different executor threads on each step.<a name="line.726"></a>
-<span class="sourceLineNo">727</span>  // ==============================================================================================<a name="line.727"></a>
-<span class="sourceLineNo">728</span><a name="line.728"></a>
-<span class="sourceLineNo">729</span>  /**<a name="line.729"></a>
-<span class="sourceLineNo">730</span>   * @return true if the procedure is in a RUNNABLE state.<a name="line.730"></a>
-<span class="sourceLineNo">731</span>   */<a name="line.731"></a>
-<span class="sourceLineNo">732</span>  public synchronized boolean isRunnable() {<a name="line.732"></a>
-<span class="sourceLineNo">733</span>    return state == ProcedureState.RUNNABLE;<a name="line.733"></a>
-<span class="sourceLineNo">734</span>  }<a name="line.734"></a>
-<span class="sourceLineNo">735</span><a name="line.735"></a>
-<span class="sourceLineNo">736</span>  public synchronized boolean isInitializing() {<a name="line.736"></a>
-<span class="sourceLineNo">737</span>    return state == ProcedureState.INITIALIZING;<a name="line.737"></a>
+<span class="sourceLineNo">720</span>  public boolean isLockedWhenLoading() {<a name="line.720"></a>
+<span class="sourceLineNo">721</span>    return lockedWhenLoading;<a name="line.721"></a>
+<span class="sourceLineNo">722</span>  }<a name="line.722"></a>
+<span class="sourceLineNo">723</span><a name="line.723"></a>
+<span class="sourceLineNo">724</span>  // ==============================================================================================<a name="line.724"></a>
+<span class="sourceLineNo">725</span>  //  Runtime state, updated every operation by the ProcedureExecutor<a name="line.725"></a>
+<span class="sourceLineNo">726</span>  //<a name="line.726"></a>
+<span class="sourceLineNo">727</span>  //  There is always 1 thread at the time operating on the state of the procedure.<a name="line.727"></a>
+<span class="sourceLineNo">728</span>  //  The ProcedureExecutor may check and set states, or some Procecedure may<a name="line.728"></a>
+<span class="sourceLineNo">729</span>  //  update its own state. but no concurrent updates. we use synchronized here<a name="line.729"></a>
+<span class="sourceLineNo">730</span>  //  just because the procedure can get scheduled on different executor threads on each step.<a name="line.730"></a>
+<span class="sourceLineNo">731</span>  // ==============================================================================================<a name="line.731"></a>
+<span class="sourceLineNo">732</span><a name="line.732"></a>
+<span class="sourceLineNo">733</span>  /**<a name="line.733"></a>
+<span class="sourceLineNo">734</span>   * @return true if the procedure is in a RUNNABLE state.<a name="line.734"></a>
+<span class="sourceLineNo">735</span>   */<a name="line.735"></a>
+<span class="sourceLineNo">736</span>  public synchronized boolean isRunnable() {<a name="line.736"></a>
+<span class="sourceLineNo">737</span>    return state == ProcedureState.RUNNABLE;<a name="line.737"></a>
 <span class="sourceLineNo">738</span>  }<a name="line.738"></a>
 <span class="sourceLineNo">739</span><a name="line.739"></a>
-<span class="sourceLineNo">740</span>  /**<a name="line.740"></a>
-<span class="sourceLineNo">741</span>   * @return true if the procedure has failed. It may or may not have rolled back.<a name="line.741"></a>
-<span class="sourceLineNo">742</span>   */<a name="line.742"></a>
-<span class="sourceLineNo">743</span>  public synchronized boolean isFailed() {<a name="line.743"></a>
-<span class="sourceLineNo">744</span>    return state == ProcedureState.FAILED || state == ProcedureState.ROLLEDBACK;<a name="line.744"></a>
-<span class="sourceLineNo">745</span>  }<a name="line.745"></a>
-<span class="sourceLineNo">746</span><a name="line.746"></a>
-<span class="sourceLineNo">747</span>  /**<a name="line.747"></a>
-<span class="sourceLineNo">748</span>   * @return true if the procedure is finished successfully.<a name="line.748"></a>
-<span class="sourceLineNo">749</span>   */<a name="line.749"></a>
-<span class="sourceLineNo">750</span>  public synchronized boolean isSuccess() {<a name="line.750"></a>
-<span class="sourceLineNo">751</span>    return state == ProcedureState.SUCCESS &amp;&amp; !hasException();<a name="line.751"></a>
-<span class="sourceLineNo">752</span>  }<a name="line.752"></a>
-<span class="sourceLineNo">753</span><a name="line.753"></a>
-<span class="sourceLineNo">754</span>  /**<a name="line.754"></a>
-<span class="sourceLineNo">755</span>   * @return true if the procedure is finished. The Procedure may be completed successfully or<a name="line.755"></a>
-<span class="sourceLineNo">756</span>   * rolledback.<a name="line.756"></a>
-<span class="sourceLineNo">757</span>   */<a name="line.757"></a>
-<span class="sourceLineNo">758</span>  public synchronized boolean isFinished() {<a name="line.758"></a>
-<span class="sourceLineNo">759</span>    return isSuccess() || state == ProcedureState.ROLLEDBACK;<a name="line.759"></a>
-<span class="sourceLineNo">760</span>  }<a name="line.760"></a>
-<span class="sourceLineNo">761</span><a name="line.761"></a>
-<span class="sourceLineNo">762</span>  /**<a name="line.762"></a>
-<span class="sourceLineNo">763</span>   * @return true if the procedure is waiting for a child to finish or for an external event.<a name="line.763"></a>
-<span class="sourceLineNo">764</span>   */<a name="line.764"></a>
-<span class="sourceLineNo">765</span>  public synchronized boolean isWaiting() {<a name="line.765"></a>
-<span class="sourceLineNo">766</span>    switch (state) {<a name="line.766"></a>
-<span class="sourceLineNo">767</span>      case WAITING:<a name="line.767"></a>
-<span class="sourceLineNo">768</span>      case WAITING_TIMEOUT:<a name="line.768"></a>
-<span class="sourceLineNo">769</span>        return true;<a name="line.769"></a>
-<span class="sourceLineNo">770</span>      default:<a name="line.770"></a>
-<span class="sourceLineNo">771</span>        break;<a name="line.771"></a>
-<span class="sourceLineNo">772</span>    }<a name="line.772"></a>
-<span class="sourceLineNo">773</span>    return false;<a name="line.773"></a>
-<span class="sourceLineNo">774</span>  }<a name="line.774"></a>
-<span class="sourceLineNo">775</span><a name="line.775"></a>
-<span class="sourceLineNo">776</span>  @VisibleForTesting<a name="line.776"></a>
-<span class="sourceLineNo">777</span>  protected synchronized void setState(final ProcedureState state) {<a name="line.777"></a>
-<span class="sourceLineNo">778</span>    this.state = state;<a name="line.778"></a>
-<span class="sourceLineNo">779</span>    updateTimestamp();<a name="line.779"></a>
-<span class="sourceLineNo">780</span>  }<a name="line.780"></a>
-<span class="sourceLineNo">781</span><a name="line.781"></a>
-<span class="sourceLineNo">782</span>  public synchronized ProcedureState getState() {<a name="line.782"></a>
-<span class="sourceLineNo">783</span>    return state;<a name="line.783"></a>
+<span class="sourceLineNo">740</span>  public synchronized boolean isInitializing() {<a name="line.740"></a>
+<span class="sourceLineNo">741</span>    return state == ProcedureState.INITIALIZING;<a name="line.741"></a>
+<span class="sourceLineNo">742</span>  }<a name="line.742"></a>
+<span class="sourceLineNo">743</span><a name="line.743"></a>
+<span class="sourceLineNo">744</span>  /**<a name="line.744"></a>
+<span class="sourceLineNo">745</span>   * @return true if the procedure has failed. It may or may not have rolled back.<a name="line.745"></a>
+<span class="sourceLineNo">746</span>   */<a name="line.746"></a>
+<span class="sourceLineNo">747</span>  public synchronized boolean isFailed() {<a name="line.747"></a>
+<span class="sourceLineNo">748</span>    return state == ProcedureState.FAILED || state == ProcedureState.ROLLEDBACK;<a name="line.748"></a>
+<span class="sourceLineNo">749</span>  }<a name="line.749"></a>
+<span class="sourceLineNo">750</span><a name="line.750"></a>
+<span class="sourceLineNo">751</span>  /**<a name="line.751"></a>
+<span class="sourceLineNo">752</span>   * @return true if the procedure is finished successfully.<a name="line.752"></a>
+<span class="sourceLineNo">753</span>   */<a name="line.753"></a>
+<span class="sourceLineNo">754</span>  public synchronized boolean isSuccess() {<a name="line.754"></a>
+<span class="sourceLineNo">755</span>    return state == ProcedureState.SUCCESS &amp;&amp; !hasException();<a name="line.755"></a>
+<span class="sourceLineNo">756</span>  }<a name="line.756"></a>
+<span class="sourceLineNo">757</span><a name="line.757"></a>
+<span class="sourceLineNo">758</span>  /**<a name="line.758"></a>
+<span class="sourceLineNo">759</span>   * @return true if the procedure is finished. The Procedure may be completed successfully or<a name="line.759"></a>
+<span class="sourceLineNo">760</span>   * rolledback.<a name="line.760"></a>
+<span class="sourceLineNo">761</span>   */<a name="line.761"></a>
+<span class="sourceLineNo">762</span>  public synchronized boolean isFinished() {<a name="line.762"></a>
+<span class="sourceLineNo">763</span>    return isSuccess() || state == ProcedureState.ROLLEDBACK;<a name="line.763"></a>
+<span class="sourceLineNo">764</span>  }<a name="line.764"></a>
+<span class="sourceLineNo">765</span><a name="line.765"></a>
+<span class="sourceLineNo">766</span>  /**<a name="line.766"></a>
+<span class="sourceLineNo">767</span>   * @return true if the procedure is waiting for a child to finish or for an external event.<a name="line.767"></a>
+<span class="sourceLineNo">768</span>   */<a name="line.768"></a>
+<span class="sourceLineNo">769</span>  public synchronized boolean isWaiting() {<a name="line.769"></a>
+<span class="sourceLineNo">770</span>    switch (state) {<a name="line.770"></a>
+<span class="sourceLineNo">771</span>      case WAITING:<a name="line.771"></a>
+<span class="sourceLineNo">772</span>      case WAITING_TIMEOUT:<a name="line.772"></a>
+<span class="sourceLineNo">773</span>        return true;<a name="line.773"></a>
+<span class="sourceLineNo">774</span>      default:<a name="line.774"></a>
+<span class="sourceLineNo">775</span>        break;<a name="line.775"></a>
+<span class="sourceLineNo">776</span>    }<a name="line.776"></a>
+<span class="sourceLineNo">777</span>    return false;<a name="line.777"></a>
+<span class="sourceLineNo">778</span>  }<a name="line.778"></a>
+<span class="sourceLineNo">779</span><a name="line.779"></a>
+<span class="sourceLineNo">780</span>  @VisibleForTesting<a name="line.780"></a>
+<span class="sourceLineNo">781</span>  protected synchronized void setState(final ProcedureState state) {<a name="line.781"></a>
+<span class="sourceLineNo">782</span>    this.state = state;<a name="line.782"></a>
+<span class="sourceLineNo">783</span>    updateTimestamp();<a name="line.783"></a>
 <span class="sourceLineNo">784</span>  }<a name="line.784"></a>
 <span class="sourceLineNo">785</span><a name="line.785"></a>
-<span class="sourceLineNo">786</span>  protected void setFailure(final String source, final Throwable cause) {<a name="line.786"></a>
-<span class="sourceLineNo">787</span>    setFailure(new RemoteProcedureException(source, cause));<a name="line.787"></a>
+<span class="sourceLineNo">786</span>  public synchronized ProcedureState getState() {<a name="line.786"></a>
+<span class="sourceLineNo">787</span>    return state;<a name="line.787"></a>
 <span class="sourceLineNo">788</span>  }<a name="line.788"></a>
 <span class="sourceLineNo">789</span><a name="line.789"></a>
-<span class="sourceLineNo">790</span>  protected synchronized void setFailure(final RemoteProcedureException exception) {<a name="line.790"></a>
-<span class="sourceLineNo">791</span>    this.exception = exception;<a name="line.791"></a>
-<span class="sourceLineNo">792</span>    if (!isFinished()) {<a name="line.792"></a>
-<span class="sourceLineNo">793</span>      setState(ProcedureState.FAILED);<a name="line.793"></a>
-<span class="sourceLineNo">794</span>    }<a name="line.794"></a>
-<span class="sourceLineNo">795</span>  }<a name="line.795"></a>
-<span class="sourceLineNo">796</span><a name="line.796"></a>
-<span class="sourceLineNo">797</span>  protected void setAbortFailure(final String source, final String msg) {<a name="line.797"></a>
-<span class="sourceLineNo">798</span>    setFailure(source, new ProcedureAbortedException(msg));<a name="line.798"></a>
+<span class="sourceLineNo">790</span>  protected void setFailure(final String source, final Throwable cause) {<a name="line.790"></a>
+<span class="sourceLineNo">791</span>    setFailure(new RemoteProcedureException(source, cause));<a name="line.791"></a>
+<span class="sourceLineNo">792</span>  }<a name="line.792"></a>
+<span class="sourceLineNo">793</span><a name="line.793"></a>
+<span class="sourceLineNo">794</span>  protected synchronized void setFailure(final RemoteProcedureException exception) {<a name="line.794"></a>
+<span class="sourceLineNo">795</span>    this.exception = exception;<a name="line.795"></a>
+<span class="sourceLineNo">796</span>    if (!isFinished()) {<a name="line.796"></a>
+<span class="sourceLineNo">797</span>      setState(ProcedureState.FAILED);<a name="line.797"></a>
+<span class="sourceLineNo">798</span>    }<a name="line.798"></a>
 <span class="sourceLineNo">799</span>  }<a name="line.799"></a>
 <span class="sourceLineNo">800</span><a name="line.800"></a>
-<span class="sourceLineNo">801</span>  /**<a name="line.801"></a>
-<span class="sourceLineNo">802</span>   * Called by the ProcedureExecutor when the timeout set by setTimeout() is expired.<a name="line.802"></a>
-<span class="sourceLineNo">803</span>   * &lt;p/&gt;<a name="line.803"></a>
-<span class="sourceLineNo">804</span>   * Another usage for this method is to implement retrying. A procedure can set the state to<a name="line.804"></a>
-<span class="sourceLineNo">805</span>   * {@code WAITING_TIMEOUT} by calling {@code setState} method, and throw a<a name="line.805"></a>
-<span class="sourceLineNo">806</span>   * {@link ProcedureSuspendedException} to halt the execution of the procedure, and do not forget a<a name="line.806"></a>
-<span class="sourceLineNo">807</span>   * call {@link #setTimeout(int)} method to set the timeout. And you should also override this<a name="line.807"></a>
-<span class="sourceLineNo">808</span>   * method to wake up the procedure, and also return false to tell the ProcedureExecutor that the<a name="line.808"></a>
-<span class="sourceLineNo">809</span>   * timeout event has been handled.<a name="line.809"></a>
-<span class="sourceLineNo">810</span>   * @return true to let the framework handle the timeout as abort, false in case the procedure<a name="line.810"></a>
-<span class="sourceLineNo">811</span>   *         handled the timeout itself.<a name="line.811"></a>
-<span class="sourceLineNo">812</span>   */<a name="line.812"></a>
-<span class="sourceLineNo">813</span>  protected synchronized boolean setTimeoutFailure(TEnvironment env) {<a name="line.813"></a>
-<span class="sourceLineNo">814</span>    if (state == ProcedureState.WAITING_TIMEOUT) {<a name="line.814"></a>
-<span class="sourceLineNo">815</span>      long timeDiff = EnvironmentEdgeManager.currentTime() - lastUpdate;<a name="line.815"></a>
-<span class="sourceLineNo">816</span>      setFailure("ProcedureExecutor",<a name="line.816"></a>
-<span class="sourceLineNo">817</span>        new TimeoutIOException("Operation timed out after " + StringUtils.humanTimeDiff(timeDiff)));<a name="line.817"></a>
-<span class="sourceLineNo">818</span>      return true;<a name="line.818"></a>
-<span class="sourceLineNo">819</span>    }<a name="line.819"></a>
-<span class="sourceLineNo">820</span>    return false;<a name="line.820"></a>
-<span class="sourceLineNo">821</span>  }<a name="line.821"></a>
-<span class="sourceLineNo">822</span><a name="line.822"></a>
-<span class="sourceLineNo">823</span>  public synchronized boolean hasException() {<a name="line.823"></a>
-<span class="sourceLineNo">824</span>    return exception != null;<a name="line.824"></a>
+<span class="sourceLineNo">801</span>  protected void setAbortFailure(final String source, final String msg) {<a name="line.801"></a>
+<span class="sourceLineNo">802</span>    setFailure(source, new ProcedureAbortedException(msg));<a name="line.802"></a>
+<span class="sourceLineNo">803</span>  }<a name="line.803"></a>
+<span class="sourceLineNo">804</span><a name="line.804"></a>
+<span class="sourceLineNo">805</span>  /**<a name="line.805"></a>
+<span class="sourceLineNo">806</span>   * Called by the ProcedureExecutor when the timeout set by setTimeout() is expired.<a name="line.806"></a>
+<span class="sourceLineNo">807</span>   * &lt;p/&gt;<a name="line.807"></a>
+<span class="sourceLineNo">808</span>   * Another usage for this method is to implement retrying. A procedure can set the state to<a name="line.808"></a>
+<span class="sourceLineNo">809</span>   * {@code WAITING_TIMEOUT} by calling {@code setState} method, and throw a<a name="line.809"></a>
+<span class="sourceLineNo">810</span>   * {@link ProcedureSuspendedException} to halt the execution of the procedure, and do not forget a<a name="line.810"></a>
+<span class="sourceLineNo">811</span>   * call {@link #setTimeout(int)} method to set the timeout. And you should also override this<a name="line.811"></a>
+<span class="sourceLineNo">812</span>   * method to wake up the procedure, and also return false to tell the ProcedureExecutor that the<a name="line.812"></a>
+<span class="sourceLineNo">813</span>   * timeout event has been handled.<a name="line.813"></a>
+<span class="sourceLineNo">814</span>   * @return true to let the framework handle the timeout as abort, false in case the procedure<a name="line.814"></a>
+<span class="sourceLineNo">815</span>   *         handled the timeout itself.<a name="line.815"></a>
+<span class="sourceLineNo">816</span>   */<a name="line.816"></a>
+<span class="sourceLineNo">817</span>  protected synchronized boolean setTimeoutFailure(TEnvironment env) {<a name="line.817"></a>
+<span class="sourceLineNo">818</span>    if (state == ProcedureState.WAITING_TIMEOUT) {<a name="line.818"></a>
+<span class="sourceLineNo">819</span>      long timeDiff = EnvironmentEdgeManager.currentTime() - lastUpdate;<a name="line.819"></a>
+<span class="sourceLineNo">820</span>      setFailure("ProcedureExecutor",<a name="line.820"></a>
+<span class="sourceLineNo">821</span>        new TimeoutIOException("Operation timed out after " + StringUtils.humanTimeDiff(timeDiff)));<a name="line.821"></a>
+<span class="sourceLineNo">822</span>      return true;<a name="line.822"></a>
+<span class="sourceLineNo">823</span>    }<a name="line.823"></a>
+<span class="sourceLineNo">824</span>    return false;<a name="line.824"></a>
 <span class="sourceLineNo">825</span>  }<a name="line.825"></a>
 <span class="sourceLineNo">826</span><a name="line.826"></a>
-<span class="sourceLineNo">827</span>  public synchronized RemoteProcedureException getException() {<a name="line.827"></a>
-<span class="sourceLineNo">828</span>    return exception;<a name="line.828"></a>
+<span class="sourceLineNo">827</span>  public synchronized boolean hasException() {<a name="line.827"></a>
+<span class="sourceLineNo">828</span>    return exception != null;<a name="line.828"></a>
 <span class="sourceLineNo">829</span>  }<a name="line.829"></a>
 <span class="sourceLineNo">830</span><a name="line.830"></a>
-<span class="sourceLineNo">831</span>  /**<a name="line.831"></a>
-<span class="sourceLineNo">832</span>   * Called by the ProcedureExecutor on procedure-load to restore the latch state<a name="line.832"></a>
-<span class="sourceLineNo">833</span>   */<a name="line.833"></a>
-<span class="sourceLineNo">834</span>  protected synchronized void setChildrenLatch(int numChildren) {<a name="line.834"></a>
-<span class="sourceLineNo">835</span>    this.childrenLatch = numChildren;<a name="line.835"></a>
-<span class="sourceLineNo">836</span>    if (LOG.isTraceEnabled()) {<a name="line.836"></a>
-<span class="sourceLineNo">837</span>      LOG.trace("CHILD LATCH INCREMENT SET " +<a name="line.837"></a>
-<span class="sourceLineNo">838</span>          this.childrenLatch, new Throwable(this.toString()));<a name="line.838"></a>
-<span class="sourceLineNo">839</span>    }<a name="line.839"></a>
-<span class="sourceLineNo">840</span>  }<a name="line.840"></a>
-<span class="sourceLineNo">841</span><a name="line.841"></a>
-<span class="sourceLineNo">842</span>  /**<a name="line.842"></a>
-<span class="sourceLineNo">843</span>   * Called by the ProcedureExecutor on procedure-load to restore the latch state<a name="line.843"></a>
-<span class="sourceLineNo">844</span>   */<a name="line.844"></a>
-<span class="sourceLineNo">845</span>  protected synchronized void incChildrenLatch() {<a name="line.845"></a>
-<span class="sourceLineNo">846</span>    // TODO: can this be inferred from the stack? I think so...<a name="line.846"></a>
-<span class="sourceLineNo">847</span>    this.childrenLatch++;<a name="line.847"></a>
-<span class="sourceLineNo">848</span>    if (LOG.isTraceEnabled()) {<a name="line.848"></a>
-<span class="sourceLineNo">849</span>      LOG.trace("CHILD LATCH INCREMENT " + this.childrenLatch, new Throwable(this.toString()));<a name="line.849"></a>
-<span class="sourceLineNo">850</span>    }<a name="line.850"></a>
-<span class="sourceLineNo">851</span>  }<a name="line.851"></a>
-<span class="sourceLineNo">852</span><a name="line.852"></a>
-<span class="sourceLineNo">853</span>  /**<a name="line.853"></a>
-<span class="sourceLineNo">854</span>   * Called by the ProcedureExecutor to notify that one of the sub-procedures has completed.<a name="line.854"></a>
-<span class="sourceLineNo">855</span>   */<a name="line.855"></a>
-<span class="sourceLineNo">856</span>  private synchronized boolean childrenCountDown() {<a name="line.856"></a>
-<span class="sourceLineNo">857</span>    assert childrenLatch &gt; 0: this;<a name="line.857"></a>
-<span class="sourceLineNo">858</span>    boolean b = --childrenLatch == 0;<a name="line.858"></a>
-<span class="sourceLineNo">859</span>    if (LOG.isTraceEnabled()) {<a name="line.859"></a>
-<span class="sourceLineNo">860</span>      LOG.trace("CHILD LATCH DECREMENT " + childrenLatch, new Throwable(this.toString()));<a name="line.860"></a>
-<span class="sourceLineNo">861</span>    }<a name="line.861"></a>
-<span class="sourceLineNo">862</span>    return b;<a name="line.862"></a>
-<span class="sourceLineNo">863</span>  }<a name="line.863"></a>
-<span class="sourceLineNo">864</span><a name="line.864"></a>
-<span class="sourceLineNo">865</span>  /**<a name="line.865"></a>
-<span class="sourceLineNo">866</span>   * Try to set this procedure into RUNNABLE state.<a name="line.866"></a>
-<span class="sourceLineNo">867</span>   * Succeeds if all subprocedures/children are done.<a name="line.867"></a>
-<span class="sourceLineNo">868</span>   * @return True if we were able to move procedure to RUNNABLE state.<a name="line.868"></a>
-<span class="sourceLineNo">869</span>   */<a name="line.869"></a>
-<span class="sourceLineNo">870</span>  synchronized boolean tryRunnable() {<a name="line.870"></a>
-<span class="sourceLineNo">871</span>    // Don't use isWaiting in the below; it returns true for WAITING and WAITING_TIMEOUT<a name="line.871"></a>
-<span class="sourceLineNo">872</span>    if (getState() == ProcedureState.WAITING &amp;&amp; childrenCountDown()) {<a name="line.872"></a>
-<span class="sourceLineNo">873</span>      setState(ProcedureState.RUNNABLE);<a name="line.873"></a>
-<span class="sourceLineNo">874</span>      return true;<a name="line.874"></a>
-<span class="sourceLineNo">875</span>    } else {<a name="line.875"></a>
-<span class="sourceLineNo">876</span>      return false;<a name="line.876"></a>
-<span class="sourceLineNo">877</span>    }<a name="line.877"></a>
-<span class="sourceLineNo">878</span>  }<a name="line.878"></a>
-<span class="sourceLineNo">879</span><a name="line.879"></a>
-<span class="sourceLineNo">880</span>  protected synchronized boolean hasChildren() {<a name="line.880"></a>
-<span class="sourceLineNo">881</span>    return childrenLatch &gt; 0;<a name="line.881"></a>
+<span class="sourceLineNo">831</span>  public synchronized RemoteProcedureException getException() {<a name="line.831"></a>
+<span class="sourceLineNo">832</span>    return exception;<a name="line.832"></a>
+<span class="sourceLineNo">833</span>  }<a name="line.833"></a>
+<span class="sourceLineNo">834</span><a name="line.834"></a>
+<span class="sourceLineNo">835</span>  /**<a name="line.835"></a>
+<span class="sourceLineNo">836</span>   * Called by the ProcedureExecutor on procedure-load to restore the latch state<a name="line.836"></a>
+<span class="sourceLineNo">837</span>   */<a name="line.837"></a>
+<span class="sourceLineNo">838</span>  protected synchronized void setChildrenLatch(int numChildren) {<a name="line.838"></a>
+<span class="sourceLineNo">839</span>    this.childrenLatch = numChildren;<a name="line.839"></a>
+<span class="sourceLineNo">840</span>    if (LOG.isTraceEnabled()) {<a name="line.840"></a>
+<span class="sourceLineNo">841</span>      LOG.trace("CHILD LATCH INCREMENT SET " +<a name="line.841"></a>
+<span class="sourceLineNo">842</span>          this.childrenLatch, new Throwable(this.toString()));<a name="line.842"></a>
+<span class="sourceLineNo">843</span>    }<a name="line.843"></a>
+<span class="sourceLineNo">844</span>  }<a name="line.844"></a>
+<span class="sourceLineNo">845</span><a name="line.845"></a>
+<span class="sourceLineNo">846</span>  /**<a name="line.846"></a>
+<span class="sourceLineNo">847</span>   * Called by the ProcedureExecutor on procedure-load to restore the latch state<a name="line.847"></a>
+<span class="sourceLineNo">848</span>   */<a name="line.848"></a>
+<span class="sourceLineNo">849</span>  protected synchronized void incChildrenLatch() {<a name="line.849"></a>
+<span class="sourceLineNo">850</span>    // TODO: can this be inferred from the stack? I think so...<a name="line.850"></a>
+<span class="sourceLineNo">851</span>    this.childrenLatch++;<a name="line.851"></a>
+<span class="sourceLineNo">852</span>    if (LOG.isTraceEnabled()) {<a name="line.852"></a>
+<span class="sourceLineNo">853</span>      LOG.trace("CHILD LATCH INCREMENT " + this.childrenLatch, new Throwable(this.toString()));<a name="line.853"></a>
+<span class="sourceLineNo">854</span>    }<a name="line.854"></a>
+<span class="sourceLineNo">855</span>  }<a name="line.855"></a>
+<span class="sourceLineNo">856</span><a name="line.856"></a>
+<span class="sourceLineNo">857</span>  /**<a name="line.857"></a>
+<span class="sourceLineNo">858</span>   * Called by the ProcedureExecutor to notify that one of the sub-procedures has completed.<a name="line.858"></a>
+<span class="sourceLineNo">859</span>   */<a name="line.859"></a>
+<span class="sourceLineNo">860</span>  private synchronized boolean childrenCountDown() {<a name="line.860"></a>
+<span class="sourceLineNo">861</span>    assert childrenLatch &gt; 0: this;<a name="line.861"></a>
+<span class="sourceLineNo">862</span>    boolean b = --childrenLatch == 0;<a name="line.862"></a>
+<span class="sourceLineNo">863</span>    if (LOG.isTraceEnabled()) {<a name="line.863"></a>
+<span class="sourceLineNo">864</span>      LOG.trace("CHILD LATCH DECREMENT " + childrenLatch, new Throwable(this.toString()));<a name="line.864"></a>
+<span class="sourceLineNo">865</span>    }<a name="line.865"></a>
+<span class="sourceLineNo">866</span>    return b;<a name="line.866"></a>
+<span class="sourceLineNo">867</span>  }<a name="line.867"></a>
+<span class="sourceLineNo">868</span><a name="line.868"></a>
+<span class="sourceLineNo">869</span>  /**<a name="line.869"></a>
+<span class="sourceLineNo">870</span>   * Try to set this procedure into RUNNABLE state.<a name="line.870"></a>
+<span class="sourceLineNo">871</span>   * Succeeds if all subprocedures/children are done.<a name="line.871"></a>
+<span class="sourceLineNo">872</span>   * @return True if we were able to move procedure to RUNNABLE state.<a name="line.872"></a>
+<span class="sourceLineNo">873</span>   */<a name="line.873"></a>
+<span class="sourceLineNo">874</span>  synchronized boolean tryRunnable() {<a name="line.874"></a>
+<span class="sourceLineNo">875</span>    // Don't use isWaiting in the below; it returns true for WAITING and WAITING_TIMEOUT<a name="line.875"></a>
+<span class="sourceLineNo">876</span>    if (getState() == ProcedureState.WAITING &amp;&amp; childrenCountDown()) {<a name="line.876"></a>
+<span class="sourceLineNo">877</span>      setState(ProcedureState.RUNNABLE);<a name="line.877"></a>
+<span class="sourceLineNo">878</span>      return true;<a name="line.878"></a>
+<span class="sourceLineNo">879</span>    } else {<a name="line.879"></a>
+<span class="sourceLineNo">880</span>      return false;<a name="line.880"></a>
+<span class="sourceLineNo">881</span>    }<a name="line.881"></a>
 <span class="sourceLineNo">882</span>  }<a name="line.882"></a>
 <span class="sourceLineNo">883</span><a name="line.883"></a>
-<span class="sourceLineNo">884</span>  protected synchronized int getChildrenLatch() {<a name="line.884"></a>
-<span class="sourceLineNo">885</span>    return childrenLatch;<a name="line.885"></a>
+<span class="sourceLineNo">884</span>  protected synchronized boolean hasChildren() {<a name="line.884"></a>
+<span class="sourceLineNo">885</span>    return childrenLatch &gt; 0;<a name="line.885"></a>
 <span class="sourceLineNo">886</span>  }<a name="line.886"></a>
 <span class="sourceLineNo">887</span><a name="line.887"></a>
-<span class="sourceLineNo">888</span>  /**<a name="line.888"></a>
-<span class="sourceLineNo">889</span>   * Called by the RootProcedureState on procedure execution.<a name="line.889"></a>
-<span class="sourceLineNo">890</span>   * Each procedure store its stack-index positions.<a name="line.890"></a>
-<span class="sourceLineNo">891</span>   */<a name="line.891"></a>
-<span class="sourceLineNo">892</span>  protected synchronized void addStackIndex(final int index) {<a name="line.892"></a>
-<span class="sourceLineNo">893</span>    if (stackIndexes == null) {<a name="line.893"></a>
-<span class="sourceLineNo">894</span>      stackIndexes = new int[] { index };<a name="line.894"></a>
-<span class="sourceLineNo">895</span>    } else {<a name="line.895"></a>
-<span class="sourceLineNo">896</span>      int count = stackIndexes.length;<a name="line.896"></a>
-<span class="sourceLineNo">897</span>      stackIndexes = Arrays.copyOf(stackIndexes, count + 1);<a name="line.897"></a>
-<span class="sourceLineNo">898</span>      stackIndexes[count] = index;<a name="line.898"></a>
-<span class="sourceLineNo">899</span>    }<a name="line.899"></a>
-<span class="sourceLineNo">900</span>  }<a name="line.900"></a>
-<span class="sourceLineNo">901</span><a name="line.901"></a>
-<span class="sourceLineNo">902</span>  protected synchronized boolean removeStackIndex() {<a name="line.902"></a>
-<span class="sourceLineNo">903</span>    if (stackIndexes != null &amp;&amp; stackIndexes.length &gt; 1) {<a name="line.903"></a>
-<span class="sourceLineNo">904</span>      stackIndexes = Arrays.copyOf(stackIndexes, stackIndexes.length - 1);<a name="line.904"></a>
-<span class="sourceLineNo">905</span>      return false;<a name="line.905"></a>
-<span class="sourceLineNo">906</span>    } else {<a name="line.906"></a>
-<span class="sourceLineNo">907</span>      stackIndexes = null;<a name="line.907"></a>
-<span class="sourceLineNo">908</span>      return true;<a name="line.908"></a>
-<span class="sourceLineNo">909</span>    }<a name="line.909"></a>
-<span class="sourceLineNo">910</span>  }<a name="line.910"></a>
-<span class="sourceLineNo">911</span><a name="line.911"></a>
-<span class="sourceLineNo">912</span>  /**<a name="line.912"></a>
-<span class="sourceLineNo">913</span>   * Called on store load to initialize the Procedure internals after<a name="line.913"></a>
-<span class="sourceLineNo">914</span>   * the creation/deserialization.<a name="line.914"></a>
-<span class="sourceLineNo">915</span>   */<a name="line.915"></a>
-<span class="sourceLineNo">916</span>  protected synchronized void setStackIndexes(final List&lt;Integer&gt; stackIndexes) {<a name="line.916"></a>
-<span class="sourceLineNo">917</span>    this.stackIndexes = new int[stackIndexes.size()];<a name="line.917"></a>
-<span class="sourceLineNo">918</span>    for (int i = 0; i &lt; this.stackIndexes.length; ++i) {<a name="line.918"></a>
-<span class="sourceLineNo">919</span>      this.stackIndexes[i] = stackIndexes.get(i);<a name="line.919"></a>
-<span class="sourceLineNo">920</span>    }<a name="line.920"></a>
-<span class="sourceLineNo">921</span>  }<a name="line.921"></a>
-<span class="sourceLineNo">922</span><a name="line.922"></a>
-<span class="sourceLineNo">923</span>  protected synchronized boolean wasExecuted() {<a name="line.923"></a>
-<span class="sourceLineNo">924</span>    return stackIndexes != null;<a name="line.924"></a>
+<span class="sourceLineNo">888</span>  protected synchronized int getChildrenLatch() {<a name="line.888"></a>
+<span class="sourceLineNo">889</span>    return childrenLatch;<a name="line.889"></a>
+<span class="sourceLineNo">890</span>  }<a name="line.890"></a>
+<span class="sourceLineNo">891</span><a name="line.891"></a>
+<span class="sourceLineNo">892</span>  /**<a name="line.892"></a>
+<span class="sourceLineNo">893</span>   * Called by the RootProcedureState on procedure execution.<a name="line.893"></a>
+<span class="sourceLineNo">894</span>   * Each procedure store its stack-index positions.<a name="line.894"></a>
+<span class="sourceLineNo">895</span>   */<a name="line.895"></a>
+<span class="sourceLineNo">896</span>  protected synchronized void addStackIndex(final int index) {<a name="line.896"></a>
+<span class="sourceLineNo">897</span>    if (stackIndexes == null) {<a name="line.897"></a>
+<span class="sourceLineNo">898</span>      stackIndexes = new int[] { index };<a name="line.898"></a>
+<span class="sourceLineNo">899</span>    } else {<a name="line.899"></a>
+<span class="sourceLineNo">900</span>      int count = stackIndexes.length;<a name="line.900"></a>
+<span class="sourceLineNo">901</span>      stackIndexes = Arrays.copyOf(stackIndexes, count + 1);<a name="line.901"></a>
+<span class="sourceLineNo">902</span>      stackIndexes[count] = index;<a name="line.902"></a>
+<span class="sourceLineNo">903</span>    }<a name="line.903"></a>
+<span class="sourceLineNo">904</span>  }<a name="line.904"></a>
+<span class="sourceLineNo">905</span><a name="line.905"></a>
+<span class="sourceLineNo">906</span>  protected synchronized boolean removeStackIndex() {<a name="line.906"></a>
+<span class="sourceLineNo">907</span>    if (stackIndexes != null &amp;&amp; stackIndexes.length &gt; 1) {<a name="line.907"></a>
+<span class="sourceLineNo">908</span>      stackIndexes = Arrays.copyOf(stackIndexes, stackIndexes.length - 1);<a name="line.908"></a>
+<span class="sourceLineNo">909</span>      return false;<a name="line.909"></a>
+<span class="sourceLineNo">910</span>    } else {<a name="line.910"></a>
+<span class="sourceLineNo">911</span>      stackIndexes = null;<a name="line.911"></a>
+<span class="sourceLineNo">912</span>      return true;<a name="line.912"></a>
+<span class="sourceLineNo">913</span>    }<a name="line.913"></a>
+<span class="sourceLineNo">914</span>  }<a name="line.914"></a>
+<span class="sourceLineNo">915</span><a name="line.915"></a>
+<span class="sourceLineNo">916</span>  /**<a name="line.916"></a>
+<span class="sourceLineNo">917</span>   * Called on store load to initialize the Procedure internals after<a name="line.917"></a>
+<span class="sourceLineNo">918</span>   * the creation/deserialization.<a name="line.918"></a>
+<span class="sourceLineNo">919</span>   */<a name="line.919"></a>
+<span class="sourceLineNo">920</span>  protected synchronized void setStackIndexes(final List&lt;Integer&gt; stackIndexes) {<a name="line.920"></a>
+<span class="sourceLineNo">921</span>    this.stackIndexes = new int[stackIndexes.size()];<a name="line.921"></a>
+<span class="sourceLineNo">922</span>    for (int i = 0; i &lt; this.stackIndexes.length; ++i) {<a name="line.922"></a>
+<span class="sourceLineNo">923</span>      this.stackIndexes[i] = stackIndexes.get(i);<a name="line.923"></a>
+<span class="sourceLineNo">924</span>    }<a name="line.924"></a>
 <span class="sourceLineNo">925</span>  }<a name="line.925"></a>
 <span class="sourceLineNo">926</span><a name="line.926"></a>
-<span class="sourceLineNo">927</span>  protected synchronized int[] getStackIndexes() {<a name="line.927"></a>
-<span class="sourceLineNo">928</span>    return stackIndexes;<a name="line.928"></a>
+<span class="sourceLineNo">927</span>  protected synchronized boolean wasExecuted() {<a name="line.927"></a>
+<span class="sourceLineNo">928</span>    return stackIndexes != null;<a name="line.928"></a>
 <span class="sourceLineNo">929</span>  }<a name="line.929"></a>
 <span class="sourceLineNo">930</span><a name="line.930"></a>
-<span class="sourceLineNo">931</span>  // ==========================================================================<a name="line.931"></a>
-<span class="sourceLineNo">932</span>  //  Internal methods - called by the ProcedureExecutor<a name="line.932"></a>
-<span class="sourceLineNo">933</span>  // ==========================================================================<a name="line.933"></a>
+<span class="sourceLineNo">931</span>  protected synchronized int[] getStackIndexes() {<a name="line.931"></a>
+<span class="sourceLineNo">932</span>    return stackIndexes;<a name="line.932"></a>
+<span class="sourceLineNo">933</span>  }<a name="line.933"></a>
 <span class="sourceLineNo">934</span><a name="line.934"></a>
-<span class="sourceLineNo">935</span>  /**<a name="line.935"></a>
-<span class="sourceLineNo">936</span>   * Internal method called by the ProcedureExecutor that starts the user-level code execute().<a name="line.936"></a>
-<span class="sourceLineNo">937</span>   * @throws ProcedureSuspendedException This is used when procedure wants to halt processing and<a name="line.937"></a>
-<span class="sourceLineNo">938</span>   *           skip out without changing states or releasing any locks held.<a name="line.938"></a>
-<span class="sourceLineNo">939</span>   */<a name="line.939"></a>
-<span class="sourceLineNo">940</span>  protected Procedure&lt;TEnvironment&gt;[] doExecute(TEnvironment env)<a name="line.940"></a>
-<span class="sourceLineNo">941</span>      throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException {<a name="line.941"></a>
-<span class="sourceLineNo">942</span>    try {<a name="line.942"></a>
-<span class="sourceLineNo">943</span>      updateTimestamp();<a name="line.943"></a>
-<span class="sourceLineNo">944</span>      if (bypass) {<a name="line.944"></a>
-<span class="sourceLineNo">945</span>        LOG.info("{} bypassed, returning null to finish it", this);<a name="line.945"></a>
-<span class="sourceLineNo">946</span>        return null;<a name="line.946"></a>
-<span class="sourceLineNo">947</span>      }<a name="line.947"></a>
-<span class="sourceLineNo">948</span>      return execute(env);<a name="line.948"></a>
-<span class="sourceLineNo">949</span>    } finally {<a name="line.949"></a>
-<span class="sourceLineNo">950</span>      updateTimestamp();<a name="line.950"></a>
-<span class="sourceLineNo">951</span>    }<a name="line.951"></a>
-<span class="sourceLineNo">952</span>  }<a name="line.952"></a>
-<span class="sourceLineNo">953</span><a name="line.953"></a>
-<span class="sourceLineNo">954</span>  /**<a name="line.954"></a>
-<span class="sourceLineNo">955</span>   * Internal method called by the ProcedureExecutor that starts the user-level code rollback().<a name="line.955"></a>
-<span class="sourceLineNo">956</span>   */<a name="line.956"></a>
-<span class="sourceLineNo">957</span>  protected void doRollback(TEnvironment env)<a name="line.957"></a>
-<span class="sourceLineNo">958</span>      throws IOException, InterruptedException {<a name="line.958"></a>
-<span class="sourceLineNo">959</span>    try {<a name="line.959"></a>
-<span class="sourceLineNo">960</span>      updateTimestamp();<a name="line.960"></a>
-<span class="sourceLineNo">961</span>      if (bypass) {<a name="line.961"></a>
-<span class="sourceLineNo">962</span>        LOG.info("{} bypassed, skipping rollback", this);<a name="line.962"></a>
-<span class="sourceLineNo">963</span>        return;<a name="line.963"></a>
-<span class="sourceLineNo">964</span>      }<a name="line.964"></a>
-<span class="sourceLineNo">965</span>      rollback(env);<a name="line.965"></a>
-<span class="sourceLineNo">966</span>    } finally {<a name="line.966"></a>
-<span class="sourceLineNo">967</span>      updateTimestamp();<a name="line.967"></a>
-<span class="sourceLineNo">968</span>    }<a name="line.968"></a>
-<span class="sourceLineNo">969</span>  }<a name="line.969"></a>
-<span class="sourceLineNo">970</span><a name="line.970"></a>
-<span class="sourceLineNo">971</span>  final void restoreLock(TEnvironment env) {<a name="line.971"></a>
-<span class="sourceLineNo">972</span>    if (!lockedWhenLoading) {<a name="line.972"></a>
-<span class="sourceLineNo">973</span>      LOG.debug("{} didn't hold the lock before restarting, skip acquiring lock.", this);<a name="line.973"></a>
-<span class="sourceLineNo">974</span>      return;<a name="line.974"></a>
-<span class="sourceLineNo">975</span>    }<a name="line.975"></a>
-<span class="sourceLineNo">976</span><a name="line.976"></a>
-<span class="sourceLineNo">977</span>    if (isFinished()) {<a name="line.977"></a>
-<span class="sourceLineNo">978</span>      LOG.debug("{} is already finished, skip acquiring lock.", this);<a name="line.978"></a>
-<span class="sourceLineNo">979</span>      return;<a name="line.979"></a>
-<span class="sourceLineNo">980</span>    }<a name="line.980"></a>
-<span class="sourceLineNo">981</span><a name="line.981"></a>
-<span class="sourceLineNo">982</span>    if (isBypass()) {<a name="line.982"></a>
-<span class="sourceLineNo">983</span>      LOG.debug("{} is already bypassed, skip acquiring lock.", this);<a name="line.983"></a>
-<span class="sourceLineNo">984</span>      return;<a name="line.984"></a>
-<span class="sourceLineNo">985</span>    }<a name="line.985"></a>
-<span class="sourceLineNo">986</span><a name="line.986"></a>
-<span class="sourceLineNo">987</span>    LOG.debug("{} held the lock before restarting, call acquireLock to restore it.", this);<a name="line.987"></a>
-<span class="sourceLineNo">988</span>    LockState state = acquireLock(env);<a name="line.988"></a>
-<span class="sourceLineNo">989</span>    assert state == LockState.LOCK_ACQUIRED;<a name="line.989"></a>
-<span class="sourceLineNo">990</span>  }<a name="line.990"></a>
-<span class="sourceLineNo">991</span><a name="line.991"></a>
-<span class="sourceLineNo">992</span>  /**<a name="line.992"></a>
-<span class="sourceLineNo">993</span>   * Internal method called by the ProcedureExecutor that starts the user-level code acquireLock().<a name="line.993"></a>
-<span class="sourceLineNo">994</span>   */<a name="line.994"></a>
-<span class="sourceLineNo">995</span>  final LockState doAcquireLock(TEnvironment env, ProcedureStore store) {<a name="line.995"></a>
-<span class="sourceLineNo">996</span>    if (waitInitialized(env)) {<a name="line.996"></a>
-<span class="sourceLineNo">997</span>      return LockState.LOCK_EVENT_WAIT;<a name="line.997"></a>
-<span class="sourceLineNo">998</span>    }<a name="line.998"></a>
-<span class="sourceLineNo">999</span>    if (lockedWhenLoading) {<a name="line.999"></a>
-<span class="sourceLineNo">1000</span>      // reset it so we will not consider it anymore<a name="line.1000"></a>
-<span class="sourceLineNo">1001</span>      lockedWhenLoading = false;<a name="line.1001"></a>
-<span class="sourceLineNo">1002</span>      locked = true;<a name="line.1002"></a>
-<span class="sourceLineNo">1003</span>      // Here we return without persist the locked state, as lockedWhenLoading is true means<a name="line.1003"></a>
-<span class="sourceLineNo">1004</span>      // that the locked field of the procedure stored in procedure store is true, so we do not need<a name="line.1004"></a>
-<span class="sourceLineNo">1005</span>      // to store it again.<a name="line.1005"></a>
-<span class="sourceLineNo">1006</span>      return LockState.LOCK_ACQUIRED;<a name="line.1006"></a>
-<span class="sourceLineNo">1007</span>    }<a name="line.1007"></a>
-<span class="sourceLineNo">1008</span>    LockState state = acquireLock(env);<a name="line.1008"></a>
-<span class="sourceLineNo">1009</span>    if (state == LockState.LOCK_ACQUIRED) {<a name="line.1009"></a>
-<span class="sourceLineNo">1010</span>      locked = true;<a name="line.1010"></a>
-<span class="sourceLineNo">1011</span>      // persist that we have held the lock. This must be done before we actually execute the<a name="line.1011"></a>
-<span class="sourceLineNo">1012</span>      // procedure, otherwise when restarting, we may consider the procedure does not have a lock,<a name="line.1012"></a>
-<span class="sourceLineNo">1013</span>      // but it may have already done some changes as we have already executed it, and if another<a name="line.1013"></a>
-<span class="sourceLineNo">1014</span>      // procedure gets the lock, then the semantic will be broken if the holdLock is true, as we do<a name="line.1014"></a>
-<span class="sourceLineNo">1015</span>      // not expect that another procedure can be executed in the middle.<a name="line.1015"></a>
-<span class="sourceLineNo">1016</span>      store.update(this);<a name="line.1016"></a>
+<span class="sourceLineNo">935</span>  // ==========================================================================<a name="line.935"></a>
+<span class="sourceLineNo">936</span>  //  Internal methods - called by the ProcedureExecutor<a name="line.936"></a>
+<span class="sourceLineNo">937</span>  // ==========================================================================<a name="line.937"></a>
+<span class="sourceLineNo">938</span><a name="line.938"></a>
+<span class="sourceLineNo">939</span>  /**<a name="line.939"></a>
+<span class="sourceLineNo">940</span>   * Internal method called by the ProcedureExecutor that starts the user-level code execute().<a name="line.940"></a>
+<span class="sourceLineNo">941</span>   * @throws ProcedureSuspendedException This is used when procedure wants to halt processing and<a name="line.941"></a>
+<span class="sourceLineNo">942</span>   *           skip out without changing states or releasing any locks held.<a name="line.942"></a>
+<span class="sourceLineNo">943</span>   */<a name="line.943"></a>
+<span class="sourceLineNo">944</span>  protected Procedure&lt;TEnvironment&gt;[] doExecute(TEnvironment env)<a name="line.944"></a>
+<span class="sourceLineNo">945</span>      throws ProcedureYieldException, ProcedureSuspendedException, InterruptedException {<a name="line.945"></a>
+<span class="sourceLineNo">946</span>    try {<a name="line.946"></a>
+<span class="sourceLineNo">947</span>      updateTimestamp();<a name="line.947"></a>
+<span class="sourceLineNo">948</span>      if (bypass) {<a name="line.948"></a>
+<span class="sourceLineNo">949</span>        LOG.info("{} bypassed, returning null to finish it", this);<a name="line.949"></a>
+<span class="sourceLineNo">950</span>        return null;<a name="line.950"></a>
+<span class="sourceLineNo">951</span>      }<a name="line.951"></a>
+<span class="sourceLineNo">952</span>      return execute(env);<a name="line.952"></a>
+<span class="sourceLineNo">953</span>    } finally {<a name="line.953"></a>
+<span class="sourceLineNo">954</span>      updateTimestamp();<a name="line.954"></a>
+<span class="sourceLineNo">955</span>    }<a name="line.955"></a>
+<span class="sourceLineNo">956</span>  }<a name="line.956"></a>
+<span class="sourceLineNo">957</span><a name="line.957"></a>
+<span class="sourceLineNo">958</span>  /**<a name="line.958"></a>
+<span class="sourceLineNo">959</span>   * Internal method called by the ProcedureExecutor that starts the user-level code rollback().<a name="line.959"></a>
+<span class="sourceLineNo">960</span>   */<a name="line.960"></a>
+<span class="sourceLineNo">961</span>  protected void doRollback(TEnvironment env)<a name="line.961"></a>
+<span class="sourceLineNo">962</span>      throws IOException, InterruptedException {<a name="line.962"></a>
+<span class="sourceLineNo">963</span>    try {<a name="line.963"></a>
+<span class="sourceLineNo">964</span>      updateTimestamp();<a name="line.964"></a>
+<span class="sourceLineNo">965</span>      if (bypass) {<a name="line.965"></a>
+<span class="sourceLineNo">966</span>        LOG.info("{} bypassed, skipping rollback", this);<a name="line.966"></a>
+<span class="sourceLineNo">967</span>        return;<a name="line.967"></a>
+<span class="sourceLineNo">968</span>      }<a name="line.968"></a>
+<span class="sourceLineNo">969</span>      rollback(env);<a name="line.969"></a>
+<span class="sourceLineNo">970</span>    } finally {<a name="line.970"></a>
+<span class="sourceLineNo">971</span>      updateTimestamp();<a name="line.971"></a>
+<span class="sourceLineNo">972</span>    }<a name="line.972"></a>
+<span class="sourceLineNo">973</span>  }<a name="line.973"></a>
+<span class="sourceLineNo">974</span><a name="line.974"></a>
+<span class="sourceLineNo">975</span>  final void restoreLock(TEnvironment env) {<a name="line.975"></a>
+<span class="sourceLineNo">976</span>    if (!lockedWhenLoading) {<a name="line.976"></a>
+<span class="sourceLineNo">977</span>      LOG.debug("{} didn't hold the lock before restarting, skip acquiring lock.", this);<a name="line.977"></a>
+<span class="sourceLineNo">978</span>      return;<a name="line.978"></a>
+<span class="sourceLineNo">979</span>    }<a name="line.979"></a>
+<span class="sourceLineNo">980</span><a name="line.980"></a>
+<span class="sourceLineNo">981</span>    if (isFinished()) {<a name="line.981"></a>
+<span class="sourceLineNo">982</span>      LOG.debug("{} is already finished, skip acquiring lock.", this);<a name="line.982"></a>
+<span class="sourceLineNo">983</span>      return;<a name="line.983"></a>
+<span class="sourceLineNo">984</span>    }<a name="line.984"></a>
+<span class="sourceLineNo">985</span><a name="line.985"></a>
+<span class="sourceLineNo">986</span>    if (isBypass()) {<a name="line.986"></a>
+<span class="sourceLineNo">987</span>      LOG.debug("{} is already bypassed, skip acquiring lock.", this);<a name="line.987"></a>
+<span class="sourceLineNo">988</span>      return;<a name="line.988"></a>
+<span class="sourceLineNo">989</span>    }<a name="line.989"></a>
+<span class="sourceLineNo">990</span>    // this can happen if the parent stores the sub procedures but before it can<a name="line.990"></a>
+<span class="sourceLineNo">991</span>    // release its lock, the master restarts<a name="line.991"></a>
+<span class="sourceLineNo">992</span>    if (getState() == ProcedureState.WAITING &amp;&amp; !holdLock(env)) {<a name="line.992"></a>
+<span class="sourceLineNo">993</span>      LOG.debug("{} is in WAITING STATE, and holdLock= false, skip acquiring lock.", this);<a name="line.993"></a>
+<span class="sourceLineNo">994</span>      lockedWhenLoading = false;<a name="line.994"></a>
+<span class="sourceLineNo">995</span>      return;<a name="line.995"></a>
+<span class="sourceLineNo">996</span>    }<a name="line.996"></a>
+<span class="sourceLineNo">997</span>    LOG.debug("{} held the lock before restarting, call acquireLock to restore it.", this);<a name="line.997"></a>
+<span class="sourceLineNo">998</span>    LockState state = acquireLock(env);<a name="line.998"></a>
+<span class="sourceLineNo">999</span>    assert state == LockState.LOCK_ACQUIRED;<a name="line.999"></a>
+<span class="sourceLineNo">1000</span>  }<a name="line.1000"></a>
+<span class="sourceLineNo">1001</span><a name="line.1001"></a>
+<span class="sourceLineNo">1002</span>  /**<a name="line.1002"></a>
+<span class="sourceLineNo">1003</span>   * Internal method called by the ProcedureExecutor that starts the user-level code acquireLock().<a name="line.1003"></a>
+<span class="sourceLineNo">1004</span>   */<a name="line.1004"></a>
+<span class="sourceLineNo">1005</span>  final LockState doAcquireLock(TEnvironment env, ProcedureStore store) {<a name="line.1005"></a>
+<span class="sourceLineNo">1006</span>    if (waitInitialized(env)) {<a name="line.1006"></a>
+<span class="sourceLineNo">1007</span>      return LockState.LOCK_EVENT_WAIT;<a name="line.1007"></a>
+<span class="sourceLineNo">1008</span>    }<a name="line.1008"></a>
+<span class="sourceLineNo">1009</span>    if (lockedWhenLoading) {<a name="line.1009"></a>
+<span class="sourceLineNo">1010</span>      // reset it so we will not consider it anymore<a name="line.1010"></a>
+<span class="sourceLineNo">1011</span>      lockedWhenLoading = false;<a name="line.1011"></a>
+<span class="sourceLineNo">1012</span>      locked = true;<a name="line.1012"></a>
+<span class="sourceLineNo">1013</span>      // Here we return without persist the locked state, as lockedWhenLoading is true means<a name="line.1013"></a>
+<span class="sourceLineNo">1014</span>      // that the locked field of the procedure stored in procedure store is true, so we do not need<a name="line.1014"></a>
+<span class="sourceLineNo">1015</span>      // to store it again.<a name="line.1015"></a>
+<span class="sourceLineNo">1016</span>      return LockState.LOCK_ACQUIRED;<a name="line.1016"></a>
 <span class="sourceLineNo">1017</span>    }<a name="line.1017"></a>
-<span class="sourceLineNo">1018</span>    return state;<a name="line.1018"></a>
-<span class="sourceLineNo">1019</span>  }<a name="line.1019"></a>
-<span class="sourceLineNo">1020</span><a name="line.1020"></a>
-<span class="sourceLineNo">1021</span>  /**<a name="line.1021"></a>
-<span class="sourceLineNo">1022</span>   * Internal method called by the ProcedureExecutor that starts the user-level code releaseLock().<a name="line.1022"></a>
-<span class="sourceLineNo">1023</span>   */<a name="line.1023"></a>
-<span class="sourceLineNo">1024</span>  final void doReleaseLock(TEnvironment env, ProcedureStore store) {<a name="line.1024"></a>
-<span class="sourceLineNo">1025</span>    locked = false;<a name="line.1025"></a>
-<span class="sourceLineNo">1026</span>    // persist that we have released the lock. This must be done before we actually release the<a name="line.1026"></a>
-<span class="sourceLineNo">1027</span>    // lock. Another procedure may take this lock immediately after we release the lock, and if we<a name="line.1027"></a>
-<span class="sourceLineNo">1028</span>    // crash before persist the information that we have already released the lock, then when<a name="line.1028"></a>
-<span class="sourceLineNo">1029</span>    // restarting there will be two procedures which both have the lock and cause problems.<a name="line.1029"></a>
-<span class="sourceLineNo">1030</span>    if (getState() != ProcedureState.ROLLEDBACK) {<a name="line.1030"></a>
-<span class="sourceLineNo">1031</span>      // If the state is ROLLEDBACK, it means that we have already deleted the procedure from<a name="line.1031"></a>
-<span class="sourceLineNo">1032</span>      // procedure store, so do not need to log the release operation any more.<a name="line.1032"></a>
-<span class="sourceLineNo">1033</span>      store.update(this);<a name="line.1033"></a>
-<span class="sourceLineNo">1034</span>    }<a name="line.1034"></a>
-<span class="sourceLineNo">1035</span>    releaseLock(env);<a name="line.1035"></a>
-<span class="sourceLineNo">1036</span>  }<a name="line.1036"></a>
-<span class="sourceLineNo">1037</span><a name="line.1037"></a>
-<span class="sourceLineNo">1038</span>  @Override<a name="line.1038"></a>
-<span class="sourceLineNo">1039</span>  public int compareTo(final Procedure&lt;TEnvironment&gt; other) {<a name="line.1039"></a>
-<span class="sourceLineNo">1040</span>    return Long.compare(getProcId(), other.getProcId());<a name="line.1040"></a>
-<span class="sourceLineNo">1041</span>  }<a name="line.1041"></a>
-<span class="sourceLineNo">1042</span><a name="line.1042"></a>
-<span class="sourceLineNo">1043</span>  // ==========================================================================<a name="line.1043"></a>
-<span class="sourceLineNo">1044</span>  //  misc utils<a name="line.1044"></a>
-<span class="sourceLineNo">1045</span>  // ==========================================================================<a name="line.1045"></a>
-<span class="sourceLineNo">1046</span><a name="line.1046"></a>
-<span class="sourceLineNo">1047</span>  /**<a name="line.1047"></a>
-<span class="sourceLineNo">1048</span>   * Get an hashcode for the specified Procedure ID<a name="line.1048"></a>
-<span class="sourceLineNo">1049</span>   * @return the hashcode for the specified procId<a name="line.1049"></a>
-<span class="sourceLineNo">1050</span>   */<a name="line.1050"></a>
-<span class="sourceLineNo">1051</span>  public static long getProcIdHashCode(long procId) {<a name="line.1051"></a>
-<span class="sourceLineNo">1052</span>    long h = procId;<a name="line.1052"></a>
-<span class="sourceLineNo">1053</span>    h ^= h &gt;&gt; 16;<a name="line.1053"></a>
-<span class="sourceLineNo">1054</span>    h *= 0x85ebca6b;<a name="line.1054"></a>
-<span class="sourceLineNo">1055</span>    h ^= h &gt;&gt; 13;<a name="line.1055"></a>
-<span class="sourceLineNo">1056</span>    h *= 0xc2b2ae35;<a name="line.1056"></a>
-<span class="sourceLineNo">1057</span>    h ^= h &gt;&gt; 16;<a name="line.1057"></a>
-<span class="sourceLineNo">1058</span>    return h;<a name="line.1058"></a>
-<span class="sourceLineNo">1059</span>  }<a name="line.1059"></a>
-<span class="sourceLineNo">1060</span><a name="line.1060"></a>
-<span class="sourceLineNo">1061</span>  /**<a name="line.1061"></a>
-<span class="sourceLineNo">1062</span>   * Helper to lookup the root Procedure ID given a specified procedure.<a name="line.1062"></a>
-<span class="sourceLineNo">1063</span>   */<a name="line.1063"></a>
-<span class="sourceLineNo">1064</span>  protected static &lt;T&gt; Long getRootProcedureId(Map&lt;Long, Procedure&lt;T&gt;&gt; procedures,<a name="line.1064"></a>
-<span class="sourceLineNo">1065</span>      Procedure&lt;T&gt; proc) {<a name="line.1065"></a>
-<span class="sourceLineNo">1066</span>    while (proc.hasParent()) {<a name="line.1066"></a>
-<span class="sourceLineNo">1067</span>      proc = procedures.get(proc.getParentProcId());<a name="line.1067"></a>
-<span class="sourceLineNo">1068</span>      if (proc == null) {<a name="line.1068"></a>
-<span class="sourceLineNo">1069</span>        return null;<a name="line.1069"></a>
-<span class="sourceLineNo">1070</span>      }<a name="line.1070"></a>
-<span class="sourceLineNo">1071</span>    }<a name="line.1071"></a>
-<span class="sourceLineNo">1072</span>    return proc.getProcId();<a name="line.1072"></a>
-<span class="sourceLineNo">1073</span>  }<a name="line.1073"></a>
-<span class="sourceLineNo">1074</span><a name="line.1074"></a>
-<span class="sourceLineNo">1075</span>  /**<a name="line.1075"></a>
-<span class="sourceLineNo">1076</span>   * @param a the first procedure to be compared.<a name="line.1076"></a>
-<span class="sourceLineNo">1077</span>   * @param b the second procedure to be compared.<a name="line.1077"></a>
-<span class="sourceLineNo">1078</span>   * @return true if the two procedures have the same parent<a name="line.1078"></a>
-<span class="sourceLineNo">1079</span>   */<a name="line.1079"></a>
-<span class="sourceLineNo">1080</span>  public static boolean haveSameParent(Procedure&lt;?&gt; a, Procedure&lt;?&gt; b) {<a name="line.1080"></a>
-<span class="sourceLineNo">1081</span>    return a.hasParent() &amp;&amp; b.hasParent() &amp;&amp; (a.getParentProcId() == b.getParentProcId());<a name="line.1081"></a>
-<span class="sourceLineNo">1082</span>  }<a name="line.1082"></a>
-<span class="sourceLineNo">1083</span>}<a name="line.1083"></a>
+<span class="sourceLineNo">1018</span>    LockState state = acquireLock(env);<a name="line.1018"></a>
+<span class="sourceLineNo">1019</span>    if (state == LockState.LOCK_ACQUIRED) {<a name="line.1019"></a>
+<span class="sourceLineNo">1020</span>      locked = true;<a name="line.1020"></a>
+<span class="sourceLineNo">1021</span>      // persist that we have held the lock. This must be done before we actually execute the<a name="line.1021"></a>
+<span class="sourceLineNo">1022</span>      // procedure, otherwise when restarting, we may consider the procedure does not have a lock,<a name="line.1022"></a>
+<span class="sourceLineNo">1023</span>      // but it may have already done some changes as we have already executed it, and if another<a name="line.1023"></a>
+<span class="sourceLineNo">1024</span>      // procedure gets the lock, then the semantic will be broken if the holdLock is true, as we do<a name="line.1024"></a>
+<span class="sourceLineNo">1025</span>      // not expect that another procedure can be executed in the middle.<a name="line.1025"></a>
+<span class="sourceLineNo">1026</span>      store.update(this);<a name="line.1026"></a>
+<span class="sourceLineNo">1027</span>    }<a name="line.1027"></a>
+<span class="sourceLineNo">1028</span>    return state;<a name="line.1028"></a>
+<span class="sourceLineNo">1029</span>  }<a name="line.1029"></a>
+<span class="sourceLineNo">1030</span><a name="line.1030"></a>
+<span class="sourceLineNo">1031</span>  /**<a name="line.1031"></a>
+<span class="sourceLineNo">1032</span>   * Internal method called by the ProcedureExecutor that starts the user-level code releaseLock().<a name="line.1032"></a>
+<span class="sourceLineNo">1033</span>   */<a name="line.1033"></a>
+<span class="sourceLineNo">1034</span>  final void doReleaseLock(TEnvironment env, ProcedureStore store) {<a name="line.1034"></a>
+<span class="sourceLineNo">1035</span>    locked = false;<a name="line.1035"></a>
+<span class="sourceLineNo">1036</span>    // persist that we have released the lock. This must be done before we actually release the<a name="line.1036"></a>
+<span class="sourceLineNo">1037</span>    // lock. Another procedure may take this lock immediately after we release the lock, and if we<a name="line.1037"></a>
+<span class="sourceLineNo">1038</span>    // crash before persist the information that we have already released the lock, then when<a name="line.1038"></a>
+<span class="sourceLineNo">1039</span>    // restarting there will be two procedures which both have the lock and cause problems.<a name="line.1039"></a>
+<span class="sourceLineNo">1040</span>    if (getState() != ProcedureState.ROLLEDBACK) {<a name="line.1040"></a>
+<span class="sourceLineNo">1041</span>      // If the state is ROLLEDBACK, it means that we have already deleted the procedure from<a name="line.1041"></a>
+<span class="sourceLineNo">1042</span>      // procedure store, so do not need to log the release operation any more.<a name="line.1042"></a>
+<span class="sourceLineNo">1043</span>      store.update(this);<a name="line.1043"></a>
+<span class="sourceLineNo">1044</span>    }<a name="line.1044"></a>
+<span class="sourceLineNo">1045</span>    releaseLock(env);<a name="line.1045"></a>
+<span class="sourceLineNo">1046</span>  }<a name="line.1046"></a>
+<span class="sourceLineNo">1047</span><a name="line.1047"></a>
+<span class="sourceLineNo">1048</span>  @Override<a name="line.1048"></a>
+<span class="sourceLineNo">1049</span>  public int compareTo(final Procedure&lt;TEnvironment&gt; other) {<a name="line.1049"></a>
+<span class="sourceLineNo">1050</span>    return Long.compare(getProcId(), other.getProcId());<a name="line.1050"></a>
+<span class="sourceLineNo">1051</span>  }<a name="line.1051"></a>
+<span class="sourceLineNo">1052</span><a name="line.1052"></a>
+<span class="sourceLineNo">1053</span>  // ==========================================================================<a name="line.1053"></a>
+<span class="sourceLineNo">1054</span>  //  misc utils<a name="line.1054"></a>
+<span class="sourceLineNo">1055</span>  // ==========================================================================<a name="line.1055"></a>
+<span class="sourceLineNo">1056</span><a name="line.1056"></a>
+<span class="sourceLineNo">1057</span>  /**<a name="line.1057"></a>
+<span class="sourceLineNo">1058</span>   * Get an hashcode for the specified Procedure ID<a name="line.1058"></a>
+<span class="sourceLineNo">1059</span>   * @return the hashcode for the specified procId<a name="line.1059"></a>
+<span class="sourceLineNo">1060</span>   */<a name="line.1060"></a>
+<span class="sourceLineNo">1061</span>  public static long getProcIdHashCode(long procId) {<a name="line.1061"></a>
+<span class="sourceLineNo">1062</span>    long h = procId;<a name="line.1062"></a>
+<span class="sourceLineNo">1063</span>    h ^= h &gt;&gt; 16;<a name="line.1063"></a>
+<span class="sourceLineNo">1064</span>    h *= 0x85ebca6b;<a name="line.1064"></a>
+<span class="sourceLineNo">1065</span>    h ^= h &gt;&gt; 13;<a name="line.1065"></a>
+<span class="sourceLineNo">1066</span>    h *= 0xc2b2ae35;<a name="line.1066"></a>
+<span class="sourceLineNo">1067</span>    h ^= h &gt;&gt; 16;<a name="line.1067"></a>
+<span class="sourceLineNo">1068</span>    return h;<a name="line.1068"></a>
+<span class="sourceLineNo">1069</span>  }<a name="line.1069"></a>
+<span class="sourceLineNo">1070</span><a name="line.1070"></a>
+<span class="sourceLineNo">1071</span>  /**<a name="line.1071"></a>
+<span class="sourceLineNo">1072</span>   * Helper to lookup the root Procedure ID given a specified procedure.<a name="line.1072"></a>
+<span class="sourceLineNo">1073</span>   */<a name="line.1073"></a>
+<span class="sourceLineNo">1074</span>  protected static &lt;T&gt; Long getRootProcedureId(Map&lt;Long, Procedure&lt;T&gt;&gt; procedures,<a name="line.1074"></a>
+<span class="sourceLineNo">1075</span>      Procedure&lt;T&gt; proc) {<a name="line.1075"></a>
+<span class="sourceLineNo">1076</span>    while (proc.hasParent()) {<a name="line.1076"></a>
+<span class="sourceLineNo">1077</span>      proc = procedures.get(proc.getParentProcId());<a name="line.1077"></a>
+<span class="sourceLineNo">1078</span>      if (proc == null) {<a name="line.1078"></a>
+<span class="sourceLineNo">1079</span>        return null;<a name="line.1079"></a>
+<span class="sourceLineNo">1080</span>      }<a name="line.1080"></a>
+<span class="sourceLineNo">1081</span>    }<a name="line.1081"></a>
+<span class="sourceLineNo">1082</span>    return proc.getProcId();<a name="line.1082"></a>
+<span class="sourceLineNo">1083</span>  }<a name="line.1083"></a>
+<span class="sourceLineNo">1084</span><a name="line.1084"></a>
+<span class="sourceLineNo">1085</span>  /**<a name="line.1085"></a>
+<span class="sourceLineNo">1086</span>   * @param a the first procedure to be compared.<a name="line.1086"></a>
+<span class="sourceLineNo">1087</span>   * @param b the second procedure to be compared.<a name="line.1087"></a>
+<span class="sourceLineNo">1088</span>   * @return true if the two procedures have the same parent<a name="line.1088"></a>
+<span class="sourceLineNo">1089</span>   */<a name="line.1089"></a>
+<span class="sourceLineNo">1090</span>  public static boolean haveSameParent(Procedure&lt;?&gt; a, Procedure&lt;?&gt; b) {<a name="line.1090"></a>
+<span class="sourceLineNo">1091</span>    return a.hasParent() &amp;&amp; b.hasParent() &amp;&amp; (a.getParentProcId() == b.getParentProcId());<a name="line.1091"></a>
+<span class="sourceLineNo">1092</span>  }<a name="line.1092"></a>
+<span class="sourceLineNo">1093</span>}<a name="line.1093"></a>
 
 
 


Mime
View raw message