@InterfaceAudience.Private @InterfaceStability.Evolving class AsyncProcess extends Object
The caller sends a buffer of operation, by calling submit. This class extract from this list the operations it can send, i.e. the operations that are on region that are not considered as busy. The process is asynchronous, i.e. it returns immediately when if has finished to iterate on the list. If, and only if, the maximum number of current task is reached, the call to submit will block. Alternatively, the caller can call submitAll, in which case all the operations will be sent. Each call to submit returns a future-like object that can be used to track operation progress.
The class manages internally the retries.
The errors are tracked inside the Future object that is returned. The results are always tracked inside the Future object and can be retrieved when the call has finished. Partial results can also be retrieved if some part of multi-request failed.
This class is thread safe. Internally, the class is thread safe enough to manage simultaneously new submission and results arising from older operations.
Internally, this class works with Row
, this mean it could be theoretically used for
gets as well.
Modifier and Type | Field and Description |
---|---|
(package private) ClusterConnection |
connection |
private static AtomicLong |
COUNTER |
private static int |
DEFAULT_LOG_DETAILS_PERIOD |
static int |
DEFAULT_START_LOG_ERRORS_AFTER_COUNT |
(package private) long |
id |
private static org.slf4j.Logger |
LOG |
static String |
LOG_DETAILS_FOR_BATCH_ERROR
Configuration to decide whether to log details for batch error
|
static String |
LOG_DETAILS_PERIOD |
(package private) boolean |
logBatchErrorDetails
Whether to log details for batch errors
|
private static AsyncRequestFuture |
NO_REQS_RESULT
Return value from a submit that didn't contain any requests.
|
(package private) int |
numTries |
(package private) long |
pause |
(package private) long |
pauseForCQTBE |
private int |
periodToLog |
static String |
PRIMARY_CALL_TIMEOUT_KEY |
(package private) long |
primaryCallTimeoutMicroseconds |
(package private) RequestController |
requestController
The traffic control for requests.
|
private RpcRetryingCallerFactory |
rpcCallerFactory |
(package private) RpcControllerFactory |
rpcFactory |
(package private) long |
serverTrackerTimeout |
static String |
START_LOG_ERRORS_AFTER_COUNT_KEY
Configure the number of failures after which the client will start logging.
|
(package private) int |
startLogErrorsCnt |
Constructor and Description |
---|
AsyncProcess(ClusterConnection hc,
org.apache.hadoop.conf.Configuration conf,
RpcRetryingCallerFactory rpcCaller,
RpcControllerFactory rpcFactory) |
Modifier and Type | Method and Description |
---|---|
(package private) static void |
addAction(ServerName server,
byte[] regionName,
Action action,
Map<ServerName,MultiAction> actionsByServer,
long nonceGroup)
Helper that is used when grouping the actions per region server.
|
private int |
checkOperationTimeout(int operationTimeout) |
private int |
checkRpcTimeout(int rpcTimeout) |
private <CResult> AsyncRequestFuture |
checkTask(AsyncProcessTask<CResult> task) |
private int |
checkTimeout(String name,
int timeout) |
(package private) <CResult> AsyncRequestFutureImpl<CResult> |
createAsyncRequestFuture(AsyncProcessTask task,
List<Action> actions,
long nonceGroup) |
protected RpcRetryingCaller<AbstractResponse> |
createCaller(CancellableRegionServerCallable callable,
int rpcTimeout)
Create a caller.
|
(package private) ConnectionImplementation.ServerErrorTracker |
createServerErrorTracker()
Creates the server error tracker to use inside process.
|
(package private) void |
decTaskCounters(Collection<byte[]> regions,
ServerName sn) |
private Consumer<Long> |
getLogger(TableName tableName,
long max) |
(package private) void |
incTaskCounters(Collection<byte[]> regions,
ServerName sn) |
(package private) static boolean |
isReplicaGet(Row row) |
private void |
setNonce(NonceGenerator ng,
Row r,
Action action) |
<CResult> AsyncRequestFuture |
submit(AsyncProcessTask<CResult> task)
The submitted task may be not accomplished at all if there are too many running tasks or
other limits.
|
private <CResult> AsyncRequestFuture |
submit(AsyncProcessTask<CResult> task,
boolean atLeastOne)
Extract from the rows list what we can submit.
|
private <CResult> AsyncRequestFuture |
submitAll(AsyncProcessTask task)
Submit immediately the list of rows, whatever the server status.
|
(package private) <CResult> AsyncRequestFuture |
submitMultiActions(AsyncProcessTask task,
List<Action> retainedActions,
long nonceGroup,
List<Exception> locationErrors,
List<Integer> locationErrorRows,
Map<ServerName,MultiAction> actionsByServer) |
protected void |
waitForMaximumCurrentTasks(int max,
TableName tableName)
Wait until the async does not have more than max tasks in progress.
|
private static final org.slf4j.Logger LOG
private static final AtomicLong COUNTER
public static final String PRIMARY_CALL_TIMEOUT_KEY
public static final String START_LOG_ERRORS_AFTER_COUNT_KEY
public static final int DEFAULT_START_LOG_ERRORS_AFTER_COUNT
public static final String LOG_DETAILS_FOR_BATCH_ERROR
private static final AsyncRequestFuture NO_REQS_RESULT
final long id
final ClusterConnection connection
private final RpcRetryingCallerFactory rpcCallerFactory
final RpcControllerFactory rpcFactory
final int startLogErrorsCnt
final long pause
final long pauseForCQTBE
final int numTries
long serverTrackerTimeout
final long primaryCallTimeoutMicroseconds
final boolean logBatchErrorDetails
final RequestController requestController
public static final String LOG_DETAILS_PERIOD
private static final int DEFAULT_LOG_DETAILS_PERIOD
private final int periodToLog
AsyncProcess(ClusterConnection hc, org.apache.hadoop.conf.Configuration conf, RpcRetryingCallerFactory rpcCaller, RpcControllerFactory rpcFactory)
public <CResult> AsyncRequestFuture submit(AsyncProcessTask<CResult> task) throws InterruptedIOException
CResult
- The class to cast the resulttask
- The setting and dataInterruptedIOException
private <CResult> AsyncRequestFuture submit(AsyncProcessTask<CResult> task, boolean atLeastOne) throws InterruptedIOException
task
- The setting and dataatLeastOne
- true if we should submit at least a subset.InterruptedIOException
<CResult> AsyncRequestFuture submitMultiActions(AsyncProcessTask task, List<Action> retainedActions, long nonceGroup, List<Exception> locationErrors, List<Integer> locationErrorRows, Map<ServerName,MultiAction> actionsByServer)
static void addAction(ServerName server, byte[] regionName, Action action, Map<ServerName,MultiAction> actionsByServer, long nonceGroup)
server
- - serverregionName
- - regionNameaction
- - the action to add to the multiactionactionsByServer
- the multiaction per servernonceGroup
- Nonce group.private <CResult> AsyncRequestFuture submitAll(AsyncProcessTask task)
task
- The setting and dataprivate <CResult> AsyncRequestFuture checkTask(AsyncProcessTask<CResult> task)
private void setNonce(NonceGenerator ng, Row r, Action action)
private int checkTimeout(String name, int timeout)
private int checkOperationTimeout(int operationTimeout)
private int checkRpcTimeout(int rpcTimeout)
<CResult> AsyncRequestFutureImpl<CResult> createAsyncRequestFuture(AsyncProcessTask task, List<Action> actions, long nonceGroup)
protected void waitForMaximumCurrentTasks(int max, TableName tableName) throws InterruptedIOException
InterruptedIOException
void incTaskCounters(Collection<byte[]> regions, ServerName sn)
void decTaskCounters(Collection<byte[]> regions, ServerName sn)
protected RpcRetryingCaller<AbstractResponse> createCaller(CancellableRegionServerCallable callable, int rpcTimeout)
ConnectionImplementation.ServerErrorTracker createServerErrorTracker()
static boolean isReplicaGet(Row row)
Copyright © 2007–2020 The Apache Software Foundation. All rights reserved.