Class BigtableSinkBuilder<T>
- Type Parameters:
T- type of the records written by the sink
BigtableSink.builder().
Required settings: a destination — table(TableDestination) for one fixed table, or
destinationResolver(DestinationResolver) to route per record — and a serialization
schema. Staged exactly-once delivery additionally requires an explicit transactional profile and
reserved marker family through stagedOptions(BigtableStagedOptions).
By default the sink creates no table: every table it writes to, and the column families the
mutations name, must exist. createDisposition(CreateDisposition) with CreateDisposition.CREATE_IF_NEEDED and tableCreateOptions(TableCreateOptions) opts into
creating them for at-least-once delivery, from one schema that serves every table the sink
creates.
-
Method Summary
Modifier and TypeMethodDescriptionappProfileId(String appProfileId) Routes the client's requests through the given application profile, which is what selects an instance's routing policy and its priority.org.apache.flink.api.connector.sink2.Sink<T>build()Builds the sink.createDisposition(CreateDisposition createDisposition) Sets whether the sink may create the destination table when a mutation finds it — or one of its column families — missing.Selects eager writes or checkpoint-owned writes; final service acceptance remains required.destinationResolver(DestinationResolver<? super T> destinationResolver) Resolves the destination table per record, so one sink writes to many tables.emulatorEndpoint(String emulatorEndpoint) Points the sink at a Bigtable emulator instead of the production service.exportClientMetricsToCloudMonitoring(boolean exportClientMetricsToCloudMonitoring) Sets whether the Bigtable client keeps exporting its built-in client-side metrics to Cloud Monitoring.exportClientMetricsToFlink(boolean exportClientMetricsToFlink) Exports the Bigtable client's own metrics through Flink's metric system, so that every configured Flink metric reporter sees them.failedMutationHandler(FailureHandler<? super FailedMutation> failedMutationHandler) Sets the policy for mutations that terminally fail — a record the serializer rejects, and a mutation Bigtable rejects as malformed or oversized.serializer(BigtableSerializationSchema<? super T> serializer) Sets the record serialization schema.serviceAccountKeyFile(String serviceAccountKeyFile) Authenticates the sink with the service-account JSON key at the given path instead of application-default credentials.Configures checkpoint-owned writes, including the explicitly provisioned marker family.table(TableDestination table) Writes every mutation to the given table.tableCreateOptions(TableCreateOptions tableCreateOptions) Sets column family names, value types and optional garbage-collection rules forCreateDisposition.CREATE_IF_NEEDED.writerOptions(BigtableWriterOptions writerOptions) Sets the writer tuning options (the batch thresholds and the in-flight bounds).
-
Method Details
-
deliveryGuarantee
Selects eager writes or checkpoint-owned writes; final service acceptance remains required. -
stagedOptions
Configures checkpoint-owned writes, including the explicitly provisioned marker family. -
table
Writes every mutation to the given table. Sugar for aDestinationResolverreturning that table for every record; this anddestinationResolver(DestinationResolver)set the same field, so the last call wins.- Parameters:
table- the destination table- Returns:
- this builder
-
destinationResolver
public BigtableSinkBuilder<T> destinationResolver(DestinationResolver<? super T> destinationResolver) Resolves the destination table per record, so one sink writes to many tables. The resolver runs before the serializer, and its result is what a failed mutation is reported against.This and
table(TableDestination)set the same field, so the last call wins.Each distinct table costs a bulk mutation batcher of its own, and beside
CreateDisposition.CREATE_IF_NEEDEDeach unseen table is created from the onetableCreateOptions(TableCreateOptions)schema — so a resolver's cardinality decides what the sink holds, and what it may create.- Parameters:
destinationResolver- the resolver- Returns:
- this builder
-
serializer
Sets the record serialization schema. Required; a schema returningnullskips the record rather than failing it.- Parameters:
serializer- the serialization schema- Returns:
- this builder
-
appProfileId
Routes the client's requests through the given application profile, which is what selects an instance's routing policy and its priority. Optional; when unset the instance's default profile applies.It is a sink option rather than part of
TableDestinationbecause it chooses a path to the data, not the data's address.- Parameters:
appProfileId- the application profile id- Returns:
- this builder
-
writerOptions
Sets the writer tuning options (the batch thresholds and the in-flight bounds). Optional; defaults to a freshbuilder's values. This setting is rejected for staged delivery, whose RPC settings belong toBigtableStagedOptions.- Parameters:
writerOptions- the options- Returns:
- this builder
-
failedMutationHandler
public BigtableSinkBuilder<T> failedMutationHandler(FailureHandler<? super FailedMutation> failedMutationHandler) Sets the policy for mutations that terminally fail — a record the serializer rejects, and a mutation Bigtable rejects as malformed or oversized. Defaults toFailureHandler.failJob(); transient failures never reach it, since the client retries them and an exhausted retry fails the job in the default at-least-once mode. Staged delivery requiresfailJob()and makes one SDK attempt per conditional request.- Parameters:
failedMutationHandler- the handler- Returns:
- this builder
-
serviceAccountKeyFile
Authenticates the sink with the service-account JSON key at the given path instead of application-default credentials. The file is read on each TaskManager when its writer or staged committer creates service clients, so every eligible TaskManager must see the same path. Optional; when unset the sink uses application-default credentials.Service-account keys are long-lived secrets. Prefer an attached service account or Workload Identity where the deployment supports one. This setting cannot be combined with
emulatorEndpoint(String), whose plaintext channel carries no credentials.- Parameters:
serviceAccountKeyFile- the service-account JSON key-file path- Returns:
- this builder
-
emulatorEndpoint
Points the sink at a Bigtable emulator instead of the production service. The connection to the givenhost:portuses a plaintext channel with no credentials, so this must only ever be used against an emulator. Optional; when unset the sink connects to Bigtable with application-default credentials.The value is parsed here, so a malformed
host:portis rejected on the client instead of surfacing as a connection failure once the job has been deployed.- Parameters:
emulatorEndpoint- the emulator endpoint ashost:port- Returns:
- this builder
- Throws:
IllegalArgumentException- if the endpoint is nothost:portwith a port in 1..65535
-
exportClientMetricsToFlink
Exports the Bigtable client's own metrics through Flink's metric system, so that every configured Flink metric reporter sees them. Optional; off by default.They are registered as
rpcMethod.METHOD.leaf: by the writer on its metric group, forMutateRows, or underEXACTLY_ONCEby the committer on its own, forCheckAndMutateRow, since the staging writer has no client. Per RPC method they are the client's operation and attempt counts and latencies, its retries, its connectivity errors, and its server, first-response and application time. The client's throttling time is not reported: the pinned client records it in the wrong unit. Latencies are reported as a count and a millisecond sum, so a backend divides their rates for the mean over any window; no percentile is reported. Each series moves when the client records into it: the attempt series as each RPC attempt ends, the operation series as each operation ends.This does not stop the client's built-in export of the same metrics to Cloud Monitoring;
exportClientMetricsToCloudMonitoring(boolean)does.- Parameters:
exportClientMetricsToFlink- whether to export the client's metrics to Flink- Returns:
- this builder
-
exportClientMetricsToCloudMonitoring
public BigtableSinkBuilder<T> exportClientMetricsToCloudMonitoring(boolean exportClientMetricsToCloudMonitoring) Sets whether the Bigtable client keeps exporting its built-in client-side metrics to Cloud Monitoring. Optional; on by default.Off, the client creates no Cloud Monitoring exporter at all. Besides the export, that removes the exporter's platform detection when a client closes: off Google Cloud, where nothing answers on the metadata server's address, each close otherwise waits for that connection attempt to time out. It is independent of
exportClientMetricsToFlink(boolean), which neither needs nor stops this export.- Parameters:
exportClientMetricsToCloudMonitoring- whether the client exports to Cloud Monitoring- Returns:
- this builder
-
createDisposition
Sets whether the sink may create the destination table when a mutation finds it — or one of its column families — missing. Defaults toCreateDisposition.CREATE_NEVER, under which the table and its families must exist.CreateDisposition.CREATE_IF_NEEDEDrequirestableCreateOptions(TableCreateOptions): a Bigtable table's schema is its column families and their garbage-collection policies, which the sink cannot guess.- Parameters:
createDisposition- the disposition- Returns:
- this builder
-
tableCreateOptions
Sets column family names, value types and optional garbage-collection rules forCreateDisposition.CREATE_IF_NEEDED. Missing declared families are added and existing GC rules remain unchanged. Options containing aggregate types require every existing declared type to match and inspect them before a destination first receives data, requiringbigtable.tables.get. Raw-only options retain name-only reconciliation of existing families; seeTableCreateOptions.- Parameters:
tableCreateOptions- the creation settings- Returns:
- this builder
-
build
Builds the sink.- Returns:
- the sink
- Throws:
IllegalStateException- if the destination, serializer or required staged options were not set, if the create disposition and the table-creation options disagree, or if a service-account key file was combined with an emulator endpointIllegalArgumentException- if the staged configuration is invalid, including a missing application profile or incompatible creation/failure-handler settings
-