Search in sources :

Example 1 with RegionResult

use of org.apache.hadoop.hbase.client.MultiResponse.RegionResult in project hbase by apache.

the class AsyncBatchRpcRetryingCaller method onComplete.

private void onComplete(Map<byte[], RegionRequest> actionsByRegion, int tries, ServerName serverName, MultiResponse resp) {
    ConnectionUtils.updateStats(conn.getStatisticsTracker(), conn.getConnectionMetrics(), serverName, resp);
    List<Action> failedActions = new ArrayList<>();
    MutableBoolean retryImmediately = new MutableBoolean(false);
    actionsByRegion.forEach((rn, regionReq) -> {
        RegionResult regionResult = resp.getResults().get(rn);
        Throwable regionException = resp.getException(rn);
        if (regionResult != null) {
            regionReq.actions.forEach(action -> onComplete(action, regionReq, tries, serverName, regionResult, failedActions, regionException, retryImmediately));
        } else {
            Throwable error;
            if (regionException == null) {
                LOG.error("Server sent us neither results nor exceptions for {}", Bytes.toStringBinary(rn));
                error = new RuntimeException("Invalid response");
            } else {
                error = translateException(regionException);
            }
            logException(tries, () -> Stream.of(regionReq), error, serverName);
            conn.getLocator().updateCachedLocationOnError(regionReq.loc, error);
            if (error instanceof DoNotRetryIOException || tries >= maxAttempts) {
                failAll(regionReq.actions.stream(), tries, error, serverName);
                return;
            }
            if (!retryImmediately.booleanValue() && error instanceof RetryImmediatelyException) {
                retryImmediately.setTrue();
            }
            addError(regionReq.actions, error, serverName);
            failedActions.addAll(regionReq.actions);
        }
    });
    if (!failedActions.isEmpty()) {
        tryResubmit(failedActions.stream(), tries, retryImmediately.booleanValue(), false);
    }
}
Also used : RegionResult(org.apache.hadoop.hbase.client.MultiResponse.RegionResult) DoNotRetryIOException(org.apache.hadoop.hbase.DoNotRetryIOException) MutableBoolean(org.apache.commons.lang3.mutable.MutableBoolean) ArrayList(java.util.ArrayList) RetryImmediatelyException(org.apache.hadoop.hbase.RetryImmediatelyException)

Aggregations

ArrayList (java.util.ArrayList)1 MutableBoolean (org.apache.commons.lang3.mutable.MutableBoolean)1 DoNotRetryIOException (org.apache.hadoop.hbase.DoNotRetryIOException)1 RetryImmediatelyException (org.apache.hadoop.hbase.RetryImmediatelyException)1 RegionResult (org.apache.hadoop.hbase.client.MultiResponse.RegionResult)1