protected class AsyncProcess.AsyncRequestFutureImpl<CResult> extends Object implements AsyncProcess.AsyncRequestFuture
Modifier and Type | Class and Description |
---|---|
private class |
AsyncProcess.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 class |
AsyncProcess.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 Batch.Callback<CResult> |
callback |
private Set<MultiServerCallable<Row>> |
callsInProgress |
private AsyncProcess.BatchErrors |
errors |
private ConnectionManager.ServerErrorTracker |
errorsByServer |
private boolean |
hasAnyReplicaGets |
private long |
nonceGroup |
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 TableName |
tableName |
Constructor and Description |
---|
AsyncProcess.AsyncRequestFutureImpl(TableName tableName,
List<Action<Row>> actions,
long nonceGroup,
ExecutorService pool,
boolean needResults,
Object[] results,
Batch.Callback<CResult> callback) |
Modifier and Type | Method and Description |
---|---|
private String |
buildDetailedErrorMsg(String string,
int index) |
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 |
decActionCounter(int index) |
private RegionLocations |
findAllLocationsOrFail(Action<Row> action,
boolean useCache) |
(package private) long |
getActionsInProgress() |
private Long |
getBackoff(ServerName server,
byte[] regionName) |
Set<MultiServerCallable<Row>> |
getCallsInProgress() |
RetriesExhaustedWithDetailsException |
getErrors() |
List<? extends Row> |
getFailedOperations() |
private Collection<? extends Runnable> |
getNewMultiActionRunnable(ServerName server,
MultiAction<Row> multiAction,
int numAttempt) |
private HRegionLocation |
getReplicaLocationOrFail(Action<Row> action) |
Object[] |
getResults() |
private void |
groupAndSendMultiAction(List<Action<Row>> currentActions,
int numAttempt)
Group a list of actions per region servers, and send them.
|
boolean |
hasError() |
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) |
AsyncProcess.Retry |
manageError(int originalIndex,
Row row,
AsyncProcess.Retry canRetry,
Throwable throwable,
ServerName server)
Check that we can retry acts accordingly: logs, set the error status.
|
private void |
manageLocationError(Action<Row> action,
Exception ex) |
private void |
receiveGlobalFailure(MultiAction<Row> rsActions,
ServerName server,
int numAttempt,
Throwable t)
Resubmit all the actions from this multiaction after a failure.
|
private void |
receiveMultiAction(MultiAction<Row> multiAction,
ServerName server,
MultiResponse responses,
int numAttempt)
Called when we receive the result of a server query.
|
private void |
resubmit(ServerName oldServer,
List<Action<Row>> 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.
|
private void |
sendMultiAction(Map<ServerName,MultiAction<Row>> actionsByServer,
int numAttempt,
List<Action<Row>> 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<Row> action,
Object result)
Sets the non-error result from a particular action.
|
private void |
startWaitingForReplicaCalls(List<Action<Row>> actionsForReplicaThread)
Starts waiting to issue replica calls on a different thread; or issues them immediately.
|
private AsyncProcess.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.
|
void |
waitUntilDone()
Wait until all tasks are executed, successfully or not.
|
private boolean |
waitUntilDone(long cutoff) |
private final Batch.Callback<CResult> callback
private final AsyncProcess.BatchErrors errors
private final ConnectionManager.ServerErrorTracker errorsByServer
private final ExecutorService pool
private final Set<MultiServerCallable<Row>> callsInProgress
private final TableName tableName
private final AtomicLong actionsInProgress
private final Object replicaResultLock
private final Object[] results
private final int[] replicaGetIndices
private final boolean hasAnyReplicaGets
private final long nonceGroup
public AsyncProcess.AsyncRequestFutureImpl(TableName tableName, List<Action<Row>> actions, long nonceGroup, ExecutorService pool, boolean needResults, Object[] results, Batch.Callback<CResult> callback)
long getActionsInProgress()
public Set<MultiServerCallable<Row>> getCallsInProgress()
private void groupAndSendMultiAction(List<Action<Row>> currentActions, int numAttempt)
currentActions
- - the list of row to submitnumAttempt
- - the current numAttempt (first attempt is 1)private HRegionLocation getReplicaLocationOrFail(Action<Row> action)
private RegionLocations findAllLocationsOrFail(Action<Row> action, boolean useCache)
private void sendMultiAction(Map<ServerName,MultiAction<Row>> actionsByServer, int numAttempt, List<Action<Row>> 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<Row> 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<Row>> actionsForReplicaThread)
public AsyncProcess.Retry manageError(int originalIndex, Row row, AsyncProcess.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<Row> 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<Row>> 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<Row> 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 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<Row> 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 AsyncProcess.ReplicaResultState trySetResultSimple(int index, Row row, boolean isError, Object result, ServerName server, boolean isFromReplica)
private void decActionCounter(int index)
public void waitUntilDone() throws InterruptedIOException
AsyncProcess.AsyncRequestFuture
waitUntilDone
in interface AsyncProcess.AsyncRequestFuture
InterruptedIOException
private boolean waitUntilDone(long cutoff) throws InterruptedException
InterruptedException
public boolean hasError()
hasError
in interface AsyncProcess.AsyncRequestFuture
public List<? extends Row> getFailedOperations()
getFailedOperations
in interface AsyncProcess.AsyncRequestFuture
public RetriesExhaustedWithDetailsException getErrors()
getErrors
in interface AsyncProcess.AsyncRequestFuture
public Object[] getResults() throws InterruptedIOException
getResults
in interface AsyncProcess.AsyncRequestFuture
InterruptedIOException
Copyright © 2007–2019 The Apache Software Foundation. All rights reserved.