Class RoundRobinLocator

java.lang.Object
com.couchbase.client.core.node.RoundRobinLocator
All Implemented Interfaces:
Locator
Direct Known Subclasses:
AnalyticsLocator, ViewLocator

public class RoundRobinLocator extends Object implements Locator
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 Details

    • RoundRobinLocator

      public RoundRobinLocator(ServiceType serviceType)
  • 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.
      Specified by:
      dispatch in interface Locator
      Parameters:
      request - the request to dispatch.
      nodes - the current list of active nodes.
      config - the current cluster configuration.
      ctx - the core context.
    • 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 in 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.

      Parameters:
      node - the node to check against.
      request - the request in scope.
      config - the cluster-level config.
      Returns:
      true if it can be used.