Class NoSQLSubscriptionConfig.Builder
- java.lang.Object
-
- oracle.kv.pubsub.NoSQLSubscriptionConfig.Builder
-
- Enclosing class:
- NoSQLSubscriptionConfig
public static class NoSQLSubscriptionConfig.Builder extends Object
Builder to construct a NoSQLSubscriptionConfig instance
-
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description NoSQLSubscriptionConfig
build()
Builds a NoSQLSubscriptionConfig instance from builderNoSQLSubscriptionConfig.Builder
setChangeTimeoutMs(long changeTimeoutMs)
Sets the subscription change timeout in milliseconds.NoSQLSubscriptionConfig.Builder
setCreateNewCheckpointTable(boolean allow)
Sets if publisher is allowed to create a new checkpoint table if it does not exist.NoSQLSubscriptionConfig.Builder
setEmptyStreamDuration(int emptyStreamSecs)
Sets the empty stream duration.NoSQLSubscriptionConfig.Builder
setLocalWritesOnly(boolean localWritesOnly)
Sets that when subscribing multi-region tables, whether only local writes are streamed.NoSQLSubscriptionConfig.Builder
setMaxReconnect(long maxReconnect)
Sets the max number of reconnect if stream is downNoSQLSubscriptionConfig.Builder
setStartStreamPosition(StreamPosition position)
Sets the start stream position.NoSQLSubscriptionConfig.Builder
setStreamMode(NoSQLStreamMode mode)
Sets the stream mode.NoSQLSubscriptionConfig.Builder
setSubscribedTables(String... tables)
Sets the subscribed tables under given namespace.NoSQLSubscriptionConfig.Builder
setSubscribedTables(Set<String> tables)
Sets the subscribed tables under given namespace.NoSQLSubscriptionConfig.Builder
setSubscriberId(NoSQLSubscriberId id)
Sets the subscriber id which owns the subscription.
-
-
-
Constructor Detail
-
Builder
public Builder(String ckptTableName)
Makes a builder for NoSQLSubscriptionConfig with required parameter.The checkpoint table can be specified in one of following formats:
- tablename, e.g., "MyCkptTable". The given table should be existent or will be created in system default table space.
- namespace:tablename, e.g., "MyNameSpace:MyTable". The given table should be existent or will be created in in the given name space.
- Parameters:
ckptTableName
- the full namespace name of checkpoint table. The checkpoint table cannot be a child table.- Throws:
IllegalArgumentException
- if the checkpoint table name is null or empty
-
-
Method Detail
-
build
public NoSQLSubscriptionConfig build()
Builds a NoSQLSubscriptionConfig instance from builder- Returns:
- a NoSQLSubscriptionConfig instance
-
setSubscribedTables
public NoSQLSubscriptionConfig.Builder setSubscribedTables(Set<String> tables)
Sets the subscribed tables under given namespace. Each table should be specified in one of following formats:- tablename, e.g., "MyTable". The given table should be
existent in system default table space. See
TableAPI.SYSDEFAULT_NAMESPACE_NAME
. - namespace:tablename, e.g., "MyNameSpace:MyTable". The given table should be existent in the given table space.
- Parameters:
tables
- set of table names to subscribe- Returns:
- this instance
- tablename, e.g., "MyTable". The given table should be
existent in system default table space. See
-
setSubscribedTables
public NoSQLSubscriptionConfig.Builder setSubscribedTables(String... tables)
Sets the subscribed tables under given namespace. Each table should be specified in one of following formats:- tablename, e.g., "MyTable". The given table should be existent in initial table space.
- namespace:tablename, e.g., "MyNameSpace:MyTable". The given table should be existent in given table space.
- Parameters:
tables
- set of table names to subscribe- Returns:
- this instance
-
setSubscriberId
public NoSQLSubscriptionConfig.Builder setSubscriberId(NoSQLSubscriberId id)
Sets the subscriber id which owns the subscription. If it is not set, the subscription is considered a singleton subscription with single subscriber streaming from all shards.- Parameters:
id
- subscriber id- Returns:
- this instance
-
setStartStreamPosition
public NoSQLSubscriptionConfig.Builder setStartStreamPosition(StreamPosition position)
Sets the start stream position. Depending on stream mode, the start stream position has different semantics as follows.If stream mode is set to
NoSQLStreamMode.FROM_CHECKPOINT
, which is the default if stream mode is not set, the stream will start from the checkpoint persisted in the specified checkpoint table, and any specified stream position will be ignored. If the checkpoint table does not exist, the stream will create a new checkpoint table for user if allowed. If the checkpoint table is empty, or if the position specified by the checkpoint table is not available, subscription will stream from the next available position.If stream mode is set to
NoSQLStreamMode.FROM_EXACT_CHECKPOINT
, the stream will start from the checkpoint persisted in the specified checkpoint table, and any specified stream position will be ignored. If the table does not exist, the stream will create a new checkpoint table for user if allowed. If the checkpoint table is empty, subscription will to stream from the first available entry. If a checkpoint has been saved but that stream position is not available, the subscription will fail and the publisher will signalSubscriptionInsufficientLogException
to the subscriber viaNoSQLSubscriber.onError(java.lang.Throwable)
.If stream mode is set to
NoSQLStreamMode.FROM_STREAM_POSITION
the stream will start from specified stream position if set. If the start stream position is not available, the subscription will stream from the next available position. If the start stream position is not set or is set to null,IllegalArgumentException
will be raised when the configuration is created.If stream mode is set to
NoSQLStreamMode.FROM_EXACT_STREAM_POSITION
, the stream will start from specified stream position if set. If the specified position is not available, the subscription will fail and the publisher will signalSubscriptionInsufficientLogException
to the subscriber viaNoSQLSubscriber.onError(java.lang.Throwable)
. If the start stream position is not set or set to null,IllegalArgumentException
will be raised when the configuration is created.If stream mode is set to
NoSQLStreamMode.FROM_NOW
, the stream will start from the latest available stream position and any specified start stream position will be ignored.- Parameters:
position
- stream position to start stream- Returns:
- this instance
-
setCreateNewCheckpointTable
public NoSQLSubscriptionConfig.Builder setCreateNewCheckpointTable(boolean allow)
Sets if publisher is allowed to create a new checkpoint table if it does not exist. If not set, the default is that publisher would create a new checkpoint table if it does not exist.- Parameters:
allow
- true if publisher is allowed to create a new checkpoint table for user if it does not exist; false otherwise, and subscription will fail if checkpoint table does not exist.- Returns:
- this instance
-
setStreamMode
public NoSQLSubscriptionConfig.Builder setStreamMode(NoSQLStreamMode mode) throws IllegalArgumentException
Sets the stream mode. If not set, the stream mode defaults toNoSQLStreamMode.FROM_CHECKPOINT
.- Parameters:
mode
- the stream mode- Returns:
- this instance
- Throws:
IllegalArgumentException
- if specified stream mode is null.
-
setEmptyStreamDuration
public NoSQLSubscriptionConfig.Builder setEmptyStreamDuration(int emptyStreamSecs) throws IllegalArgumentException
Sets the empty stream duration. A stream is considered empty if all subscribed tables have been removed from the subscription. An empty stream is considered to be no longer empty when at least one subscribed table is added successfully to the empty stream. If a stream is empty, the publisher would keep the empty stream alive for a period of time specified, and the publisher would shut down the empty stream when it times out.If not set, the empty stream stream duration defaults to 60 seconds.
- Parameters:
emptyStreamSecs
- empty stream lifetime in seconds- Returns:
- this instance
- Throws:
IllegalArgumentException
- if specified empty stream lifetime is non-positive.
-
setChangeTimeoutMs
public NoSQLSubscriptionConfig.Builder setChangeTimeoutMs(long changeTimeoutMs) throws IllegalArgumentException
Sets the subscription change timeout in milliseconds. When the user changes the subscription by adding or removing table, the request would be sent to kvstore and it would timeout if the kvstore does not respond the request within the time period.If not set, change timeout defaults to 30000 milliseconds.
- Parameters:
changeTimeoutMs
- change timeout in milliseconds- Returns:
- this instance
- Throws:
IllegalArgumentException
- if specified change timeout is non-positive.
-
setLocalWritesOnly
public NoSQLSubscriptionConfig.Builder setLocalWritesOnly(boolean localWritesOnly)
Sets that when subscribing multi-region tables, whether only local writes are streamed.- Returns:
- this instance
-
setMaxReconnect
public NoSQLSubscriptionConfig.Builder setMaxReconnect(long maxReconnect)
Sets the max number of reconnect if stream is down- Returns:
- this instance
-
-