Class SpannerOptions.Builder (6.74.0)

public static class SpannerOptions.Builder extends ServiceOptions.Builder<Spanner,SpannerOptions,SpannerOptions.Builder>

Builder for SpannerOptions instances.

Inheritance

java.lang.Object > com.google.cloud.ServiceOptions.Builder > SpannerOptions.Builder

Constructors

Builder()

protected Builder()

Methods

build()

public SpannerOptions build()
Returns
Type Description
SpannerOptions
Overrides
com.google.cloud.ServiceOptions.Builder.build()

disableAdministrativeRequestRetries()

public SpannerOptions.Builder disableAdministrativeRequestRetries()

Disables automatic retries of administrative requests that fail if the https://cloud.google.com/spanner/quotas#administrative_limits have been exceeded. You should disable these retries if you intend to handle these errors in your application.

Returns
Type Description
SpannerOptions.Builder

disableDirectPath()

public SpannerOptions.Builder disableDirectPath()
Returns
Type Description
SpannerOptions.Builder

disableGrpcGcpExtension()

public SpannerOptions.Builder disableGrpcGcpExtension()

Disables gRPC-GCP extension.

Returns
Type Description
SpannerOptions.Builder

disableLeaderAwareRouting()

public SpannerOptions.Builder disableLeaderAwareRouting()

Disable leader aware routing. Disabling leader aware routing would route all requests in RW/PDML transactions to any region.

Returns
Type Description
SpannerOptions.Builder

enableGrpcGcpExtension()

public SpannerOptions.Builder enableGrpcGcpExtension()

Enables gRPC-GCP extension with the default settings. Do not set GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS to true in combination with this option, as Multiplexed sessions are not supported for gRPC-GCP.

Returns
Type Description
SpannerOptions.Builder

enableGrpcGcpExtension(GcpManagedChannelOptions options)

public SpannerOptions.Builder enableGrpcGcpExtension(GcpManagedChannelOptions options)

Enables gRPC-GCP extension and uses provided options for configuration. The metric registry and default Spanner metric labels will be added automatically. Do not set GOOGLE_CLOUD_SPANNER_MULTIPLEXED_SESSIONS to true in combination with this option, as Multiplexed sessions are not supported for gRPC-GCP.

Parameter
Name Description
options com.google.cloud.grpc.GcpManagedChannelOptions
Returns
Type Description
SpannerOptions.Builder

enableLeaderAwareRouting()

public SpannerOptions.Builder enableLeaderAwareRouting()

Enable leader aware routing. Leader aware routing would route all requests in RW/PDML transactions to the leader region.

Returns
Type Description
SpannerOptions.Builder

getAllowedClientLibTokens()

protected Set<String> getAllowedClientLibTokens()
Returns
Type Description
Set<String>
Overrides
com.google.cloud.ServiceOptions.Builder.getAllowedClientLibTokens()

getDatabaseAdminStubSettingsBuilder()

public DatabaseAdminStubSettings.Builder getDatabaseAdminStubSettingsBuilder()

Returns the DatabaseAdminStubSettings.Builder that will be used to build the SpannerRpc. Use this to set custom RetrySettings for individual gRPC methods.

The library will automatically use the defaults defined in DatabaseAdminStubSettings if no custom settings are set. The defaults are the same as the defaults that are used by DatabaseAdminSettings, and are generated from the file spanner_admin_database_gapic.yaml. Retries are configured for idempotent methods but not for non-idempotent methods.

You can set the same RetrySettings for all unary methods by calling this:


 builder
     .getDatabaseAdminStubSettingsBuilder()
     .applyToAllUnaryMethods(
         new ApiFunction<UnaryCallSettings.Builder<?, ?>, Void>() {
           public Void apply(Builder<?, ?> input) {
             input.setRetrySettings(retrySettings);
             return null;
           }
         });
 
Returns
Type Description
DatabaseAdminStubSettings.Builder

getInstanceAdminStubSettingsBuilder()

public InstanceAdminStubSettings.Builder getInstanceAdminStubSettingsBuilder()

Returns the InstanceAdminStubSettings.Builder that will be used to build the SpannerRpc. Use this to set custom RetrySettings for individual gRPC methods.

