Package com.couchbase.client.core.node
Class RoundRobinLocator
- java.lang.Object
-
- com.couchbase.client.core.node.RoundRobinLocator
-
- All Implemented Interfaces:
Locator
- Direct Known Subclasses:
ViewLocator
public class RoundRobinLocator extends Object implements Locator
ALocator
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
Constructors Constructor Description RoundRobinLocator(ServiceType serviceType)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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.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 Detail
-
RoundRobinLocator
public RoundRobinLocator(ServiceType serviceType)
-
-
Method Detail
-
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.
-
-