Class BigtableDataClients

java.lang.Object
io.github.flink.gcp.connector.bigtable.BigtableDataClients

@Internal public final class BigtableDataClients extends Object
How this connector points a BigtableDataClient at an instance: production over application-default credentials, production over a runtime-loaded service-account provider, or an emulator over a plaintext channel with no credentials.

At the module root rather than beside either direction, because every data-client boundary of this connector takes it — the sink, both sources and the table layer all build the same settings from the same inputs. The admin clients do not come through here: BigtableTableAdmin and the Change Streams coordinator build their own settings, and each carries its own copy of the emulator branch. A second copy of this branch is exactly the thing that reads green on a machine with credentials and red in CI — the failure ADR-0064 exists to describe.

Only what every path shares lives here. Per-caller tuning — the sink's batch thresholds, and whatever a source may one day need — is applied by the caller on top of the builder this hands back, which is why the return type is the builder rather than the settings.

Retry settings are deliberately untouched, on every path. The client retries MutateRows per entry, resumes a broken ReadRows stream from the last key it saw, and resumes a broken ReadChangeStream from its last continuation token. Only a failure that outlives the client's own retry budget reaches the connector, and on the Change Streams path the reader turns that into a terminal failure so Flink restarts from the checkpointed token. So nothing here owns a retry loop, and nothing has a retry knob to map. The single-row request family is the one caller that touches a call's settings on top of this builder — DefaultSingleRowClientFactory pins CheckAndMutateRow and ReadModifyWriteRow to a single attempt under its configured deadline — and it leaves the retryable-code sets as the client ships them, which for those two RPCs is empty (ADR-0148).

  • Field Details

    • DEFAULT_EXPORT_CLIENT_METRICS_TO_CLOUD_MONITORING

      public static final boolean DEFAULT_EXPORT_CLIENT_METRICS_TO_CLOUD_MONITORING
      Whether a client keeps its built-in Cloud Monitoring export when nothing chooses; one place, as DEFAULT_EXPORT_CLIENT_METRICS_TO_FLINK is.
      See Also:
  • Method Details

    • instanceKey

      public static String instanceKey(TableDestination destination)
      Returns the key under which every client pool shares one client per instance: the project and instance a destination names, in the one spelling the pools and the per-instance bookkeeping all use.
      Parameters:
      destination - the table whose instance the key names
      Returns:
      the instance key
    • settings

      public static com.google.cloud.bigtable.data.v2.BigtableDataSettings.Builder settings(TableDestination destination, @Nullable String appProfileId, @Nullable EmulatorEndpoint emulatorEndpoint, @Nullable com.google.api.gax.core.CredentialsProvider credentialsOverride)
      Builds the settings for a client that talks to a destination's instance.
      Parameters:
      destination - the table whose project and instance the client is bound to; the table itself is named per call, not in the settings
      appProfileId - the application profile to route through, or null for the instance's default
      emulatorEndpoint - the emulator to connect to (plaintext, no credentials), or null for production Bigtable
      credentialsOverride - the runtime-loaded service-account provider, or null to preserve application-default credentials
      Returns:
      the settings builder, for the caller to tune and build
    • applyClientMetrics

      public static void applyClientMetrics(com.google.cloud.bigtable.data.v2.BigtableDataSettings.Builder settings, @Nullable ClientMetrics clientMetrics, boolean exportToCloudMonitoring)
      Applies the two client-metrics choices to settings built by settings(io.github.flink.gcp.connector.bigtable.TableDestination, java.lang.String, io.github.flink.gcp.connector.base.rpc.EmulatorEndpoint, com.google.api.gax.core.CredentialsProvider).

      On the classic stub path they are independent in the client (2.85.0, BigtableClientContext). The built-in Cloud Monitoring exporter is created whenever internal metrics are enabled, whatever the metrics provider; a CustomOpenTelemetryMetricsProvider adds a second recorder beside it rather than replacing it, and NoopMetricsProvider does not remove it. So exporting to Flink leaves the Cloud Monitoring export running, and only disableInternalMetrics() stops it. The session (vRPC) path that serves ReadRow and MutateRow is the exception: MetricsImpl.newTableTracer returns a no-op tracer when internal metrics are off, so there disabling the Cloud Monitoring export also silences the second recorder.

      The provider is set on the emulator path too. The emulator builder sets NoopMetricsProvider, and a later provider replaces it: the client then records against the emulator like any other endpoint, which is what lets an emulator test observe the client's series. The emulator builder has already disabled the Cloud Monitoring export.

      Parameters:
      settings - the settings to apply them to
      clientMetrics - the client metrics to record into, or null to export nothing to Flink
      exportToCloudMonitoring - whether the client keeps its built-in Cloud Monitoring export