The library will automatically use the defaults defined in InstanceAdminStubSettings if no custom settings are set. The defaults are the same as the defaults that are used by InstanceAdminSettings, and are generated from the file spanner_admin_instance_gapic.yaml. Retries are configured for idempotent methods but not for non-idempotent methods.

You can set the same RetrySettings for all unary methods by calling this:


 builder
     .getInstanceAdminStubSettingsBuilder()
     .applyToAllUnaryMethods(
         new ApiFunction<UnaryCallSettings.Builder<?, ?>, Void>() {
           public Void apply(Builder<?, ?> input) {
             input.setRetrySettings(retrySettings);
             return null;
           }
         });
 
Returns
Type Description
InstanceAdminStubSettings.Builder

getSpannerStubSettingsBuilder()

public SpannerStubSettings.Builder getSpannerStubSettingsBuilder()

Returns the SpannerStubSettings.Builder that will be used to build the SpannerRpc. Use this to set custom RetrySettings for individual gRPC methods.

The library will automatically use the defaults defined in SpannerStubSettings if no custom settings are set. The defaults are the same as the defaults that are used by SpannerSettings, and are generated from the file spanner_gapic.yaml. Retries are configured for idempotent methods but not for non-idempotent methods.

You can set the same RetrySettings for all unary methods by calling this:


 builder
     .getSpannerStubSettingsBuilder()
     .applyToAllUnaryMethods(
         new ApiFunction<UnaryCallSettings.Builder<?, ?>, Void>() {
           public Void apply(Builder<?, ?> input) {
             input.setRetrySettings(retrySettings);
             return null;
           }
         });
 
Returns
Type Description
SpannerStubSettings.Builder

setAsyncExecutorProvider(SpannerOptions.CloseableExecutorProvider provider)

public SpannerOptions.Builder setAsyncExecutorProvider(SpannerOptions.CloseableExecutorProvider provider)

Sets the ExecutorProvider to use for high-level async calls that need an executor, such as fetching results for an AsyncResultSet.

Async methods will use a sensible default if no custom ExecutorProvider has been set. The default ExecutorProvider uses a cached thread pool containing a maximum of 8 threads. The pool is lazily initialized and will not create any threads if the user application does not use any async methods. It will also scale down the thread usage if the async load allows for that.

Call SpannerOptions#createAsyncExecutorProvider(int, long, TimeUnit) to create a provider with a custom pool size or call FixedCloseableExecutorProvider#create(ScheduledExecutorService) to create a CloseableExecutorProvider from a standard Java ScheduledExecutorService.

Parameter
Name Description
provider SpannerOptions.CloseableExecutorProvider
Returns
Type Description
SpannerOptions.Builder

setAutoThrottleAdministrativeRequests()

public SpannerOptions.Builder setAutoThrottleAdministrativeRequests()

Instructs the client library to automatically throttle the number of administrative requests if the rate of administrative requests generated by this Spanner instance will exceed the administrative limits Cloud Spanner. The default behavior is to not throttle any requests. If the limit is exceeded, Cloud Spanner will return a RESOURCE_EXHAUSTED error. More information on the administrative limits can be found here: https://cloud.google.com/spanner/quotas#administrative_limits. Setting this option is not a guarantee that the rate will never be exceeded, as this option will only throttle requests coming from this client. Additional requests from other clients could still cause the limit to be exceeded.

Returns
Type Description
SpannerOptions.Builder

setCallCredentialsProvider(SpannerOptions.CallCredentialsProvider callCredentialsProvider)

public SpannerOptions.Builder setCallCredentialsProvider(SpannerOptions.CallCredentialsProvider callCredentialsProvider)

Sets a CallCredentialsProvider that can deliver CallCredentials to use on a per-gRPC basis.

Parameter
Name Description
callCredentialsProvider SpannerOptions.CallCredentialsProvider
Returns
Type Description
SpannerOptions.Builder

setChannelConfigurator(ApiFunction<ManagedChannelBuilder,ManagedChannelBuilder> channelConfigurator)

public SpannerOptions.Builder setChannelConfigurator(ApiFunction<ManagedChannelBuilder,ManagedChannelBuilder> channelConfigurator)

Sets an ApiFunction that will be used to