/** {@inheritDoc} */ @Override public long countElements(MutateRowsRequest request) { return request.getEntriesCount(); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + TABLE_NAME_FIELD_NUMBER; hash = (53 * hash) + getTableName().hashCode(); hash = (37 * hash) + APP_PROFILE_ID_FIELD_NUMBER; hash = (53 * hash) + getAppProfileId().hashCode(); if (getEntriesCount() > 0) { hash = (37 * hash) + ENTRIES_FIELD_NUMBER; hash = (53 * hash) + getEntriesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * Handle an RPC level failure by generating a {@link FailedMutation} for each expected entry. The * newly generated {@link FailedMutation}s will be combined with the permanentFailures to give the * caller the whole picture since the first call. This method will always throw a {@link * MutateRowsException}. */ private void handleAttemptError(Throwable rpcError) { ApiException entryError = createSyntheticErrorForRpcFailure(rpcError); ImmutableList.Builder<FailedMutation> allFailures = ImmutableList.builder(); MutateRowsRequest lastRequest = currentRequest; allFailures.addAll(permanentFailures); Builder builder = lastRequest.toBuilder().clearEntries(); List<Integer> newOriginalIndexes = Lists.newArrayList(); for (int i = 0; i < currentRequest.getEntriesCount(); i++) { int origIndex = getOriginalIndex(i); FailedMutation failedMutation = FailedMutation.create(origIndex, entryError); allFailures.add(failedMutation); if (!failedMutation.getError().isRetryable()) { permanentFailures.add(failedMutation); } else { // Schedule the mutation entry for the next RPC by adding it to the request builder and // recording its original index newOriginalIndexes.add(origIndex); builder.addEntries(lastRequest.getEntries(i)); } } currentRequest = builder.build(); originalIndexes = newOriginalIndexes; throw new MutateRowsException(rpcError, allFailures.build(), entryError.isRetryable()); }
currentRequest.getEntriesCount() > 0, "Request doesn't have any mutations to send");
assertThat(innerCallable.lastRequest.getEntriesCount()).isEqualTo(1); assertThat(innerCallable.lastRequest.getEntries(0).getRowKey()) .isEqualTo(ByteString.copyFromUtf8("1-unavailable"));
public MutateRowsRequestManager(RetryOptions retryOptions, MutateRowsRequest originalRequest) { this.currentRequest = originalRequest; this.originalRequest = originalRequest; this.retryOptions = retryOptions; results = new Status[originalRequest.getEntriesCount()]; // This map should is a map between currentRequest and originalRquest. For now, currentRequest // == originalRquest, but they could diverge if a retry occurs. mapToOriginalIndex = new int[originalRequest.getEntriesCount()]; for (int i = 0; i < mapToOriginalIndex.length; i++) { mapToOriginalIndex[i] = i; } }
/** {@inheritDoc} */ @Override public long countElements(MutateRowsRequest request) { return request.getEntriesCount(); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + TABLE_NAME_FIELD_NUMBER; hash = (53 * hash) + getTableName().hashCode(); if (getEntriesCount() > 0) { hash = (37 * hash) + ENTRIES_FIELD_NUMBER; hash = (53 * hash) + getEntriesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
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()))); }
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + TABLE_NAME_FIELD_NUMBER; hash = (53 * hash) + getTableName().hashCode(); hash = (37 * hash) + APP_PROFILE_ID_FIELD_NUMBER; hash = (53 * hash) + getAppProfileId().hashCode(); if (getEntriesCount() > 0) { hash = (37 * hash) + ENTRIES_FIELD_NUMBER; hash = (53 * hash) + getEntriesList().hashCode(); } hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
/** * Handle an RPC level failure by generating a {@link FailedMutation} for each expected entry. The * newly generated {@link FailedMutation}s will be combined with the permanentFailures to give the * caller the whole picture since the first call. This method will always throw a {@link * MutateRowsException}. */ private void handleAttemptError(Throwable rpcError) { ApiException entryError = createSyntheticErrorForRpcFailure(rpcError); ImmutableList.Builder<FailedMutation> allFailures = ImmutableList.builder(); MutateRowsRequest lastRequest = currentRequest; allFailures.addAll(permanentFailures); Builder builder = lastRequest.toBuilder().clearEntries(); List<Integer> newOriginalIndexes = Lists.newArrayList(); for (int i = 0; i < currentRequest.getEntriesCount(); i++) { int origIndex = getOriginalIndex(i); FailedMutation failedMutation = FailedMutation.create(origIndex, entryError); allFailures.add(failedMutation); if (!failedMutation.getError().isRetryable()) { permanentFailures.add(failedMutation); } else { // Schedule the mutation entry for the next RPC by adding it to the request builder and // recording its original index newOriginalIndexes.add(origIndex); builder.addEntries(lastRequest.getEntries(i)); } } currentRequest = builder.build(); originalIndexes = newOriginalIndexes; throw new MutateRowsException(rpcError, allFailures.build(), entryError.isRetryable()); }
@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; }
currentRequest.getEntriesCount() > 0, "Request doesn't have any mutations to send");