Class SpannerOptions

java.lang.Object
com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
com.google.cloud.spanner.SpannerOptions
All Implemented Interfaces:
Serializable

public class SpannerOptions extends com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
Options for the Cloud Spanner service.
See Also:
  • Field Details

  • Constructor Details

  • Method Details

    • createAsyncExecutorProvider

      public static SpannerOptions.CloseableExecutorProvider createAsyncExecutorProvider(int poolSize, long keepAliveTime, TimeUnit unit)
      Creates a SpannerOptions.CloseableExecutorProvider that can be used as an ExecutorProvider for the async API. The ExecutorProvider will lazily create up to poolSize threads. The backing threads will automatically be shutdown if they have not been used during the keep-alive time. The backing threads are created as daemon threads.
      Parameters:
      poolSize - the maximum number of threads to create in the pool
      keepAliveTime - the time that an unused thread in the pool should be kept alive
      unit - the time unit used for the keepAliveTime
      Returns:
      a SpannerOptions.CloseableExecutorProvider that can be used for SpannerOptions.Builder.setAsyncExecutorProvider(CloseableExecutorProvider)
    • getDefaultInstance

      public static SpannerOptions getDefaultInstance()
      Returns default instance of SpannerOptions.
    • newBuilder

      public static SpannerOptions.Builder newBuilder()
    • useEnvironment

      public static void useEnvironment(SpannerOptions.SpannerEnvironment environment)
      Sets the environment to use to read configuration. The default will read configuration from environment variables.
    • useDefaultEnvironment

      public static void useDefaultEnvironment()
      Sets the environment to use to read configuration to the default environment. This will read configuration from environment variables.
    • enableOpenTelemetryTraces

      public static void enableOpenTelemetryTraces()
      Enables OpenTelemetry traces. Enabling OpenTelemetry traces will disable OpenCensus traces. By default, OpenCensus traces are enabled.
    • enableOpenCensusTraces

      @ObsoleteApi("The OpenCensus project is deprecated. Use enableOpenTelemetryTraces to switch to OpenTelemetry traces") public static void enableOpenCensusTraces()
      Enables OpenCensus traces. Enabling OpenCensus traces will disable OpenTelemetry traces.
    • getActiveTracingFramework

      public static com.google.cloud.spanner.SpannerOptions.TracingFramework getActiveTracingFramework()
    • disableOpenCensusMetrics

      public static void disableOpenCensusMetrics()
      Disables OpenCensus metrics. Disable OpenCensus metrics before creating Spanner client.
    • isEnabledOpenCensusMetrics

      public static boolean isEnabledOpenCensusMetrics()
    • enableOpenTelemetryMetrics

      public static void enableOpenTelemetryMetrics()
      Enables OpenTelemetry metrics. Enable OpenTelemetry metrics before creating Spanner client.
    • isEnabledOpenTelemetryMetrics

      public static boolean isEnabledOpenTelemetryMetrics()
    • getDefaultProject

      protected String getDefaultProject()
      Overrides:
      getDefaultProject in class com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
    • getChannelProvider

      public com.google.api.gax.rpc.TransportChannelProvider getChannelProvider()
    • getChannelConfigurator

      public com.google.api.core.ApiFunction<io.grpc.ManagedChannelBuilder,io.grpc.ManagedChannelBuilder> getChannelConfigurator()
    • getInterceptorProvider

      public com.google.api.gax.grpc.GrpcInterceptorProvider getInterceptorProvider()
    • getNumChannels

      public int getNumChannels()
    • getTransportChannelExecutorThreadNameFormat

      public String getTransportChannelExecutorThreadNameFormat()
    • getSessionPoolOptions

      public SessionPoolOptions getSessionPoolOptions()
    • getDatabaseRole

      public String getDatabaseRole()
    • getSessionLabels

      public Map<String,String> getSessionLabels()
    • getSpannerStubSettings

      public SpannerStubSettings getSpannerStubSettings()
    • getInstanceAdminStubSettings

      public InstanceAdminStubSettings getInstanceAdminStubSettings()
    • getDatabaseAdminStubSettings

      public DatabaseAdminStubSettings getDatabaseAdminStubSettings()
    • getPartitionedDmlTimeout

      public org.threeten.bp.Duration getPartitionedDmlTimeout()
    • isGrpcGcpExtensionEnabled

      public boolean isGrpcGcpExtensionEnabled()
    • getGrpcGcpOptions

      public com.google.cloud.grpc.GcpManagedChannelOptions getGrpcGcpOptions()
    • isAutoThrottleAdministrativeRequests

      public boolean isAutoThrottleAdministrativeRequests()
    • getRetryAdministrativeRequestsSettings

      public com.google.api.gax.retrying.RetrySettings getRetryAdministrativeRequestsSettings()
    • isTrackTransactionStarter

      public boolean isTrackTransactionStarter()
    • getCallCredentialsProvider

      public SpannerOptions.CallCredentialsProvider getCallCredentialsProvider()
    • getCompressorName

      public String getCompressorName()
    • isLeaderAwareRoutingEnabled

      public boolean isLeaderAwareRoutingEnabled()
    • getDirectedReadOptions

      public DirectedReadOptions getDirectedReadOptions()
    • isAttemptDirectPath

      @BetaApi public boolean isAttemptDirectPath()
    • getOpenTelemetry

      public io.opentelemetry.api.OpenTelemetry getOpenTelemetry()
      Returns an instance of OpenTelemetry. If OpenTelemetry object is not set via SpannerOptions then GlobalOpenTelemetry will be used as fallback.
    • isUseVirtualThreads

      @BetaApi public boolean isUseVirtualThreads()
    • getDefaultQueryOptions

      public ExecuteSqlRequest.QueryOptions getDefaultQueryOptions(DatabaseId databaseId)
      Returns the default query options to use for the specific database.
    • getAsyncExecutorProvider

      public SpannerOptions.CloseableExecutorProvider getAsyncExecutorProvider()
    • getPrefetchChunks

      public int getPrefetchChunks()
    • getDecodeMode

      public DecodeMode getDecodeMode()
    • getDefaultGrpcTransportOptions

      public static com.google.cloud.grpc.GrpcTransportOptions getDefaultGrpcTransportOptions()
    • getDefaultHost

      protected String getDefaultHost()
      Overrides:
      getDefaultHost in class com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
    • getScopes

      public Set<String> getScopes()
      Specified by:
      getScopes in class com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
    • getSpannerRpcV1

      protected SpannerRpc getSpannerRpcV1()
    • shouldRefreshService

      protected boolean shouldRefreshService(Spanner cachedService)
      Overrides:
      shouldRefreshService in class com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
      Returns:
      true if the cached Spanner service instance is null or closed. This will cause the method ServiceOptions.getService() to create a new SpannerRpc instance when one is requested.
    • shouldRefreshRpc

      protected boolean shouldRefreshRpc(com.google.cloud.ServiceRpc cachedRpc)
      Overrides:
      shouldRefreshRpc in class com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
      Returns:
      true if the cached ServiceRpc instance is null or closed. This will cause the method ServiceOptions.getRpc() to create a new Spanner instance when one is requested.
    • toBuilder

      public SpannerOptions.Builder toBuilder()
      Specified by:
      toBuilder in class com.google.cloud.ServiceOptions<Spanner,SpannerOptions>
    • getEndpoint

      public String getEndpoint()