@InterfaceAudience.Private class AsyncRequestFutureImpl<CResult> extends Object implements AsyncRequestFuture
Modifier and Type | Class and Description |
---|---|
private class |
AsyncRequestFutureImpl.ReplicaCallIssuingRunnable
Runnable (that can be submitted to thread pool) that waits for when it's time
to issue replica calls, finds region replicas, groups the requests by replica and
issues the calls (on separate threads, via sendMultiAction).
|
private static class |
AsyncRequestFutureImpl.ReplicaResultState
Sync point for calls to multiple replicas for the same user request (Get).
|
static class |
AsyncRequestFutureImpl.Retry
|
(package private) class |
AsyncRequestFutureImpl.SingleServerRequestRunnable
Runnable (that can be submitted to thread pool) that submits MultiAction to a
single server.
|
Modifier and Type | Field and Description |
---|---|
private AtomicLong |
actionsInProgress |
private AsyncProcess |
asyncProcess |
private Batch.Callback<CResult> |
callback |
private Set<CancellableRegionServerCallable> |
callsInProgress |
private CancellableRegionServerCallable |
currentCallable |
private BatchErrors |
errors |
private ConnectionImplementation.ServerErrorTracker |
errorsByServer |
private boolean |
hasAnyReplicaGets |
private static org.slf4j.Logger |
LOG |
private long |
nonceGroup |
private int |
operationTimeout |
private ExecutorService |
pool |
private int[] |
replicaGetIndices
Indices of replica gets in results.
|
private Object |
replicaResultLock
The lock controls access to results.
|
private Object[] |
results
Result array.
|
private int |
rpcTimeout |
private TableName |
tableName |
private RetryingTimeTracker |
tracker |
Constructor and Description |
---|
AsyncRequestFutureImpl(AsyncProcessTask task,
List<Action> actions,
long nonceGroup,
AsyncProcess asyncProcess) |
Modifier and Type | Method and Description |
---|---|
private String |
buildDetailedErrorMsg(String string,
int index) |
private void |
cleanServerCache(ServerName server,
Throwable regionException) |
private MultiServerCallable |
createCallable(ServerName server,
TableName tableName,
MultiAction multi)
Create a callable.
|
private String |
createLog(int numAttempt,
int failureCount,
int replaySize,
ServerName sn,
Throwable error,
long backOffTime,
boolean willRetry,
String startTime,
int failed,
int stopped) |
private ConnectionImplementation.ServerErrorTracker |
createServerErrorTracker()
Creates the server error tracker to use inside process.
|
(package private) AsyncRequestFutureImpl.SingleServerRequestRunnable |
createSingleServerRequest(MultiAction multiAction,
int numAttempt,
ServerName server,
Set<CancellableRegionServerCallable> callsInProgress) |
private void |
decActionCounter(int index) |
private RegionLocations |
findAllLocationsOrFail(Action action,
boolean useCache) |
private Long |
getBackoff(ServerName server,
byte[] regionName) |
protected Set<CancellableRegionServerCallable> |
getCallsInProgress() |
RetriesExhaustedWithDetailsException |
getErrors() |
List<? extends Row> |
getFailedOperations() |
private Collection<? extends Runnable> |
getNewMultiActionRunnable(ServerName server,
MultiAction multiAction,
int numAttempt) |
(package private) long |
getNumberOfActionsInProgress() |
private HRegionLocation |
getReplicaLocationOrFail(Action action) |
Object[] |
getResults() |
(package private) void |
groupAndSendMultiAction(List<Action> currentActions,
int numAttempt)
Group a list of actions per region servers, and send them.
|
boolean |
hasError() |
private void |
invokeCallBack(byte[] regionName,
byte[] row,
CResult result) |
private boolean |
isActionComplete(int index,
Row row)
Checks if the action is complete; used on error to prevent needless retries.
|
private void |
logNoResubmit(ServerName oldServer,
int numAttempt,
int failureCount,
Throwable throwable,
int failed,
int stopped) |
(package private) AsyncRequestFutureImpl.Retry |
manageError(int originalIndex,
Row row,
AsyncRequestFutureImpl.Retry canRetry,
Throwable throwable,
ServerName server)
Check that we can retry acts accordingly: logs, set the error status.
|
private void |
manageLocationError(Action action,
Exception ex) |
private void |
receiveGlobalFailure(MultiAction rsActions,
ServerName server,
int numAttempt,
Throwable t)
Resubmit all the actions from this multiaction after a failure.
|
private void |
receiveMultiAction(MultiAction multiAction,
ServerName server,
MultiResponse responses,
int numAttempt)
Called when we receive the result of a server query.
|
private void |
resubmit(ServerName oldServer,
List<Action> toReplay,
int numAttempt,
int failureCount,
Throwable throwable)
Log as much info as possible, and, if there is something to replay,
submit it again after a back off sleep.
|
(package private) void |
sendMultiAction(Map<ServerName,MultiAction> actionsByServer,
int numAttempt,
List<Action> actionsForReplicaThread,
boolean reuseThread)
Send a multi action structure to the servers, after a delay depending on the attempt
number.
|
private void |
setError(int index,
Row row,
Throwable throwable,
ServerName server)
Sets the error from a particular action.
|
private void |
setResult(Action action,
Object result)
Sets the non-error result from a particular action.
|
private void |
startWaitingForReplicaCalls(List<Action> actionsForReplicaThread)
Starts waiting to issue replica calls on a different thread; or issues them immediately.
|
private AsyncRequestFutureImpl.ReplicaResultState |
trySetResultSimple(int index,
Row row,
boolean isError,
Object result,
ServerName server,
boolean isFromReplica)
Tries to set the result or error for a particular action as if there were no replica calls.
|
private void |
updateCachedLocations(ServerName server,
byte[] regionName,
byte[] row,
Throwable rowException) |
private void |
updateResult(int index,
Object result) |
protected void |
updateStats(ServerName server,
Map<byte[],MultiResponse.RegionResult> results) |
void |
waitUntilDone()
Wait until all tasks are executed, successfully or not.
|
private boolean |
waitUntilDone(long cutoff) |
private static final org.slf4j.Logger LOG
private RetryingTimeTracker tracker
private final Batch.Callback<CResult> callback
private final BatchErrors errors
private final ConnectionImplementation.ServerErrorTracker errorsByServer
private final ExecutorService pool
private final Set<CancellableRegionServerCallable> callsInProgress
private final AtomicLong actionsInProgress
private final Object replicaResultLock
private final Object[] results
private final int[] replicaGetIndices
private final boolean hasAnyReplicaGets
private final long nonceGroup
private final CancellableRegionServerCallable currentCallable
private final int operationTimeout
private final int rpcTimeout
private final AsyncProcess asyncProcess
public AsyncRequestFutureImpl(AsyncProcessTask task, List<Action> actions, long nonceGroup, AsyncProcess asyncProcess)
protected Set<CancellableRegionServerCallable> getCallsInProgress()
AsyncRequestFutureImpl.SingleServerRequestRunnable createSingleServerRequest(MultiAction multiAction, int numAttempt, ServerName server, Set<CancellableRegionServerCallable> callsInProgress)
void groupAndSendMultiAction(List<Action> currentActions, int numAttempt)
currentActions
- - the list of row to submitnumAttempt
- - the current numAttempt (first attempt is 1)private HRegionLocation getReplicaLocationOrFail(Action action)
private void manageLocationError(Action action, Exception ex)
private RegionLocations findAllLocationsOrFail(Action action, boolean useCache)
void sendMultiAction(Map<ServerName,MultiAction> actionsByServer, int numAttempt, List<Action> actionsForReplicaThread, boolean reuseThread)
actionsByServer
- the actions structured by regionsnumAttempt
- the attempt number.actionsForReplicaThread
- original actions for replica thread; null on non-first call.private Collection<? extends Runnable> getNewMultiActionRunnable(ServerName server, MultiAction multiAction, int numAttempt)
private Long getBackoff(ServerName server, byte[] regionName)
server
- server location where the target region is hostedregionName
- name of the region which we are going to write some dataprivate void startWaitingForReplicaCalls(List<Action> actionsForReplicaThread)
AsyncRequestFutureImpl.Retry manageError(int originalIndex, Row row, AsyncRequestFutureImpl.Retry canRetry, Throwable throwable, ServerName server)
originalIndex
- the position in the list sentrow
- the rowcanRetry
- if false, we won't retry whatever the settings.throwable
- the throwable, if any (can be null)server
- the location, if any (can be null)private void receiveGlobalFailure(MultiAction rsActions, ServerName server, int numAttempt, Throwable t)
rsActions
- the actions still to do from the initial listserver
- the destinationnumAttempt
- the number of attempts so fart
- the throwable (if any) that caused the resubmitprivate void resubmit(ServerName oldServer, List<Action> toReplay, int numAttempt, int failureCount, Throwable throwable)
private void logNoResubmit(ServerName oldServer, int numAttempt, int failureCount, Throwable throwable, int failed, int stopped)
private void receiveMultiAction(MultiAction multiAction, ServerName server, MultiResponse responses, int numAttempt)
multiAction
- - the multiAction we sentserver
- - the location. It's used as a server name.responses
- - the response, if anynumAttempt
- - the attemptprivate void updateCachedLocations(ServerName server, byte[] regionName, byte[] row, Throwable rowException)
private void invokeCallBack(byte[] regionName, byte[] row, CResult result)
private void cleanServerCache(ServerName server, Throwable regionException)
protected void updateStats(ServerName server, Map<byte[],MultiResponse.RegionResult> results)
private String createLog(int numAttempt, int failureCount, int replaySize, ServerName sn, Throwable error, long backOffTime, boolean willRetry, String startTime, int failed, int stopped)
private void setResult(Action action, Object result)
action
- Action (request) that the server responded to.result
- The result.private void setError(int index, Row row, Throwable throwable, ServerName server)
index
- Original action index.row
- Original request.throwable
- The resulting error.server
- The source server.private boolean isActionComplete(int index, Row row)
index
- Original action index.row
- Original request.private AsyncRequestFutureImpl.ReplicaResultState trySetResultSimple(int index, Row row, boolean isError, Object result, ServerName server, boolean isFromReplica)
private void decActionCounter(int index)
private String buildDetailedErrorMsg(String string, int index)
public void waitUntilDone() throws InterruptedIOException
AsyncRequestFuture
waitUntilDone
in interface AsyncRequestFuture
InterruptedIOException
private boolean waitUntilDone(long cutoff) throws InterruptedException
InterruptedException
public boolean hasError()
hasError
in interface AsyncRequestFuture
public List<? extends Row> getFailedOperations()
getFailedOperations
in interface AsyncRequestFuture
public RetriesExhaustedWithDetailsException getErrors()
getErrors
in interface AsyncRequestFuture
public Object[] getResults() throws InterruptedIOException
getResults
in interface AsyncRequestFuture
InterruptedIOException
private ConnectionImplementation.ServerErrorTracker createServerErrorTracker()
private MultiServerCallable createCallable(ServerName server, TableName tableName, MultiAction multi)
private void updateResult(int index, Object result)
long getNumberOfActionsInProgress()
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.