Return-Path: X-Original-To: apmail-hbase-commits-archive@www.apache.org Delivered-To: apmail-hbase-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id E50F41893D for ; Thu, 3 Mar 2016 17:17:02 +0000 (UTC) Received: (qmail 71195 invoked by uid 500); 3 Mar 2016 17:16:49 -0000 Delivered-To: apmail-hbase-commits-archive@hbase.apache.org Received: (qmail 71114 invoked by uid 500); 3 Mar 2016 17:16:49 -0000 Mailing-List: contact commits-help@hbase.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@hbase.apache.org Delivered-To: mailing list commits@hbase.apache.org Received: (qmail 69031 invoked by uid 99); 3 Mar 2016 17:16:48 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Mar 2016 17:16:48 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id 5C7EAE7902; Thu, 3 Mar 2016 17:16:48 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: misty@apache.org To: commits@hbase.apache.org Date: Thu, 03 Mar 2016 17:17:17 -0000 Message-Id: <3c3f9e3875fd482f8c67e70c515fbab9@git.apache.org> In-Reply-To: <0956c332793142c0a2f193526c17722f@git.apache.org> References: <0956c332793142c0a2f193526c17722f@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [31/49] hbase-site git commit: Published site at 4b3e38705cb24aee82615b1b9af47ed549ea1358. http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.Flow.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.Flow.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.Flow.html index e83e623..eebec9d 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.Flow.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.Flow.html @@ -29,179 +29,200 @@ 021import java.io.IOException; 022import java.io.InputStream; 023import java.io.OutputStream; -024import java.util.Arrays; -025 -026import org.apache.hadoop.hbase.classification.InterfaceAudience; -027import org.apache.hadoop.hbase.classification.InterfaceStability; -028import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.StateMachineProcedureData; -029 -030/** -031 * Procedure described by a series of steps. -032 * -033 * The procedure implementor must have an enum of 'states', describing -034 * the various step of the procedure. -035 * Once the procedure is running, the procedure-framework will call executeFromState() -036 * using the 'state' provided by the user. The first call to executeFromState() -037 * will be performed with 'state = null'. The implementor can jump between -038 * states using setNextState(MyStateEnum.ordinal()). -039 * The rollback will call rollbackState() for each state that was executed, in reverse order. -040 */ -041@InterfaceAudience.Private -042@InterfaceStability.Evolving -043public abstract class StateMachineProcedure<TEnvironment, TState> -044 extends Procedure<TEnvironment> { -045 private int stateCount = 0; -046 private int[] states = null; -047 -048 protected enum Flow { -049 HAS_MORE_STATE, -050 NO_MORE_STATE, -051 } -052 -053 /** -054 * called to perform a single step of the specified 'state' of the procedure -055 * @param state state to execute -056 * @return Flow.NO_MORE_STATE if the procedure is completed, -057 * Flow.HAS_MORE_STATE if there is another step. -058 */ -059 protected abstract Flow executeFromState(TEnvironment env, TState state) -060 throws ProcedureYieldException, InterruptedException; -061 -062 /** -063 * called to perform the rollback of the specified state -064 * @param state state to rollback -065 * @throws IOException temporary failure, the rollback will retry later -066 */ -067 protected abstract void rollbackState(TEnvironment env, TState state) -068 throws IOException, InterruptedException; -069 -070 /** -071 * Convert an ordinal (or state id) to an Enum (or more descriptive) state object. -072 * @param stateId the ordinal() of the state enum (or state id) -073 * @return the state enum object -074 */ -075 protected abstract TState getState(int stateId); -076 -077 /** -078 * Convert the Enum (or more descriptive) state object to an ordinal (or state id). -079 * @param state the state enum object -080 * @return stateId the ordinal() of the state enum (or state id) -081 */ -082 protected abstract int getStateId(TState state); -083 -084 /** -085 * Return the initial state object that will be used for the first call to executeFromState(). -086 * @return the initial state enum object -087 */ -088 protected abstract TState getInitialState(); -089 -090 /** -091 * Set the next state for the procedure. -092 * @param state the state enum object -093 */ -094 protected void setNextState(final TState state) { -095 setNextState(getStateId(state)); -096 } -097 -098 /** -099 * By default, the executor will try ro run all the steps of the procedure start to finish. -100 * Return true to make the executor yield between execution steps to -101 * give other procedures time to run their steps. -102 * @param state the state we are going to execute next. -103 * @return Return true if the executor should yield before the execution of the specified step. -104 * Defaults to return false. -105 */ -106 protected boolean isYieldBeforeExecuteFromState(TEnvironment env, TState state) { -107 return false; -108 } -109 -110 @Override -111 protected Procedure[] execute(final TEnvironment env) -112 throws ProcedureYieldException, InterruptedException { -113 updateTimestamp(); -114 try { -115 TState state = getCurrentState(); -116 if (stateCount == 0) { -117 setNextState(getStateId(state)); -118 } -119 if (executeFromState(env, state) == Flow.NO_MORE_STATE) { -120 // completed -121 return null; -122 } -123 return (isWaiting() || isFailed()) ? null : new Procedure[] {this}; -124 } finally { -125 updateTimestamp(); -126 } -127 } -128 -129 @Override -130 protected void rollback(final TEnvironment env) -131 throws IOException, InterruptedException { -132 try { -133 updateTimestamp(); -134 rollbackState(env, getCurrentState()); -135 stateCount--; -136 } finally { -137 updateTimestamp(); -138 } -139 } -140 -141 @Override -142 protected boolean isYieldAfterExecutionStep(final TEnvironment env) { -143 return isYieldBeforeExecuteFromState(env, getCurrentState()); -144 } -145 -146 private TState getCurrentState() { -147 return stateCount > 0 ? getState(states[stateCount-1]) : getInitialState(); +024import java.util.ArrayList; +025import java.util.Arrays; +026 +027import org.apache.hadoop.hbase.classification.InterfaceAudience; +028import org.apache.hadoop.hbase.classification.InterfaceStability; +029import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.StateMachineProcedureData; +030 +031/** +032 * Procedure described by a series of steps. +033 * +034 * The procedure implementor must have an enum of 'states', describing +035 * the various step of the procedure. +036 * Once the procedure is running, the procedure-framework will call executeFromState() +037 * using the 'state' provided by the user. The first call to executeFromState() +038 * will be performed with 'state = null'. The implementor can jump between +039 * states using setNextState(MyStateEnum.ordinal()). +040 * The rollback will call rollbackState() for each state that was executed, in reverse order. +041 */ +042@InterfaceAudience.Private +043@InterfaceStability.Evolving +044public abstract class StateMachineProcedure<TEnvironment, TState> +045 extends Procedure<TEnvironment> { +046 private int stateCount = 0; +047 private int[] states = null; +048 +049 private ArrayList<Procedure> subProcList = null; +050 +051 protected enum Flow { +052 HAS_MORE_STATE, +053 NO_MORE_STATE, +054 } +055 +056 /** +057 * called to perform a single step of the specified 'state' of the procedure +058 * @param state state to execute +059 * @return Flow.NO_MORE_STATE if the procedure is completed, +060 * Flow.HAS_MORE_STATE if there is another step. +061 */ +062 protected abstract Flow executeFromState(TEnvironment env, TState state) +063 throws ProcedureYieldException, InterruptedException; +064 +065 /** +066 * called to perform the rollback of the specified state +067 * @param state state to rollback +068 * @throws IOException temporary failure, the rollback will retry later +069 */ +070 protected abstract void rollbackState(TEnvironment env, TState state) +071 throws IOException, InterruptedException; +072 +073 /** +074 * Convert an ordinal (or state id) to an Enum (or more descriptive) state object. +075 * @param stateId the ordinal() of the state enum (or state id) +076 * @return the state enum object +077 */ +078 protected abstract TState getState(int stateId); +079 +080 /** +081 * Convert the Enum (or more descriptive) state object to an ordinal (or state id). +082 * @param state the state enum object +083 * @return stateId the ordinal() of the state enum (or state id) +084 */ +085 protected abstract int getStateId(TState state); +086 +087 /** +088 * Return the initial state object that will be used for the first call to executeFromState(). +089 * @return the initial state enum object +090 */ +091 protected abstract TState getInitialState(); +092 +093 /** +094 * Set the next state for the procedure. +095 * @param state the state enum object +096 */ +097 protected void setNextState(final TState state) { +098 setNextState(getStateId(state)); +099 } +100 +101 /** +102 * By default, the executor will try ro run all the steps of the procedure start to finish. +103 * Return true to make the executor yield between execution steps to +104 * give other procedures time to run their steps. +105 * @param state the state we are going to execute next. +106 * @return Return true if the executor should yield before the execution of the specified step. +107 * Defaults to return false. +108 */ +109 protected boolean isYieldBeforeExecuteFromState(TEnvironment env, TState state) { +110 return false; +111 } +112 +113 /** +114 * Add a child procedure to execute +115 * @param subProcedure the child procedure +116 */ +117 protected void addChildProcedure(Procedure subProcedure) { +118 if (subProcList == null) { +119 subProcList = new ArrayList<Procedure>(); +120 } +121 subProcList.add(subProcedure); +122 } +123 +124 @Override +125 protected Procedure[] execute(final TEnvironment env) +126 throws ProcedureYieldException, InterruptedException { +127 updateTimestamp(); +128 try { +129 TState state = getCurrentState(); +130 if (stateCount == 0) { +131 setNextState(getStateId(state)); +132 } +133 if (executeFromState(env, state) == Flow.NO_MORE_STATE) { +134 // completed +135 return null; +136 } +137 +138 if (subProcList != null && subProcList.size() != 0) { +139 Procedure[] subProcedures = subProcList.toArray(new Procedure[subProcList.size()]); +140 subProcList = null; +141 return subProcedures; +142 } +143 +144 return (isWaiting() || isFailed()) ? null : new Procedure[] {this}; +145 } finally { +146 updateTimestamp(); +147 } 148 } 149 -150 /** -151 * Set the next state for the procedure. -152 * @param stateId the ordinal() of the state enum (or state id) -153 */ -154 private void setNextState(final int stateId) { -155 if (states == null || states.length == stateCount) { -156 int newCapacity = stateCount + 8; -157 if (states != null) { -158 states = Arrays.copyOf(states, newCapacity); -159 } else { -160 states = new int[newCapacity]; -161 } -162 } -163 states[stateCount++] = stateId; -164 } -165 -166 @Override -167 protected void toStringState(StringBuilder builder) { -168 super.toStringState(builder); -169 if (!isFinished() && getCurrentState() != null) { -170 builder.append(":").append(getCurrentState()); -171 } -172 } -173 -174 @Override -175 protected void serializeStateData(final OutputStream stream) throws IOException { -176 StateMachineProcedureData.Builder data = StateMachineProcedureData.newBuilder(); -177 for (int i = 0; i < stateCount; ++i) { -178 data.addState(states[i]); -179 } -180 data.build().writeDelimitedTo(stream); -181 } -182 -183 @Override -184 protected void deserializeStateData(final InputStream stream) throws IOException { -185 StateMachineProcedureData data = StateMachineProcedureData.parseDelimitedFrom(stream); -186 stateCount = data.getStateCount(); -187 if (stateCount > 0) { -188 states = new int[stateCount]; -189 for (int i = 0; i < stateCount; ++i) { -190 states[i] = data.getState(i); -191 } -192 } else { -193 states = null; -194 } -195 } -196} +150 @Override +151 protected void rollback(final TEnvironment env) +152 throws IOException, InterruptedException { +153 try { +154 updateTimestamp(); +155 rollbackState(env, getCurrentState()); +156 stateCount--; +157 } finally { +158 updateTimestamp(); +159 } +160 } +161 +162 @Override +163 protected boolean isYieldAfterExecutionStep(final TEnvironment env) { +164 return isYieldBeforeExecuteFromState(env, getCurrentState()); +165 } +166 +167 private TState getCurrentState() { +168 return stateCount > 0 ? getState(states[stateCount-1]) : getInitialState(); +169 } +170 +171 /** +172 * Set the next state for the procedure. +173 * @param stateId the ordinal() of the state enum (or state id) +174 */ +175 private void setNextState(final int stateId) { +176 if (states == null || states.length == stateCount) { +177 int newCapacity = stateCount + 8; +178 if (states != null) { +179 states = Arrays.copyOf(states, newCapacity); +180 } else { +181 states = new int[newCapacity]; +182 } +183 } +184 states[stateCount++] = stateId; +185 } +186 +187 @Override +188 protected void toStringState(StringBuilder builder) { +189 super.toStringState(builder); +190 if (!isFinished() && getCurrentState() != null) { +191 builder.append(":").append(getCurrentState()); +192 } +193 } +194 +195 @Override +196 protected void serializeStateData(final OutputStream stream) throws IOException { +197 StateMachineProcedureData.Builder data = StateMachineProcedureData.newBuilder(); +198 for (int i = 0; i < stateCount; ++i) { +199 data.addState(states[i]); +200 } +201 data.build().writeDelimitedTo(stream); +202 } +203 +204 @Override +205 protected void deserializeStateData(final InputStream stream) throws IOException { +206 StateMachineProcedureData data = StateMachineProcedureData.parseDelimitedFrom(stream); +207 stateCount = data.getStateCount(); +208 if (stateCount > 0) { +209 states = new int[stateCount]; +210 for (int i = 0; i < stateCount; ++i) { +211 states[i] = data.getState(i); +212 } +213 } else { +214 states = null; +215 } +216 } +217} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.html b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.html index e83e623..eebec9d 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/procedure2/StateMachineProcedure.html @@ -29,179 +29,200 @@ 021import java.io.IOException; 022import java.io.InputStream; 023import java.io.OutputStream; -024import java.util.Arrays; -025 -026import org.apache.hadoop.hbase.classification.InterfaceAudience; -027import org.apache.hadoop.hbase.classification.InterfaceStability; -028import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.StateMachineProcedureData; -029 -030/** -031 * Procedure described by a series of steps. -032 * -033 * The procedure implementor must have an enum of 'states', describing -034 * the various step of the procedure. -035 * Once the procedure is running, the procedure-framework will call executeFromState() -036 * using the 'state' provided by the user. The first call to executeFromState() -037 * will be performed with 'state = null'. The implementor can jump between -038 * states using setNextState(MyStateEnum.ordinal()). -039 * The rollback will call rollbackState() for each state that was executed, in reverse order. -040 */ -041@InterfaceAudience.Private -042@InterfaceStability.Evolving -043public abstract class StateMachineProcedure<TEnvironment, TState> -044 extends Procedure<TEnvironment> { -045 private int stateCount = 0; -046 private int[] states = null; -047 -048 protected enum Flow { -049 HAS_MORE_STATE, -050 NO_MORE_STATE, -051 } -052 -053 /** -054 * called to perform a single step of the specified 'state' of the procedure -055 * @param state state to execute -056 * @return Flow.NO_MORE_STATE if the procedure is completed, -057 * Flow.HAS_MORE_STATE if there is another step. -058 */ -059 protected abstract Flow executeFromState(TEnvironment env, TState state) -060 throws ProcedureYieldException, InterruptedException; -061 -062 /** -063 * called to perform the rollback of the specified state -064 * @param state state to rollback -065 * @throws IOException temporary failure, the rollback will retry later -066 */ -067 protected abstract void rollbackState(TEnvironment env, TState state) -068 throws IOException, InterruptedException; -069 -070 /** -071 * Convert an ordinal (or state id) to an Enum (or more descriptive) state object. -072 * @param stateId the ordinal() of the state enum (or state id) -073 * @return the state enum object -074 */ -075 protected abstract TState getState(int stateId); -076 -077 /** -078 * Convert the Enum (or more descriptive) state object to an ordinal (or state id). -079 * @param state the state enum object -080 * @return stateId the ordinal() of the state enum (or state id) -081 */ -082 protected abstract int getStateId(TState state); -083 -084 /** -085 * Return the initial state object that will be used for the first call to executeFromState(). -086 * @return the initial state enum object -087 */ -088 protected abstract TState getInitialState(); -089 -090 /** -091 * Set the next state for the procedure. -092 * @param state the state enum object -093 */ -094 protected void setNextState(final TState state) { -095 setNextState(getStateId(state)); -096 } -097 -098 /** -099 * By default, the executor will try ro run all the steps of the procedure start to finish. -100 * Return true to make the executor yield between execution steps to -101 * give other procedures time to run their steps. -102 * @param state the state we are going to execute next. -103 * @return Return true if the executor should yield before the execution of the specified step. -104 * Defaults to return false. -105 */ -106 protected boolean isYieldBeforeExecuteFromState(TEnvironment env, TState state) { -107 return false; -108 } -109 -110 @Override -111 protected Procedure[] execute(final TEnvironment env) -112 throws ProcedureYieldException, InterruptedException { -113 updateTimestamp(); -114 try { -115 TState state = getCurrentState(); -116 if (stateCount == 0) { -117 setNextState(getStateId(state)); -118 } -119 if (executeFromState(env, state) == Flow.NO_MORE_STATE) { -120 // completed -121 return null; -122 } -123 return (isWaiting() || isFailed()) ? null : new Procedure[] {this}; -124 } finally { -125 updateTimestamp(); -126 } -127 } -128 -129 @Override -130 protected void rollback(final TEnvironment env) -131 throws IOException, InterruptedException { -132 try { -133 updateTimestamp(); -134 rollbackState(env, getCurrentState()); -135 stateCount--; -136 } finally { -137 updateTimestamp(); -138 } -139 } -140 -141 @Override -142 protected boolean isYieldAfterExecutionStep(final TEnvironment env) { -143 return isYieldBeforeExecuteFromState(env, getCurrentState()); -144 } -145 -146 private TState getCurrentState() { -147 return stateCount > 0 ? getState(states[stateCount-1]) : getInitialState(); +024import java.util.ArrayList; +025import java.util.Arrays; +026 +027import org.apache.hadoop.hbase.classification.InterfaceAudience; +028import org.apache.hadoop.hbase.classification.InterfaceStability; +029import org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.StateMachineProcedureData; +030 +031/** +032 * Procedure described by a series of steps. +033 * +034 * The procedure implementor must have an enum of 'states', describing +035 * the various step of the procedure. +036 * Once the procedure is running, the procedure-framework will call executeFromState() +037 * using the 'state' provided by the user. The first call to executeFromState() +038 * will be performed with 'state = null'. The implementor can jump between +039 * states using setNextState(MyStateEnum.ordinal()). +040 * The rollback will call rollbackState() for each state that was executed, in reverse order. +041 */ +042@InterfaceAudience.Private +043@InterfaceStability.Evolving +044public abstract class StateMachineProcedure<TEnvironment, TState> +045 extends Procedure<TEnvironment> { +046 private int stateCount = 0; +047 private int[] states = null; +048 +049 private ArrayList<Procedure> subProcList = null; +050 +051 protected enum Flow { +052 HAS_MORE_STATE, +053 NO_MORE_STATE, +054 } +055 +056 /** +057 * called to perform a single step of the specified 'state' of the procedure +058 * @param state state to execute +059 * @return Flow.NO_MORE_STATE if the procedure is completed, +060 * Flow.HAS_MORE_STATE if there is another step. +061 */ +062 protected abstract Flow executeFromState(TEnvironment env, TState state) +063 throws ProcedureYieldException, InterruptedException; +064 +065 /** +066 * called to perform the rollback of the specified state +067 * @param state state to rollback +068 * @throws IOException temporary failure, the rollback will retry later +069 */ +070 protected abstract void rollbackState(TEnvironment env, TState state) +071 throws IOException, InterruptedException; +072 +073 /** +074 * Convert an ordinal (or state id) to an Enum (or more descriptive) state object. +075 * @param stateId the ordinal() of the state enum (or state id) +076 * @return the state enum object +077 */ +078 protected abstract TState getState(int stateId); +079 +080 /** +081 * Convert the Enum (or more descriptive) state object to an ordinal (or state id). +082 * @param state the state enum object +083 * @return stateId the ordinal() of the state enum (or state id) +084 */ +085 protected abstract int getStateId(TState state); +086 +087 /** +088 * Return the initial state object that will be used for the first call to executeFromState(). +089 * @return the initial state enum object +090 */ +091 protected abstract TState getInitialState(); +092 +093 /** +094 * Set the next state for the procedure. +095 * @param state the state enum object +096 */ +097 protected void setNextState(final TState state) { +098 setNextState(getStateId(state)); +099 } +100 +101 /** +102 * By default, the executor will try ro run all the steps of the procedure start to finish. +103 * Return true to make the executor yield between execution steps to +104 * give other procedures time to run their steps. +105 * @param state the state we are going to execute next. +106 * @return Return true if the executor should yield before the execution of the specified step. +107 * Defaults to return false. +108 */ +109 protected boolean isYieldBeforeExecuteFromState(TEnvironment env, TState state) { +110 return false; +111 } +112 +113 /** +114 * Add a child procedure to execute +115 * @param subProcedure the child procedure +116 */ +117 protected void addChildProcedure(Procedure subProcedure) { +118 if (subProcList == null) { +119 subProcList = new ArrayList<Procedure>(); +120 } +121 subProcList.add(subProcedure); +122 } +123 +124 @Override +125 protected Procedure[] execute(final TEnvironment env) +126 throws ProcedureYieldException, InterruptedException { +127 updateTimestamp(); +128 try { +129 TState state = getCurrentState(); +130 if (stateCount == 0) { +131 setNextState(getStateId(state)); +132 } +133 if (executeFromState(env, state) == Flow.NO_MORE_STATE) { +134 // completed +135 return null; +136 } +137 +138 if (subProcList != null && subProcList.size() != 0) { +139 Procedure[] subProcedures = subProcList.toArray(new Procedure[subProcList.size()]); +140 subProcList = null; +141 return subProcedures; +142 } +143 +144 return (isWaiting() || isFailed()) ? null : new Procedure[] {this}; +145 } finally { +146 updateTimestamp(); +147 } 148 } 149 -150 /** -151 * Set the next state for the procedure. -152 * @param stateId the ordinal() of the state enum (or state id) -153 */ -154 private void setNextState(final int stateId) { -155 if (states == null || states.length == stateCount) { -156 int newCapacity = stateCount + 8; -157 if (states != null) { -158 states = Arrays.copyOf(states, newCapacity); -159 } else { -160 states = new int[newCapacity]; -161 } -162 } -163 states[stateCount++] = stateId; -164 } -165 -166 @Override -167 protected void toStringState(StringBuilder builder) { -168 super.toStringState(builder); -169 if (!isFinished() && getCurrentState() != null) { -170 builder.append(":").append(getCurrentState()); -171 } -172 } -173 -174 @Override -175 protected void serializeStateData(final OutputStream stream) throws IOException { -176 StateMachineProcedureData.Builder data = StateMachineProcedureData.newBuilder(); -177 for (int i = 0; i < stateCount; ++i) { -178 data.addState(states[i]); -179 } -180 data.build().writeDelimitedTo(stream); -181 } -182 -183 @Override -184 protected void deserializeStateData(final InputStream stream) throws IOException { -185 StateMachineProcedureData data = StateMachineProcedureData.parseDelimitedFrom(stream); -186 stateCount = data.getStateCount(); -187 if (stateCount > 0) { -188 states = new int[stateCount]; -189 for (int i = 0; i < stateCount; ++i) { -190 states[i] = data.getState(i); -191 } -192 } else { -193 states = null; -194 } -195 } -196} +150 @Override +151 protected void rollback(final TEnvironment env) +152 throws IOException, InterruptedException { +153 try { +154 updateTimestamp(); +155 rollbackState(env, getCurrentState()); +156 stateCount--; +157 } finally { +158 updateTimestamp(); +159 } +160 } +161 +162 @Override +163 protected boolean isYieldAfterExecutionStep(final TEnvironment env) { +164 return isYieldBeforeExecuteFromState(env, getCurrentState()); +165 } +166 +167 private TState getCurrentState() { +168 return stateCount > 0 ? getState(states[stateCount-1]) : getInitialState(); +169 } +170 +171 /** +172 * Set the next state for the procedure. +173 * @param stateId the ordinal() of the state enum (or state id) +174 */ +175 private void setNextState(final int stateId) { +176 if (states == null || states.length == stateCount) { +177 int newCapacity = stateCount + 8; +178 if (states != null) { +179 states = Arrays.copyOf(states, newCapacity); +180 } else { +181 states = new int[newCapacity]; +182 } +183 } +184 states[stateCount++] = stateId; +185 } +186 +187 @Override +188 protected void toStringState(StringBuilder builder) { +189 super.toStringState(builder); +190 if (!isFinished() && getCurrentState() != null) { +191 builder.append(":").append(getCurrentState()); +192 } +193 } +194 +195 @Override +196 protected void serializeStateData(final OutputStream stream) throws IOException { +197 StateMachineProcedureData.Builder data = StateMachineProcedureData.newBuilder(); +198 for (int i = 0; i < stateCount; ++i) { +199 data.addState(states[i]); +200 } +201 data.build().writeDelimitedTo(stream); +202 } +203 +204 @Override +205 protected void deserializeStateData(final InputStream stream) throws IOException { +206 StateMachineProcedureData data = StateMachineProcedureData.parseDelimitedFrom(stream); +207 stateCount = data.getStateCount(); +208 if (stateCount > 0) { +209 states = new int[stateCount]; +210 for (int i = 0; i < stateCount; ++i) { +211 states[i] = data.getState(i); +212 } +213 } else { +214 states = null; +215 } +216 } +217} http://git-wip-us.apache.org/repos/asf/hbase-site/blob/4ce8323f/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AbstractMemStore.html ---------------------------------------------------------------------- diff --git a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AbstractMemStore.html b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AbstractMemStore.html index 7e80faa..c6029bd 100644 --- a/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AbstractMemStore.html +++ b/devapidocs/src-html/org/apache/hadoop/hbase/regionserver/AbstractMemStore.html @@ -234,36 +234,36 @@ 226 return getSnapshot().getSize(); 227 } 228 -229 @Override -230 public String toString() { -231 StringBuffer buf = new StringBuffer(); -232 int i = 1; -233 try { -234 for (Segment segment : getListOfSegments()) { -235 buf.append("Segment (" + i + ") " + segment.toString() + "; "); -236 i++; -237 } -238 } catch (IOException e){ -239 return e.toString(); -240 } -241 return buf.toString(); -242 } -243 -244 protected void rollbackInSnapshot(Cell cell) { -245 // If the key is in the snapshot, delete it. We should not update -246 // this.size, because that tracks the size of only the memstore and -247 // not the snapshot. The flush of this snapshot to disk has not -248 // yet started because Store.flush() waits for all rwcc transactions to -249 // commit before starting the flush to disk. -250 snapshot.rollback(cell); -251 } -252 -253 protected void rollbackInActive(Cell cell) { -254 // If the key is in the memstore, delete it. Update this.size. -255 long sz = active.rollback(cell); -256 if (sz != 0) { -257 setOldestEditTimeToNow(); -258 } +229 /** +230 * Remove n key from the memstore. Only cells that have the same key and the +231 * same memstoreTS are removed. It is ok to not update timeRangeTracker +232 * in this call. It is possible that we can optimize this method by using +233 * tailMap/iterator, but since this method is called rarely (only for +234 * error recovery), we can leave those optimization for the future. +235 * @param cell +236 */ +237 @Override +238 public void rollback(Cell cell) { +239 // If the key is in the active, delete it. Update this.size. +240 long sz = active.rollback(cell); +241 if (sz != 0) { +242 setOldestEditTimeToNow(); +243 } +244 } +245 +246 @Override +247 public String toString() { +248 StringBuffer buf = new StringBuffer(); +249 int i = 1; +250 try { +251 for (Segment segment : getListOfSegments()) { +252 buf.append("Segment (" + i + ") " + segment.toString() + "; "); +253 i++; +254 } +255 } catch (IOException e){ +256 return e.toString(); +257 } +258 return buf.toString(); 259 } 260 261 protected Configuration getConfiguration() {