@InterfaceAudience.Private @InterfaceStability.Evolving public abstract class Procedure<TEnvironment> extends Object implements Comparable<Procedure>
Constructor and Description |
---|
Procedure() |
Modifier and Type | Method and Description |
---|---|
protected abstract boolean |
abort(TEnvironment env)
The abort() call is asynchronous and each procedure must decide how to deal
with that, if they want to be abortable.
|
protected boolean |
acquireLock(TEnvironment env)
The user should override this method, and try to take a lock if necessary.
|
protected void |
addStackIndex(int index)
Called by the RootProcedureState on procedure execution.
|
protected void |
beforeReplay(TEnvironment env)
Called when the procedure is loaded for replay.
|
protected boolean |
childrenCountDown()
Called by the ProcedureExecutor to notify that one of the sub-procedures
has completed.
|
int |
compareTo(Procedure other) |
protected void |
completionCleanup(TEnvironment env)
Called when the procedure is marked as completed (success or rollback).
|
static org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.Procedure |
convert(Procedure proc)
Helper to convert the procedure to protobuf.
|
static Procedure |
convert(org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.Procedure proto)
Helper to convert the protobuf procedure.
|
static ProcedureInfo |
createProcedureInfo(Procedure proc,
NonceKey nonceKey)
Helper to create the ProcedureInfo from Procedure.
|
protected abstract void |
deserializeStateData(InputStream stream)
Called on store load to allow the user to decode the previously serialized
state.
|
protected Procedure[] |
doExecute(TEnvironment env)
Internal method called by the ProcedureExecutor that starts the
user-level code execute().
|
protected void |
doRollback(TEnvironment env)
Internal method called by the ProcedureExecutor that starts the
user-level code rollback().
|
long |
elapsedTime() |
protected abstract Procedure[] |
execute(TEnvironment env)
The main code of the procedure.
|
RemoteProcedureException |
getException() |
long |
getLastUpdate() |
NonceKey |
getNonceKey() |
String |
getOwner() |
long |
getParentProcId() |
long |
getProcId() |
static long |
getProcIdHashCode(long procId)
Get an hashcode for the specified Procedure ID
|
byte[] |
getResult() |
protected static Long |
getRootProcedureId(Map<Long,Procedure> procedures,
Procedure proc) |
protected int[] |
getStackIndexes() |
long |
getStartTime() |
protected org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.ProcedureState |
getState() |
int |
getTimeout() |
long |
getTimeRemaining() |
protected boolean |
hasChildren() |
boolean |
hasException() |
boolean |
hasOwner() |
boolean |
hasParent() |
boolean |
hasTimeout() |
protected void |
incChildrenLatch()
Called by the ProcedureExecutor on procedure-load to restore the latch state
|
boolean |
isFailed() |
boolean |
isFinished() |
protected boolean |
isRunnable() |
boolean |
isSuccess() |
boolean |
isWaiting() |
protected boolean |
isYieldAfterExecutionStep(TEnvironment env)
By default, the executor will try ro run procedures start to finish.
|
protected static Procedure |
newInstance(String className) |
protected void |
releaseLock(TEnvironment env)
The user should override this method, and release lock if necessary.
|
protected boolean |
removeStackIndex() |
protected abstract void |
rollback(TEnvironment env)
The code to undo what done by the execute() code.
|
protected abstract void |
serializeStateData(OutputStream stream)
The user-level code of the procedure may have some state to
persist (e.g.
|
protected void |
setAbortFailure(String source,
String msg) |
protected void |
setChildrenLatch(int numChildren)
Called by the ProcedureExecutor on procedure-load to restore the latch state
|
protected void |
setFailure(RemoteProcedureException exception) |
protected void |
setFailure(String source,
Throwable cause) |
protected void |
setNonceKey(NonceKey nonceKey)
Called by the ProcedureExecutor to set the value to the newly created procedure.
|
void |
setOwner(String owner) |
protected void |
setParentProcId(long parentProcId)
Called by the ProcedureExecutor to assign the parent to the newly created procedure.
|
protected void |
setProcId(long procId)
Called by the ProcedureExecutor to assign the ID to the newly created procedure.
|
protected void |
setResult(byte[] result)
The procedure may leave a "result" on completion.
|
protected void |
setStackIndexes(List<Integer> stackIndexes)
Called on store load to initialize the Procedure internals after
the creation/deserialization.
|
protected void |
setStartTime(long startTime)
Called on store load to initialize the Procedure internals after
the creation/deserialization.
|
protected void |
setState(org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.ProcedureState state) |
protected void |
setTimeout(int timeout) |
protected boolean |
setTimeoutFailure() |
protected boolean |
shouldWaitClientAck(TEnvironment env)
By default, the executor will keep the procedure result around util
the eviction TTL is expired.
|
String |
toString() |
protected String |
toStringClass() |
protected void |
toStringClassDetails(StringBuilder builder)
Extend the toString() information with the procedure details
e.g.
|
String |
toStringDetails()
Extend the toString() information with more procedure
details
|
protected StringBuilder |
toStringSimpleSB()
Build the StringBuilder for the simple form of
procedure string.
|
protected void |
toStringState(StringBuilder builder)
Called from
toString() when interpolating Procedure state |
protected void |
updateTimestamp() |
protected static void |
validateClass(Procedure proc) |
protected boolean |
wasExecuted() |
protected abstract Procedure[] execute(TEnvironment env) throws ProcedureYieldException, InterruptedException
env
- the environment passed to the ProcedureExecutorProcedureYieldException
- the procedure will be added back to the queue and retried laterInterruptedException
- the procedure will be added back to the queue and retried laterprotected abstract void rollback(TEnvironment env) throws IOException, InterruptedException
env
- the environment passed to the ProcedureExecutorIOException
- temporary failure, the rollback will retry laterInterruptedException
- the procedure will be added back to the queue and retried laterprotected abstract boolean abort(TEnvironment env)
protected abstract void serializeStateData(OutputStream stream) throws IOException
stream
- the stream that will contain the user serialized dataIOException
protected abstract void deserializeStateData(InputStream stream) throws IOException
stream
- the stream that contains the user serialized dataIOException
protected boolean acquireLock(TEnvironment env)
protected void releaseLock(TEnvironment env)
protected void beforeReplay(TEnvironment env)
protected void completionCleanup(TEnvironment env)
protected boolean isYieldAfterExecutionStep(TEnvironment env)
env
- the environment passed to the ProcedureExecutorprotected boolean shouldWaitClientAck(TEnvironment env)
env
- the environment passed to the ProcedureExecutorprotected StringBuilder toStringSimpleSB()
public String toStringDetails()
protected String toStringClass()
protected void toStringState(StringBuilder builder)
toString()
when interpolating Procedure
statebuilder
- Append current ProcedureProtos.ProcedureState
protected void toStringClassDetails(StringBuilder builder)
builder
- the string builder to use to append the proc specific informationpublic byte[] getResult()
protected void setResult(byte[] result)
result
- the serialized result that will be passed to the clientpublic long getProcId()
public boolean hasParent()
public boolean hasException()
public boolean hasTimeout()
public long getParentProcId()
public NonceKey getNonceKey()
protected boolean isRunnable()
public boolean isFailed()
public boolean isSuccess()
public boolean isFinished()
public boolean isWaiting()
public RemoteProcedureException getException()
public long getStartTime()
public long getLastUpdate()
public long elapsedTime()
protected void setTimeout(int timeout)
timeout
- timeout in msecpublic int getTimeout()
public long getTimeRemaining()
@InterfaceAudience.Private public void setOwner(String owner)
public String getOwner()
public boolean hasOwner()
@InterfaceAudience.Private protected void setState(org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.ProcedureState state)
@InterfaceAudience.Private protected org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.ProcedureState getState()
protected void setFailure(RemoteProcedureException exception)
@InterfaceAudience.Private protected boolean setTimeoutFailure()
@InterfaceAudience.Private protected void setProcId(long procId)
@InterfaceAudience.Private protected void setParentProcId(long parentProcId)
@InterfaceAudience.Private protected void setNonceKey(NonceKey nonceKey)
@InterfaceAudience.Private protected Procedure[] doExecute(TEnvironment env) throws ProcedureYieldException, InterruptedException
@InterfaceAudience.Private protected void doRollback(TEnvironment env) throws IOException, InterruptedException
IOException
InterruptedException
@InterfaceAudience.Private protected void setStartTime(long startTime)
protected void updateTimestamp()
@InterfaceAudience.Private protected void setChildrenLatch(int numChildren)
@InterfaceAudience.Private protected void incChildrenLatch()
@InterfaceAudience.Private protected boolean childrenCountDown()
@InterfaceAudience.Private protected boolean hasChildren()
@InterfaceAudience.Private protected void addStackIndex(int index)
@InterfaceAudience.Private protected boolean removeStackIndex()
@InterfaceAudience.Private protected void setStackIndexes(List<Integer> stackIndexes)
@InterfaceAudience.Private protected boolean wasExecuted()
@InterfaceAudience.Private protected int[] getStackIndexes()
public int compareTo(Procedure other)
compareTo
in interface Comparable<Procedure>
public static long getProcIdHashCode(long procId)
@InterfaceAudience.Private protected static Long getRootProcedureId(Map<Long,Procedure> procedures, Procedure proc)
protected static Procedure newInstance(String className) throws IOException
IOException
protected static void validateClass(Procedure proc) throws IOException
IOException
@InterfaceAudience.Private public static ProcedureInfo createProcedureInfo(Procedure proc, NonceKey nonceKey)
@InterfaceAudience.Private public static org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.Procedure convert(Procedure proc) throws IOException
IOException
@InterfaceAudience.Private public static Procedure convert(org.apache.hadoop.hbase.protobuf.generated.ProcedureProtos.Procedure proto) throws IOException
IOException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.