Class NodeLocatorHelper

java.lang.Object
com.couchbase.client.java.util.NodeLocatorHelper

@Uncommitted public class NodeLocatorHelper extends Object
Helper class to provide direct access on how document IDs are mapped onto nodes.
  • Method Details

    • create

      public static NodeLocatorHelper create(Bucket bucket, Duration waitUntilReadyDuration)
      Creates a new NodeLocatorHelper, mapped on to the given Bucket. To make sure that the helper has a bucket config to work with in the beginning, it will call Bucket.waitUntilReady(Duration) with the duration provided as an argument. If you already did call waitUntilReady before initializing the helper, you can pass a duration of 0 in which case it will be omitted.
      Parameters:
      bucket - the scoped bucket.
      waitUntilReadyDuration - the duration used to call waitUntilReady (if 0 ignored).
      Returns:
      the created locator.
    • activeNodeForId

      public String activeNodeForId(String id)
      Returns the target active node address for a given document ID on the bucket.
      Parameters:
      id - the document id to convert.
      Returns:
      the node for the given document id.
    • availableReplicaNodesForId

      public List<String> availableReplicaNodesForId(String id)
      Returns all target replica nodes which are currently available on the bucket.
      Parameters:
      id - the document ID to check.
      Returns:
      the list of nodes for the given document ID.
    • replicaNodesForId

      public List<String> replicaNodesForId(String id)
      Returns all target replica nodes addresses for a given document ID on the bucket.
      Parameters:
      id - the document id to convert.
      Returns:
      the node for the given document id.
    • replicaNodeForId

      public String replicaNodeForId(String id, int replicaNum)
      Returns the target replica node address for a given document ID and replica number on the bucket.
      Parameters:
      id - the document id to convert.
      replicaNum - the replica number.
      Returns:
      the node for the given document id.
    • nodes

      public List<String> nodes()
      Returns all nodes known in the current config.
      Returns:
      all currently known nodes.