Package com.couchbase.client.java.util
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 Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description StringactiveNodeForId(String id)Returns the target active node address for a given document ID on the bucket.List<String>availableReplicaNodesForId(String id)Returns all target replica nodes which are currently available on the bucket.static NodeLocatorHelpercreate(Bucket bucket, Duration waitUntilReadyDuration)Creates a newNodeLocatorHelper, mapped on to the givenBucket.List<String>nodes()Returns all nodes known in the current config.StringreplicaNodeForId(String id, int replicaNum)Returns the target replica node address for a given document ID and replica number on the bucket.List<String>replicaNodesForId(String id)Returns all target replica nodes addresses for a given document ID on the bucket.
-
-
-
Method Detail
-
create
public static NodeLocatorHelper create(Bucket bucket, Duration waitUntilReadyDuration)
Creates a newNodeLocatorHelper, mapped on to the givenBucket. To make sure that the helper has a bucket config to work with in the beginning, it will callBucket.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.
-
-