Class ProcedureCoordinator
java.lang.Object
org.apache.hadoop.hbase.procedure.ProcedureCoordinator
This is the master side of a distributed complex procedure execution.
The Procedure
is generic and subclassing or customization shouldn't be necessary -- any
customization should happen just in Subprocedure
s.
-
Field Summary
Modifier and TypeFieldDescription(package private) static final long
private static final org.slf4j.Logger
private final ExecutorService
private final ConcurrentMap<String,
Procedure> private final ProcedureCoordinatorRpcs
(package private) static final long
private final long
(package private) static final long
private final long
-
Constructor Summary
ConstructorDescriptionCreate and start a ProcedureCoordinator.ProcedureCoordinator
(ProcedureCoordinatorRpcs rpcs, ThreadPoolExecutor pool, long timeoutMillis, long wakeTimeMillis) Create and start a ProcedureCoordinator. -
Method Summary
Modifier and TypeMethodDescriptionvoid
abortProcedure
(String procName, ForeignException reason) Abort the procedure with the given namevoid
close()
Shutdown the thread pools and release rpc resources(package private) Procedure
createProcedure
(ForeignExceptionDispatcher fed, String procName, byte[] procArgs, List<String> expectedMembers) Exposed for hooking with unit tests.static ThreadPoolExecutor
defaultPool
(String coordName, int opThreads) Default thread pool for the procedurestatic ThreadPoolExecutor
defaultPool
(String coordName, int opThreads, long keepAliveMillis) Default thread pool for the proceduregetProcedure
(String name) Returns the procedure.Returns Return set of all procedure names.(package private) ProcedureCoordinatorRpcs
getRpcs()
Returns the rpcs implementation for all current procedures(package private) void
memberAcquiredBarrier
(String procName, String member) Notification that the procedure had the specified member acquired its part of the barrier viaSubprocedure.acquireBarrier()
.(package private) void
memberFinishedBarrier
(String procName, String member, byte[] dataFromMember) Notification that the procedure had another member finished executing its in-barrier subproc viaSubprocedure.insideBarrier()
.(package private) void
rpcConnectionFailure
(String message, IOException cause) The connection to the rest of the procedure group (members and coordinator) has been broken/lost/failed.startProcedure
(ForeignExceptionDispatcher fed, String procName, byte[] procArgs, List<String> expectedMembers) Kick off the named procedure Currently only one procedure with the same type and name is allowed to run at a time.(package private) boolean
submitProcedure
(Procedure proc) Submit an procedure to kick off its dependent subprocedures.
-
Field Details
-
LOG
-
KEEP_ALIVE_MILLIS_DEFAULT
- See Also:
-
TIMEOUT_MILLIS_DEFAULT
- See Also:
-
WAKE_MILLIS_DEFAULT
- See Also:
-
rpcs
-
pool
-
wakeTimeMillis
-
timeoutMillis
-
procedures
-
-
Constructor Details
-
ProcedureCoordinator
Create and start a ProcedureCoordinator. The rpc object registers the ProcedureCoordinator and starts any threads in this constructor.- Parameters:
pool
- Used for executing procedures.
-
ProcedureCoordinator
public ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs, ThreadPoolExecutor pool, long timeoutMillis, long wakeTimeMillis) Create and start a ProcedureCoordinator. The rpc object registers the ProcedureCoordinator and starts any threads in this constructor.- Parameters:
pool
- Used for executing procedures.
-
-
Method Details
-
defaultPool
Default thread pool for the procedure- Parameters:
opThreads
- the maximum number of threads to allow in the pool
-
defaultPool
Default thread pool for the procedure- Parameters:
opThreads
- the maximum number of threads to allow in the poolkeepAliveMillis
- the maximum time (ms) that excess idle threads will wait for new tasks
-
close
Shutdown the thread pools and release rpc resources- Throws:
IOException
-
submitProcedure
Submit an procedure to kick off its dependent subprocedures.- Parameters:
proc
- Procedure to execute- Returns:
- true if the procedure was started correctly, false if the procedure or any subprocedures could not be started. Failure could be due to submitting a procedure multiple times (or one with the same name), or some sort of IO problem. On errors, the procedure's monitor holds a reference to the exception that caused the failure.
-
rpcConnectionFailure
The connection to the rest of the procedure group (members and coordinator) has been broken/lost/failed. This should fail any interested procedures, but not attempt to notify other members since we cannot reach them anymore.- Parameters:
message
- description of the errorcause
- the actual cause of the failure
-
abortProcedure
Abort the procedure with the given name- Parameters:
procName
- name of the procedure to abortreason
- serialized information about the abort
-
createProcedure
Procedure createProcedure(ForeignExceptionDispatcher fed, String procName, byte[] procArgs, List<String> expectedMembers) Exposed for hooking with unit tests.- Returns:
- the newly created procedure
-
startProcedure
public Procedure startProcedure(ForeignExceptionDispatcher fed, String procName, byte[] procArgs, List<String> expectedMembers) Kick off the named procedure Currently only one procedure with the same type and name is allowed to run at a time.- Parameters:
procName
- name of the procedure to startprocArgs
- arguments for the procedureexpectedMembers
- expected members to start- Returns:
- handle to the running procedure, if it was started correctly, null otherwise. Null could be due to submitting a procedure multiple times (or one with the same name), or runtime exception. Check the procedure's monitor that holds a reference to the exception that caused the failure.
-
memberAcquiredBarrier
Notification that the procedure had the specified member acquired its part of the barrier viaSubprocedure.acquireBarrier()
.- Parameters:
procName
- name of the procedure that acquiredmember
- name of the member that acquired
-
memberFinishedBarrier
Notification that the procedure had another member finished executing its in-barrier subproc viaSubprocedure.insideBarrier()
.- Parameters:
procName
- name of the subprocedure that finishedmember
- name of the member that executed and released its barrierdataFromMember
- the data that the member returned along with the notification
-
getRpcs
Returns the rpcs implementation for all current procedures -
getProcedure
Returns the procedure. This Procedure is a live instance so should not be modified but can be inspected.- Parameters:
name
- Name of the procedure- Returns:
- Procedure or null if not present any more
-
getProcedureNames
Returns Return set of all procedure names.
-