public static class SpannerTableTailer.Builder extends Object
SpannerTableTailer.| Modifier and Type | Method and Description |
|---|---|
SpannerTableTailer |
build()
Creates the
SpannerTableTailer. |
SpannerTableTailer.Builder |
setCommitTimestampColumn(String column)
This should only be set if your table contains more than one commit timestamp
column.
|
SpannerTableTailer.Builder |
setCommitTimestampRepository(CommitTimestampRepository repository)
Sets the
CommitTimestampRepository to use with this SpannerTableTailer. |
SpannerTableTailer.Builder |
setExecutor(ScheduledExecutorService executor)
Sets the executor to use to poll the table and to execute the
SpannerTableChangeWatcher.RowChangeCallbacks. |
SpannerTableTailer.Builder |
setFallbackToWithQuerySeconds(int seconds)
A
SpannerTableTailer that uses a FixedShardProvider with an array of values
will by default execute a simple poll query that looks like this: |
SpannerTableTailer.Builder |
setLimit(long limit)
Sets the maximum number of changes to fetch for each poll query.
|
SpannerTableTailer.Builder |
setPollInterval(org.threeten.bp.Duration interval)
Sets the poll interval for the table.
|
SpannerTableTailer.Builder |
setShardProvider(ShardProvider provider)
Sets the
ShardProvider that this SpannerTableTailer should use. |
SpannerTableTailer.Builder |
setTableHint(String tableHint)
Sets an optional table hint to use for the poll query.
|
public SpannerTableTailer.Builder setTableHint(String tableHint)
public SpannerTableTailer.Builder setLimit(long limit)
limit number of changes are found during a poll, a new poll will be scheduled directly
instead of after setPollInterval(Duration).
Setting this limit to a lower value instructs the SpannerTableTailer to execute
more poll queries more quickly if it is not able to keep up with the modifications in the
table that it is watching. Setting it too low can limit the overall throughput of the SpannerTableTailer as it cannot fetch enough rows in each poll.
Recommended values are between 1,000 and 10,000.
public SpannerTableTailer.Builder setFallbackToWithQuerySeconds(int seconds)
SpannerTableTailer that uses a FixedShardProvider with an array of values
will by default execute a simple poll query that looks like this:
SELECT *
FROM Table
WHERE LastModified > @lastSeenCommitTimestamp AND ShardId IS NOT NULL AND ShardId IN UNNEST(@shardIds)
ORDER BY LastModified, PrimaryKeyCol1, PrimaryKeyCol2, ...
LIMIT @limit
In some specific cases these queries can also automatically be re-written to a query that
creates a WITH clause for each shard id. This can be more efficient, especially if there are
many old mutations that have not yet been reported by the SpannerTableTailer. Using
such a query comes with the expense of a higher memory footprint on Cloud Spanner. This query
is therefore only used if the SpannerTableTailer is more than 60 seconds behind. This
default limit of 60 seconds can be increased or decreased with this setting.
Recommended values are between 10 seconds and 24 hours. Setting the limit to multiple
hours means that the WITH query should only be used when the SpannerTableTailer is
started after having been stopped for a while, while modifications to the watched table
continued to be applied.
public SpannerTableTailer.Builder setShardProvider(ShardProvider provider)
ShardProvider that this SpannerTableTailer should use.public SpannerTableTailer.Builder setCommitTimestampRepository(CommitTimestampRepository repository)
CommitTimestampRepository to use with this SpannerTableTailer.
If none is set, it will default to a SpannerCommitTimestampRepository which stores
the last seen commit timestamp in a table named LAST_SEEN_COMMIT_TIMESTAMPS. The table will
be created if it does not yet exist.
public SpannerTableTailer.Builder setPollInterval(org.threeten.bp.Duration interval)
public SpannerTableTailer.Builder setExecutor(ScheduledExecutorService executor)
SpannerTableChangeWatcher.RowChangeCallbacks.
Defaults to a single daemon threaded executor that is exclusively used for this SpannerTableTailer.public SpannerTableTailer.Builder setCommitTimestampColumn(String column)
Sets the commit timestamp column to use. It is only necessary to set this property if the
table contains more than one column with the allow_commit_timestamp=true option. If the table
only contains one column that can hold a commit timestamp, the SpannerTableTailer
will find the column automatically.
public SpannerTableTailer build()
SpannerTableTailer.Copyright © 2022 Google LLC. All rights reserved.