Class NoSQLPublisher
- All Implemented Interfaces:
Publisher<StreamOperation>
For each kvstore, limit one instance of NoSQLPublisher running on a single JVM. For repeated request of publisher with same configuration, the same instance will be returned to user. If user requests a publisher instance to a kvstore with existing publisher, but with different configuration parameters, an exception will be raised to user. However, user is able to change the parameters of an existing publisher.
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
Default maximum number of subscriptions.static final long
Default shard timeout in milliseconds. -
Method Summary
Modifier and TypeMethodDescriptionvoid
close
(boolean delDir) Closes a publisher without error, shut down all connection to source and free resources.void
Closes a publisher, shut down all connection to source and free resources.static NoSQLPublisher
get
(NoSQLPublisherConfig config) Returns a handle to the NoSQL publisher after verifying that the store exists and is accessible.static NoSQLPublisher
get
(NoSQLPublisherConfig config, Logger logger) Returns a handle to the NoSQL publisher after verifying that the store exists and is accessible.static NoSQLPublisher
get
(NoSQLPublisherConfig config, LoginCredentials loginCred) Returns a handle to the NoSQL publisher after verifying that the store exists and is accessible.static NoSQLPublisher
get
(NoSQLPublisherConfig config, LoginCredentials loginCred, Logger logger) Returns a handle to the NoSQL publisher after verifying that the store exists and is accessible.long
Gets kvstore store idGets the kvstore nameboolean
isClosed()
Returns true is the publisher has already shutdownvoid
subscribe
(Subscriber<? super StreamOperation> s) A Subscriber establishes a NoSQL Subscription to initiate the flow of elements from the Publisher.
-
Field Details
-
DEFAULT_MAX_CONCURRENT_SUBS
public static final int DEFAULT_MAX_CONCURRENT_SUBSDefault maximum number of subscriptions.- See Also:
-
DEFAULT_SHARD_TIMEOUT_MS
public static final long DEFAULT_SHARD_TIMEOUT_MSDefault shard timeout in milliseconds.- See Also:
-
-
Method Details
-
get
Returns a handle to the NoSQL publisher after verifying that the store exists and is accessible. An existing publisher instance will be returned if possible. If security is configured with the system properties, this method will return a NoSQL publisher to a secure store. However, if no security is configured, this method will return a NoSQL publisher for non-secure store.- Parameters:
config
- publisher configuration- Returns:
- an instance of the publisher
- Throws:
PublisherFailureException
- if unable to create a publisher
-
get
public static NoSQLPublisher get(NoSQLPublisherConfig config, Logger logger) throws PublisherFailureException Returns a handle to the NoSQL publisher after verifying that the store exists and is accessible. An existing publisher instance will be returned if possible. If security is configured with the system properties, this method will return a NoSQL publisher to a secure store. However, if no security is configured, this method will return a NoSQL publisher for non-secure store.- Parameters:
config
- publisher configurationlogger
- private logger- Returns:
- an instance of the publisher
- Throws:
PublisherFailureException
- if unable to create a publisher
-
get
Returns a handle to the NoSQL publisher after verifying that the store exists and is accessible. An existing publisher instance will be returned if possible.- Parameters:
config
- publisher configurationloginCred
- login credentials- Returns:
- an instance of the publisher
- Throws:
PublisherFailureException
- if unable to create a publisher
-
get
public static NoSQLPublisher get(NoSQLPublisherConfig config, LoginCredentials loginCred, Logger logger) throws PublisherFailureException Returns a handle to the NoSQL publisher after verifying that the store exists and is accessible. An existing publisher instance will be returned if possible.- Parameters:
config
- publisher configurationloginCred
- login credentialslogger
- private logger- Returns:
- an instance of the publisher
- Throws:
PublisherFailureException
- if unable to create a publisher
-
subscribe
A Subscriber establishes a NoSQL Subscription to initiate the flow of elements from the Publisher. As part of the Subscription creation, the subscription configuration is obtained viaNoSQLSubscriber.getSubscriptionConfig()
. The configuration contains information needed by the Publisher to start or resume the stream. Normal completion of this method results inNoSQLSubscriber.onSubscribe(org.reactivestreams.Subscription)
being invoked.Each publisher can have at most one subscriber from a subscription group specified in
NoSQLSubscriptionConfig
. For example, for a subscription group with three subscribers, each must run in a separate publisher, preferably on separate nodes. In other words, within each Publisher, all concurrent subscriptions must be from distinct groups. If a user tries to subscribe two subscriptions from the same group to same Publisher, aSubscriptionFailureException
will be raised.Note his method is not allowed to throw any exceptions other than NullPointerException. All other exceptions must be delivered via onError, according to rule Publisher.9 in reactive stream spec.
- Specified by:
subscribe
in interfacePublisher<StreamOperation>
- Parameters:
s
- subscriber trying to use the publisher- Throws:
NullPointerException
- if subscriber is null
-
close
public void close(boolean delDir) Closes a publisher without error, shut down all connection to source and free resources. A closed publisher cannot be reopened, but user will be able to create a new instance of NoSQLPublisher.- Parameters:
delDir
- true if delete the publisher root directory
-
close
Closes a publisher, shut down all connection to source and free resources. A closed publisher cannot be reopened, but user will be able to create a new instance of NoSQLPublisher.- Parameters:
cause
- null if normal close, otherwise it is the cause of failure that leads to publisher close.delDir
- true if delete the publisher root directory
-
getStoreId
public long getStoreId()Gets kvstore store id- Returns:
- kvstore store id
-
getStoreName
Gets the kvstore name- Returns:
- kvstore name
-
isClosed
public boolean isClosed()Returns true is the publisher has already shutdown- Returns:
- true is the publisher has already shutdown
-