Package com.couchbase.client.core.node
Class RoundRobinLocator
java.lang.Object
com.couchbase.client.core.node.RoundRobinLocator
- All Implemented Interfaces:
Locator
- Direct Known Subclasses:
AnalyticsLocator
,ViewLocator
A
Locator
which implements node selection on a round-robin basis.
This locator simply tracks a counter that gets incremented and applied to the list of nodes provided. The list of nodes is filtered to make sure that only nodes with the specific service are taken into account.
- Since:
- 1.0.0
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
checkServiceNotAvailable
(Request<? extends Response> request, ClusterConfig config) Can be overridden to check if a request should be cancelled immediately that the service is not supported.void
dispatch
(Request<? extends Response> request, List<Node> nodes, ClusterConfig config, CoreContext ctx) Given the environment and node information, the implementation locates the right set of nodes and dispatches the request into them.protected boolean
nodeCanBeUsed
(Node node, Request<? extends Response> request, ClusterConfig config) This method can be overridden for additional per-node checks in addition to the service-type based check already performed infilterNodes(List, Request, ClusterConfig)
.
-
Constructor Details
-
RoundRobinLocator
-
-
Method Details
-
dispatch
public void dispatch(Request<? extends Response> request, List<Node> nodes, ClusterConfig config, CoreContext ctx) Description copied from interface:Locator
Given the environment and node information, the implementation locates the right set of nodes and dispatches the request into them. -
checkServiceNotAvailable
protected boolean checkServiceNotAvailable(Request<? extends Response> request, ClusterConfig config) Can be overridden to check if a request should be cancelled immediately that the service is not supported.If this method returns false, something MUST be done with the request, or it will time out!
-
nodeCanBeUsed
protected boolean nodeCanBeUsed(Node node, Request<? extends Response> request, ClusterConfig config) This method can be overridden for additional per-node checks in addition to the service-type based check already performed infilterNodes(List, Request, ClusterConfig)
.This method will be called for each node in the list to find out if it can be used in principle for dispatching the request.
- Parameters:
node
- the node to check against.request
- the request in scope.config
- the cluster-level config.- Returns:
- true if it can be used.
-