@InterfaceAudience.Private public class ProcedureCoordinator extends Object
The Procedure
is generic and subclassing or customization shouldn't be
necessary -- any customization should happen just in Subprocedure
s.
Modifier and Type | Field and Description |
---|---|
(package private) static long |
KEEP_ALIVE_MILLIS_DEFAULT |
private static org.slf4j.Logger |
LOG |
private ExecutorService |
pool |
private ConcurrentMap<String,Procedure> |
procedures |
private ProcedureCoordinatorRpcs |
rpcs |
(package private) static long |
TIMEOUT_MILLIS_DEFAULT |
private long |
timeoutMillis |
(package private) static long |
WAKE_MILLIS_DEFAULT |
private long |
wakeTimeMillis |
Constructor and Description |
---|
ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs,
ThreadPoolExecutor pool)
Create and start a ProcedureCoordinator.
|
ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs,
ThreadPoolExecutor pool,
long timeoutMillis,
long wakeTimeMillis)
Create and start a ProcedureCoordinator.
|
Modifier and Type | Method and Description |
---|---|
void |
abortProcedure(String procName,
ForeignException reason)
Abort the procedure with the given name
|
void |
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 procedure
|
static ThreadPoolExecutor |
defaultPool(String coordName,
int opThreads,
long keepAliveMillis)
Default thread pool for the procedure
|
Procedure |
getProcedure(String name)
Returns the procedure.
|
Set<String> |
getProcedureNames() |
(package private) ProcedureCoordinatorRpcs |
getRpcs() |
(package private) void |
memberAcquiredBarrier(String procName,
String member)
Notification that the procedure had the specified member acquired its part of the barrier
via
Subprocedure.acquireBarrier() . |
(package private) void |
memberFinishedBarrier(String procName,
String member,
byte[] dataFromMember)
Notification that the procedure had another member finished executing its in-barrier subproc
via
Subprocedure.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.
|
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.
|
(package private) boolean |
submitProcedure(Procedure proc)
Submit an procedure to kick off its dependent subprocedures.
|
private static final org.slf4j.Logger LOG
static final long KEEP_ALIVE_MILLIS_DEFAULT
static final long TIMEOUT_MILLIS_DEFAULT
static final long WAKE_MILLIS_DEFAULT
private final ProcedureCoordinatorRpcs rpcs
private final ExecutorService pool
private final long wakeTimeMillis
private final long timeoutMillis
private final ConcurrentMap<String,Procedure> procedures
public ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs, ThreadPoolExecutor pool)
rpcs
- pool
- Used for executing procedures.public ProcedureCoordinator(ProcedureCoordinatorRpcs rpcs, ThreadPoolExecutor pool, long timeoutMillis, long wakeTimeMillis)
rpcs
- pool
- Used for executing procedures.timeoutMillis
- public static ThreadPoolExecutor defaultPool(String coordName, int opThreads)
coordName
- opThreads
- the maximum number of threads to allow in the poolpublic static ThreadPoolExecutor defaultPool(String coordName, int opThreads, long keepAliveMillis)
coordName
- opThreads
- the maximum number of threads to allow in the poolkeepAliveMillis
- the maximum time (ms) that excess idle threads will wait for new taskspublic void close() throws IOException
IOException
boolean submitProcedure(Procedure proc)
proc
- Procedure to executevoid rpcConnectionFailure(String message, IOException cause)
message
- description of the errorcause
- the actual cause of the failurepublic void abortProcedure(String procName, ForeignException reason)
procName
- name of the procedure to abortreason
- serialized information about the abortProcedure createProcedure(ForeignExceptionDispatcher fed, String procName, byte[] procArgs, List<String> expectedMembers)
procName
- procArgs
- expectedMembers
- public Procedure startProcedure(ForeignExceptionDispatcher fed, String procName, byte[] procArgs, List<String> expectedMembers)
procName
- name of the procedure to startprocArgs
- arguments for the procedureexpectedMembers
- expected members to startvoid memberAcquiredBarrier(String procName, String member)
Subprocedure.acquireBarrier()
.procName
- name of the procedure that acquiredmember
- name of the member that acquiredvoid memberFinishedBarrier(String procName, String member, byte[] dataFromMember)
Subprocedure.insideBarrier()
.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 notificationProcedureCoordinatorRpcs getRpcs()
public Procedure getProcedure(String name)
name
- Name of the procedurepublic Set<String> getProcedureNames()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.