Interface ClusterNodeSelector


public interface ClusterNodeSelector
A selector which selects and returns a node from the available nodes in a cluster. Typical usage of a ClusterNodeSelector involve load balancing of calls to various nodes in the cluster.
Author:
Jaikiran Pai, Wolf Dieter Fink
  • Field Details

    • FIRST_AVAILABLE

      static final ClusterNodeSelector FIRST_AVAILABLE
      Always use the first available node, regardless of whether it is connected.
    • FIRST_CONNECTED

      static final ClusterNodeSelector FIRST_CONNECTED
      Always use the first connected node, or fall back to the first available node if none are connected.
    • RANDOM_CONNECTED

      static final ClusterNodeSelector RANDOM_CONNECTED
      Always use a random connected node, or fall back to a random unconnected node.
    • RANDOM

      static final ClusterNodeSelector RANDOM
      Use a random available node, regardless of whether it is connected.
    • ROUND_ROBIN

      static final ClusterNodeSelector ROUND_ROBIN
      Use available nodes in a round-robin fashion, regardless of whether it is connected.
    • DEFAULT

      static final ClusterNodeSelector DEFAULT
      A simple default selector which uses simpleConnectionThresholdRandomSelector(int) with a minimum of 5 connections.
    • DEFAULT_PREFER_LOCAL

      static final ClusterNodeSelector DEFAULT_PREFER_LOCAL
      A deployment node selector which check the server name if inside and prefer it if available for selection. If no local node is used the DEFAULT will be used and connect a minimum of 5 nodes and select it randomly.
    • RANDOM_PREFER_LOCAL

      static final ClusterNodeSelector RANDOM_PREFER_LOCAL
  • Method Details

    • selectNode

      String selectNode(String clusterName, String[] connectedNodes, String[] totalAvailableNodes)
      Returns a node from among the totalAvailableNodes, as the target node for Enterprise Beans invocations. The selector can decide whether to pick an already connected node (from the passed connectedNodes) or decide to select a node to which a connection hasn't yet been established. If a node to which a connection hasn't been established is selected then the cluster context will create a connection to it.
      Parameters:
      clusterName - the name of the cluster to which the nodes belong (will not be null)
      connectedNodes - the node names to which a connection has been established (may be empty but will not be null)
      totalAvailableNodes - all available nodes in the cluster, including connected nodes (will not be empty or null)
      Returns:
      the selected node name (must not be null)
    • simpleConnectionThresholdRandomSelector

      static ClusterNodeSelector simpleConnectionThresholdRandomSelector(int minimum)
      A simple threshold-based random selector. If the minimum is met, then a random connected node is used, otherwise a random available node is used, increasing the total number of connections for future invocations.
      Parameters:
      minimum - the minimum number of connected nodes to attempt to acquire
      Returns:
      the node selector (not null)
    • firstConnected

      static ClusterNodeSelector firstConnected(ClusterNodeSelector fallback)
      Always try to use the first connected node. If no nodes are connected, the fallback is used.
      Parameters:
      fallback - the fallback selector (must not be null)
      Returns:
      the node selector (not null)
    • useRandomConnectedNode

      static ClusterNodeSelector useRandomConnectedNode(ClusterNodeSelector fallback)
      Always try to use a random connected node. If no nodes are connected, the fallback is used.
      Parameters:
      fallback - the fallback selector (must not be null)
      Returns:
      the node selector (not null)
    • useRoundRobinConnectedNode

      @Deprecated static ClusterNodeSelector useRoundRobinConnectedNode(ClusterNodeSelector fallback)
      Deprecated.
      will be removed in future version
      Always try to round-robin among connected nodes. If no nodes are connected, the fallback is used. Note that the round-robin node count may be shared among multiple node sets, thus certain specific usage patterns may defeat the round-robin behavior.
      Parameters:
      fallback - the fallback selector (must not be null)
      Returns:
      the node selector (not null)
    • minimumConnectionThreshold

      static ClusterNodeSelector minimumConnectionThreshold(int minimum, ClusterNodeSelector unmet, ClusterNodeSelector met)
      Determine the action to take based on a threshold of minimum connections. If the minimum is met, or if there are no more available nodes to choose from, the met selector is used, otherwise the unmet selector is used.
      Parameters:
      minimum - the minimum number of connections
      unmet - the selector to use when the number of connections is below the minimum and there are unconnected nodes (must not be null)
      met - the selector to use when the number of connections is at or above the minimum or there are no unconnected nodes (must not be null)
      Returns:
      the node selector (not null)
    • useRandomUnconnectedNode

      static ClusterNodeSelector useRandomUnconnectedNode(ClusterNodeSelector fallback)
      Always try to use an unconnected node. If all nodes are connected, the fallback is used.
      Parameters:
      fallback - the selector to use if all available nodes are connected (must not be null)
      Returns:
      the node selector (not null)
    • useRoundRobinUnconnectedNode

      @Deprecated static ClusterNodeSelector useRoundRobinUnconnectedNode(ClusterNodeSelector fallback)
      Deprecated.
      will be removed in future version
      Always try to use an unconnected node in a round-robin fashion. If all nodes are connected, the fallback is used.
      Parameters:
      fallback - the selector to use if all available nodes are connected (must not be null)
      Returns:
      the node selector (not null)