static AwaitReplicationCallable create( UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse> generateCallable, UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable, ClientContext clientContext, RetrySettings pollingSettings) { RetryAlgorithm<CheckConsistencyResponse> retryAlgorithm = new RetryAlgorithm<>( new PollResultAlgorithm(), new ExponentialPollAlgorithm(pollingSettings, clientContext.getClock())); RetryingExecutor<CheckConsistencyResponse> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new AwaitReplicationCallable(generateCallable, checkCallable, retryingExecutor); }
/** * Internal helper to create the base MutateRows callable chain. The chain is responsible for * retrying individual entry in case of error. * * @see MutateRowsRetryingCallable for more details */ private UnaryCallable<MutateRowsRequest, Void> createMutateRowsBaseCallable() { RetryAlgorithm<Void> retryAlgorithm = new RetryAlgorithm<>( new ApiResultRetryAlgorithm<Void>(), new ExponentialRetryAlgorithm( settings.bulkMutateRowsSettings().getRetrySettings(), clientContext.getClock())); RetryingExecutor<Void> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new MutateRowsRetryingCallable( clientContext.getDefaultCallContext(), stub.mutateRowsCallable(), retryingExecutor, settings.bulkMutateRowsSettings().getRetryableCodes()); }
private RetryingExecutorWithContext<String> getRetryingExecutor( RetryAlgorithm<String> retryAlgorithm, ScheduledExecutorService scheduler) { return new ScheduledRetryingExecutor<>(retryAlgorithm, scheduler); }
static <RequestT, ResponseT, MetadataT> OperationCallableImpl<RequestT, ResponseT, MetadataT> longRunningOperationImpl( UnaryCallable<RequestT, OperationSnapshot> initialCallable, OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings, ClientContext clientContext, LongRunningClient longRunningClient) { RetryAlgorithm<OperationSnapshot> pollingAlgorithm = new RetryAlgorithm<>( new OperationResponsePollAlgorithm(), operationCallSettings.getPollingAlgorithm()); ScheduledRetryingExecutor<OperationSnapshot> scheduler = new ScheduledRetryingExecutor<>(pollingAlgorithm, clientContext.getExecutor()); return new OperationCallableImpl<>( initialCallable, scheduler, longRunningClient, operationCallSettings); } }
static <RequestT, ResponseT, MetadataT> OperationCallableImpl<RequestT, ResponseT, MetadataT> longRunningOperationImpl( UnaryCallable<RequestT, OperationSnapshot> initialCallable, OperationCallSettings<RequestT, ResponseT, MetadataT> operationCallSettings, ClientContext clientContext, LongRunningClient longRunningClient) { RetryAlgorithm<OperationSnapshot> pollingAlgorithm = new RetryAlgorithm<>( new OperationResponsePollAlgorithm(), operationCallSettings.getPollingAlgorithm()); ScheduledRetryingExecutor<OperationSnapshot> scheduler = new ScheduledRetryingExecutor<>(pollingAlgorithm, clientContext.getExecutor()); return new OperationCallableImpl<>( initialCallable, scheduler, longRunningClient, operationCallSettings); } }
static AwaitReplicationCallable create( UnaryCallable<GenerateConsistencyTokenRequest, GenerateConsistencyTokenResponse> generateCallable, UnaryCallable<CheckConsistencyRequest, CheckConsistencyResponse> checkCallable, ClientContext clientContext, RetrySettings pollingSettings) { RetryAlgorithm<CheckConsistencyResponse> retryAlgorithm = new RetryAlgorithm<>( new PollResultAlgorithm(), new ExponentialPollAlgorithm(pollingSettings, clientContext.getClock())); RetryingExecutor<CheckConsistencyResponse> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new AwaitReplicationCallable(generateCallable, checkCallable, retryingExecutor); }
public static <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> retrying( UnaryCallable<RequestT, ResponseT> innerCallable, UnaryCallSettings<?, ?> callSettings, ClientContext clientContext) { if (callSettings.getRetryableCodes().isEmpty()) { return innerCallable; } RetryAlgorithm<ResponseT> retryAlgorithm = new RetryAlgorithm<>( new ApiResultRetryAlgorithm<ResponseT>(), new ExponentialRetryAlgorithm( callSettings.getRetrySettings(), clientContext.getClock())); ScheduledRetryingExecutor<ResponseT> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new RetryingCallable<>( clientContext.getDefaultCallContext(), innerCallable, retryingExecutor); }
public static <RequestT, ResponseT> UnaryCallable<RequestT, ResponseT> retrying( UnaryCallable<RequestT, ResponseT> innerCallable, UnaryCallSettings<?, ?> callSettings, ClientContext clientContext) { if (callSettings.getRetryableCodes().isEmpty()) { return innerCallable; } RetryAlgorithm<ResponseT> retryAlgorithm = new RetryAlgorithm<>( new ApiResultRetryAlgorithm<ResponseT>(), new ExponentialRetryAlgorithm( callSettings.getRetrySettings(), clientContext.getClock())); ScheduledRetryingExecutor<ResponseT> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new RetryingCallable<>( clientContext.getDefaultCallContext(), innerCallable, retryingExecutor); }
@BetaApi("The surface for streaming is not stable yet and may change in the future.") public static <RequestT, ResponseT> ServerStreamingCallable<RequestT, ResponseT> retrying( ServerStreamingCallable<RequestT, ResponseT> innerCallable, ServerStreamingCallSettings<RequestT, ResponseT> callSettings, ClientContext clientContext) { if (callSettings.getRetryableCodes().isEmpty()) { return innerCallable; } StreamingRetryAlgorithm<Void> retryAlgorithm = new StreamingRetryAlgorithm<>( new ApiResultRetryAlgorithm<Void>(), new ExponentialRetryAlgorithm( callSettings.getRetrySettings(), clientContext.getClock())); ScheduledRetryingExecutor<Void> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new RetryingServerStreamingCallable<>( innerCallable, retryingExecutor, callSettings.getResumptionStrategy()); }
@BetaApi("The surface for streaming is not stable yet and may change in the future.") public static <RequestT, ResponseT> ServerStreamingCallable<RequestT, ResponseT> retrying( ServerStreamingCallable<RequestT, ResponseT> innerCallable, ServerStreamingCallSettings<RequestT, ResponseT> callSettings, ClientContext clientContext) { if (callSettings.getRetryableCodes().isEmpty()) { return innerCallable; } StreamingRetryAlgorithm<Void> retryAlgorithm = new StreamingRetryAlgorithm<>( new ApiResultRetryAlgorithm<Void>(), new ExponentialRetryAlgorithm( callSettings.getRetrySettings(), clientContext.getClock())); ScheduledRetryingExecutor<Void> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new RetryingServerStreamingCallable<>( innerCallable, retryingExecutor, callSettings.getResumptionStrategy()); }
/** * Internal helper to create the base MutateRows callable chain. The chain is responsible for * retrying individual entry in case of error. * * @see MutateRowsRetryingCallable for more details */ private UnaryCallable<MutateRowsRequest, Void> createMutateRowsBaseCallable() { RetryAlgorithm<Void> retryAlgorithm = new RetryAlgorithm<>( new ApiResultRetryAlgorithm<Void>(), new ExponentialRetryAlgorithm( settings.bulkMutateRowsSettings().getRetrySettings(), clientContext.getClock())); RetryingExecutor<Void> retryingExecutor = new ScheduledRetryingExecutor<>(retryAlgorithm, clientContext.getExecutor()); return new MutateRowsRetryingCallable( clientContext.getDefaultCallContext(), stub.mutateRowsCallable(), retryingExecutor, settings.bulkMutateRowsSettings().getRetryableCodes()); }