Package org.jboss.ejb.client
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 Summary
FieldsModifier and TypeFieldDescriptionstatic final ClusterNodeSelectorA simple default selector which usessimpleConnectionThresholdRandomSelector(int)with a minimum of 5 connections.static final ClusterNodeSelectorA deployment node selector which check the server name if inside and prefer it if available for selection.static final ClusterNodeSelectorAlways use the first available node, regardless of whether it is connected.static final ClusterNodeSelectorAlways use the first connected node, or fall back to the first available node if none are connected.static final ClusterNodeSelectorUse a random available node, regardless of whether it is connected.static final ClusterNodeSelectorAlways use a random connected node, or fall back to a random unconnected node.static final ClusterNodeSelectorstatic final ClusterNodeSelectorUse available nodes in a round-robin fashion, regardless of whether it is connected. -
Method Summary
Modifier and TypeMethodDescriptionstatic ClusterNodeSelectorfirstConnected(ClusterNodeSelector fallback) Always try to use the first connected node.static ClusterNodeSelectorminimumConnectionThreshold(int minimum, ClusterNodeSelector unmet, ClusterNodeSelector met) Determine the action to take based on a threshold of minimum connections.selectNode(String clusterName, String[] connectedNodes, String[] totalAvailableNodes) Returns a node from among thetotalAvailableNodes, as the target node for Enterprise Beans invocations.static ClusterNodeSelectorsimpleConnectionThresholdRandomSelector(int minimum) A simple threshold-based random selector.static ClusterNodeSelectoruseRandomConnectedNode(ClusterNodeSelector fallback) Always try to use a random connected node.static ClusterNodeSelectoruseRandomUnconnectedNode(ClusterNodeSelector fallback) Always try to use an unconnected node.static ClusterNodeSelectorDeprecated.will be removed in future versionstatic ClusterNodeSelectorDeprecated.will be removed in future version
-
Field Details
-
FIRST_AVAILABLE
Always use the first available node, regardless of whether it is connected. -
FIRST_CONNECTED
Always use the first connected node, or fall back to the first available node if none are connected. -
RANDOM_CONNECTED
Always use a random connected node, or fall back to a random unconnected node. -
RANDOM
Use a random available node, regardless of whether it is connected. -
ROUND_ROBIN
Use available nodes in a round-robin fashion, regardless of whether it is connected. -
DEFAULT
A simple default selector which usessimpleConnectionThresholdRandomSelector(int)with a minimum of 5 connections. -
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
-
-
Method Details
-
selectNode
Returns a node from among thetotalAvailableNodes, as the target node for Enterprise Beans invocations. The selector can decide whether to pick an already connected node (from the passedconnectedNodes) 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 benull)connectedNodes- the node names to which a connection has been established (may be empty but will not benull)totalAvailableNodes- all available nodes in the cluster, including connected nodes (will not be empty ornull)- Returns:
- the selected node name (must not be
null)
-
simpleConnectionThresholdRandomSelector
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
Always try to use the first connected node. If no nodes are connected, the fallback is used.- Parameters:
fallback- the fallback selector (must not benull)- Returns:
- the node selector (not
null)
-
useRandomConnectedNode
Always try to use a random connected node. If no nodes are connected, the fallback is used.- Parameters:
fallback- the fallback selector (must not benull)- Returns:
- the node selector (not
null)
-
useRoundRobinConnectedNode
Deprecated.will be removed in future versionAlways 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 benull)- 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, themetselector is used, otherwise theunmetselector is used.- Parameters:
minimum- the minimum number of connectionsunmet- the selector to use when the number of connections is below the minimum and there are unconnected nodes (must not benull)met- the selector to use when the number of connections is at or above the minimum or there are no unconnected nodes (must not benull)- Returns:
- the node selector (not
null)
-
useRandomUnconnectedNode
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 benull)- Returns:
- the node selector (not
null)
-
useRoundRobinUnconnectedNode
Deprecated.will be removed in future versionAlways 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 benull)- Returns:
- the node selector (not
null)
-