@Override protected MutateRowsRequest getRetryRequest() { return requestManager.getRetryRequest(); }
@Override public void onMessage(MutateRowsResponse message) { try { requestManager.onMessage(message); } catch (Exception e) { setException(e); } }
@Override protected boolean onOK(Metadata trailers) { ProcessingStatus status = requestManager.onOK(); if (status == ProcessingStatus.INVALID) { // Set an exception. onError(INVALID_RESPONSE, trailers); return true; } // There was a problem in the data found in onMessage(), so fail the RPC. if (status == ProcessingStatus.SUCCESS || status == ProcessingStatus.NOT_RETRYABLE) { // Set the response, with either success, or non-retryable responses. completionFuture.set(Arrays.asList(requestManager.buildResponse())); return true; } // Perform a partial retry, if the backoff policy allows it. Long nextBackOff = getNextBackoff(); if (nextBackOff == null) { // Return the response as is, and don't retry; rpc.getRpcMetrics().markRetriesExhasted(); completionFuture.set(Arrays.asList(requestManager.buildResponse())); operationSpan.addAnnotation("MutationCount", ImmutableMap.of("failureCount", AttributeValue.longAttributeValue(requestManager.getRetryRequest().getEntriesCount()))); return true; } performRetry(nextBackOff); operationSpan.addAnnotation("MutationCount", ImmutableMap.of("retryCount", AttributeValue.longAttributeValue(requestManager.getRetryRequest().getEntriesCount()))); return false; }
if (status.getCode() == io.grpc.Status.Code.OK.value()) { continue; } else if (retryOptions.isRetryable(getGrpcCode(status))) { currentRequest = createRetryRequest(toRetry);
/** * @return a {@link MutateRowsResponse} built from the accumulation of all calls to * onMessage/onOK. */ public MutateRowsResponse buildResponse() { List<MutateRowsResponse.Entry> entries = new ArrayList<>(); for (int i = 0; i < results.length; i++) { Status status = (results[i] == null) ? STATUS_INTERNAL : results[i]; entries.add(createEntry(i, status)); } return MutateRowsResponse.newBuilder().addAllEntries(entries).build(); } }
public RetryingMutateRowsOperation(RetryOptions retryOptions, MutateRowsRequest originalRquest, BigtableAsyncRpc<MutateRowsRequest, MutateRowsResponse> retryableRpc, CallOptions callOptions, ScheduledExecutorService retryExecutorService, Metadata originalMetadata, ApiClock clock) { super(retryOptions, originalRquest, retryableRpc, callOptions, retryExecutorService, originalMetadata, clock); requestManager = new MutateRowsRequestManager(retryOptions, originalRquest); operationSpan.addAnnotation("MutationCount", ImmutableMap.of("count", AttributeValue.longAttributeValue(originalRquest.getEntriesCount()))); }