public class RoundRobinLocator extends Object implements Locator
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.
Constructor and Description |
---|
RoundRobinLocator(ServiceType serviceType) |
Modifier and Type | Method and 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 in
filterNodes(List, Request, ClusterConfig) . |
public RoundRobinLocator(ServiceType serviceType)
public void dispatch(Request<? extends Response> request, List<Node> nodes, ClusterConfig config, CoreContext ctx)
Locator
protected boolean checkServiceNotAvailable(Request<? extends Response> request, ClusterConfig config)
If this method returns false, something MUST be done with the request or it will time out!
protected boolean nodeCanBeUsed(Node node, Request<? extends Response> request, ClusterConfig config)
filterNodes(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.
node
- the node to check against.request
- the request in scope.config
- the cluster-level config.Copyright © 2020 Couchbase, Inc.. All rights reserved.