Class BigQueryReadClients

java.lang.Object
io.github.flink.gcp.connector.bigquery.source.BigQueryReadClients

@Internal public final class BigQueryReadClients extends Object
Storage Read API clients, for the two places the source opens one: the enumerator creates the read session, and every reader opens its assigned streams.

Two factory methods rather than one, because only the reading side has anything to configure: the ReadRows retry budget is inert on a client that only creates sessions, and a caller that had to pass it would be inventing a value. Naming them after the call each serves is what keeps the wrong one from being picked.

public because those two live in sibling packages and Java has no package-tree-internal access — the same reason the connector's metric-name inventory is public.

  • Method Details

    • createForSessions

      public static com.google.cloud.bigquery.storage.v1.BigQueryReadClient createForSessions(@Nullable String serviceAccountKeyFile, @Nullable EmulatorEndpoint emulatorEndpoint) throws IOException
      Creates the client the enumerator creates its read session with.

      CreateReadSession's own retry settings are left as the SDK ships them — a ten-minute budget over DEADLINE_EXCEEDED and UNAVAILABLE. That call happens once per job, on the coordinator thread, before anything has been read, and a failure there is reported immediately rather than sitting inside a fetch.

      Parameters:
      serviceAccountKeyFile - the service-account key-file path, or null for ADC
      emulatorEndpoint - the emulator's gRPC endpoint, or null for BigQuery itself
      Returns:
      the client; the caller owns it and must close it
      Throws:
      IOException - if the client cannot be created
    • createForReads

      public static com.google.cloud.bigquery.storage.v1.BigQueryReadClient createForReads(@Nullable String serviceAccountKeyFile, @Nullable EmulatorEndpoint emulatorEndpoint, int retryMaxAttempts, @Nullable Runnable onRetry) throws IOException
      Creates the client a reader opens its assigned streams with.
      Parameters:
      serviceAccountKeyFile - the service-account key-file path, or null for ADC
      emulatorEndpoint - the emulator's gRPC endpoint, or null for BigQuery itself
      retryMaxAttempts - the bound put on the client's own ReadRows retry
      onRetry - run once per retried attempt, or null to observe none
      Returns:
      the client; the caller owns it and must close it
      Throws:
      IOException - if the client cannot be created