Class SpannerChangeStreamSourceBuilder<T>
- Type Parameters:
T- the record type produced
SpannerChangeStreamSource.-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final DurationDefault retention assumed when the change stream declares no explicit retention; seeabsentRetentionFallback(Duration).static final DurationDefault heartbeat interval.static final intDefault bound on the open change-stream queries in one source subtask; seemaxConcurrentQueriesPerSubtask(int). -
Method Summary
Modifier and TypeMethodDescriptionabsentRetentionFallback(Duration fallback) Sets the retention used whenINFORMATION_SCHEMA.CHANGE_STREAM_OPTIONShas no explicit retention row.build()Builds the source.changeStreamName(String changeStreamName) Sets the change stream to read.columnExcludeList(Collection<String> patterns) Excludes non-key columns whosetable.columnidentifiers fully match at least one Java regular expression.columnIncludeList(Collection<String> patterns) Includes non-key columns whosetable.columnidentifiers fully match at least one Java regular expression.database(DatabaseDestination database) Sets the database holding the change stream.deserializer(SpannerChangeStreamDeserializationSchema<T> deserializer) Sets the schema turning each data-change record into output records.emulatorEndpoint(String emulatorEndpoint) Points the source at a Spanner emulator, over a plaintext channel with no credentials.heartbeatInterval(Duration interval) Sets the service heartbeat interval.maxConcurrentQueriesPerSubtask(int maximum) Bounds the TVF partition queries opened concurrently by one source subtask.resumeFallback(StartPosition resumeFallback) Sets where to restart when a restored partition position has fallen outside the stream's retention.rpcPriority(SpannerRpcPriority rpcPriority) Sets the priority Spanner schedules the partition queries at.serviceAccountKeyFile(String serviceAccountKeyFile) Authenticates the source with the service-account JSON key at the given path instead of application-default credentials.skipMessagesWithoutChange(boolean skip) Skips a data-change record when column filtering removes every non-key value it reported.startPosition(StartPosition startPosition) Sets where a fresh stream begins.tableExcludeList(Collection<String> patterns) Excludes tables whose Spanner-reported names fully match at least one Java regular expression.tableIncludeList(Collection<String> patterns) Includes tables whose Spanner-reported names fully match at least one Java regular expression.
-
Field Details
-
DEFAULT_HEARTBEAT_INTERVAL
Default heartbeat interval. Heartbeats are what advance a quiet partition's watermark; seeheartbeatInterval(Duration). -
DEFAULT_ABSENT_RETENTION_FALLBACK
Default retention assumed when the change stream declares no explicit retention; seeabsentRetentionFallback(Duration). -
DEFAULT_MAX_CONCURRENT_QUERIES_PER_SUBTASK
public static final int DEFAULT_MAX_CONCURRENT_QUERIES_PER_SUBTASKDefault bound on the open change-stream queries in one source subtask; seemaxConcurrentQueriesPerSubtask(int).- See Also:
-
-
Method Details
-
database
Sets the database holding the change stream. Required.- Parameters:
database- the database- Returns:
- this builder
-
changeStreamName
Sets the change stream to read. Required.The name is the one the
CREATE CHANGE STREAMstatement gave it; the source calls the read function Spanner generates for it.- Parameters:
changeStreamName- the change stream name, not blank and without surrounding whitespace- Returns:
- this builder
-
deserializer
public SpannerChangeStreamSourceBuilder<T> deserializer(SpannerChangeStreamDeserializationSchema<T> deserializer) Sets the schema turning each data-change record into output records. Required.Zero or more outputs per record, collected synchronously; see the schema's own documentation for what emitting nothing means.
- Parameters:
deserializer- the deserialization schema- Returns:
- this builder
-
startPosition
Sets where a fresh stream begins. Optional; defaults toStartPosition.latest().Resolved once, on the coordinator. It is ignored on a restore, where the checkpointed partition ledger decides — see
resumeFallback(StartPosition)for what happens when that ledger has expired.- Parameters:
startPosition- the start position- Returns:
- this builder
-
resumeFallback
Sets where to restart when a restored partition position has fallen outside the stream's retention. Optional; unset means such a restore fails.Setting it is a decision to lose data rather than stop: the coordinator discards the whole checkpointed ledger and starts one new query from here, so the unavailable interval is never read and records at or after this position can be delivered again.
- Parameters:
resumeFallback- the fallback start position- Returns:
- this builder
-
absentRetentionFallback
Sets the retention used whenINFORMATION_SCHEMA.CHANGE_STREAM_OPTIONShas no explicit retention row. The default is seven days. It must be longer than the one-minute retention safety margin used when resolving the earliest readable timestamp.- Parameters:
fallback- the retention to assume- Returns:
- this builder
-
heartbeatInterval
Sets the service heartbeat interval. Optional; defaults to two seconds.Heartbeats are what advance a quiet partition's watermark, so this is the upper bound on how long the source's event time can stand still while the stream is idle.
- Parameters:
interval- the heartbeat interval, from one second through five minutes and expressible in whole milliseconds- Returns:
- this builder
-
rpcPriority
Sets the priority Spanner schedules the partition queries at. Optional; unset leaves the service's own handling in place, which is the same asHIGH.Applies to every partition query in both dialects. Change Streams queries do not use Data Boost, so this is the only lever over what they cost the instance.
- Parameters:
rpcPriority- the priority- Returns:
- this builder
-
maxConcurrentQueriesPerSubtask
Bounds the TVF partition queries opened concurrently by one source subtask.The default is eight. Job-wide configured capacity is source parallelism multiplied by this value; it is a connector bound, not a published Spanner quota.
- Parameters:
maximum- the per-subtask query bound, positive- Returns:
- this builder
-
tableIncludeList
Includes tables whose Spanner-reported names fully match at least one Java regular expression.An empty collection disables this filter. It is mutually exclusive with
tableExcludeList(Collection).- Parameters:
patterns- the Java regular expressions, each matching a complete table name- Returns:
- this builder
-
tableExcludeList
Excludes tables whose Spanner-reported names fully match at least one Java regular expression.An empty collection disables this filter. It is mutually exclusive with
tableIncludeList(Collection).- Parameters:
patterns- the Java regular expressions, each matching a complete table name- Returns:
- this builder
-
columnIncludeList
Includes non-key columns whosetable.columnidentifiers fully match at least one Java regular expression.Primary-key columns are always retained. An empty collection disables this filter. It is mutually exclusive with
columnExcludeList(Collection).- Parameters:
patterns- the Java regular expressions, each matching a completetable.columnidentifier- Returns:
- this builder
-
columnExcludeList
Excludes non-key columns whosetable.columnidentifiers fully match at least one Java regular expression.Primary-key columns are always retained. An empty collection disables this filter. It is mutually exclusive with
columnIncludeList(Collection).- Parameters:
patterns- the Java regular expressions, each matching a completetable.columnidentifier- Returns:
- this builder
-
skipMessagesWithoutChange
Skips a data-change record when column filtering removes every non-key value it reported.The default is
false, which delivers the record with empty projected value objects so that transaction activity remains visible.- Parameters:
skip- whether to skip such a record- Returns:
- this builder
-
serviceAccountKeyFile
Authenticates the source with the service-account JSON key at the given path instead of application-default credentials.The JobManager reads the file when the coordinator initializes, and each TaskManager reads it when its reader opens. Only the path is serialized. 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 source at a Spanner emulator, over a plaintext channel with no credentials. Never production.The endpoint is parsed here rather than when the source connects, so a malformed value fails where the job is assembled instead of on a TaskManager.
- Parameters:
emulatorEndpoint- the emulator endpoint ashost:port- Returns:
- this builder
- Throws:
IllegalArgumentException- if the endpoint is nothost:portwith a port in 1..65535
-
build
Builds the source.- Returns:
- the source
- Throws:
IllegalStateException- if a required option was not set, if both sides of a mutually exclusive filter pair were set, or if a service-account key file was combined with an emulator endpoint
-