Class NoSQLPublisher

java.lang.Object
oracle.kv.pubsub.NoSQLPublisher
All Implemented Interfaces:
org.reactivestreams.Publisher<StreamOperation>

public class NoSQLPublisher extends Object implements org.reactivestreams.Publisher<StreamOperation>
Object represents a NoSQLPublisher which publishes changes to the NoSQL store on order, an implementation of Reactive Streams Publisher interface. 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 Details

    • DEFAULT_MAX_CONCURRENT_SUBS

      public static final int DEFAULT_MAX_CONCURRENT_SUBS
      Default maximum number of subscriptions.
      See Also:
    • DEFAULT_SHARD_TIMEOUT_MS

      public static final long DEFAULT_SHARD_TIMEOUT_MS
      Default shard timeout in milliseconds.
      See Also:
  • Method Details

    • get

      public static NoSQLPublisher get(NoSQLPublisherConfig config)
      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 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 return a NoSQL publisher for non-secure store.
      Parameters:
      config - publisher configuration
      logger - private logger
      Returns:
      an instance of the publisher
      Throws:
      PublisherFailureException - if unable to create a publisher
    • get

      public static NoSQLPublisher get(NoSQLPublisherConfig config, LoginCredentials loginCred)
      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 configuration
      loginCred - 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 configuration
      loginCred - login credentials
      logger - private logger
      Returns:
      an instance of the publisher
      Throws:
      PublisherFailureException - if unable to create a publisher
    • subscribe

      public void subscribe(org.reactivestreams.Subscriber<? super StreamOperation> s) throws NullPointerException
      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 via NoSQLSubscriber.getSubscriptionConfig(). The configuration contains information needed by the Publisher to start or resume the stream. Normal completion of this method results in NoSQLSubscriber.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, a SubscriptionFailureException 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 interface org.reactivestreams.Publisher<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

      public void close(Throwable cause, boolean delDir)
      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

      public String 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