Package org.jboss.ejb.client
Interface ClusterNodeSelector
-
public interface ClusterNodeSelectorA selector which selects and returns a node from the available nodes in a cluster. Typical usage of aClusterNodeSelectorinvolve load balancing of calls to various nodes in the cluster.- Author:
- Jaikiran Pai, Wolf Dieter Fink
-
-
Field Summary
Fields Modifier and Type Field Description static ClusterNodeSelectorDEFAULTA simple default selector which usessimpleConnectionThresholdRandomSelector(int)with a minimum of 5 connections.static ClusterNodeSelectorDEFAULT_PREFER_LOCALA deployment node selector which check the server name if inside and prefer it if available for selection.static ClusterNodeSelectorFIRST_AVAILABLEAlways use the first available node, regardless of whether it is connected.static ClusterNodeSelectorFIRST_CONNECTEDAlways use the first connected node, or fall back to the first available node if none are connected.static ClusterNodeSelectorRANDOMUse a random available node, regardless of whether it is connected.static ClusterNodeSelectorRANDOM_CONNECTEDAlways use a random connected node, or fall back to a random unconnected node.static ClusterNodeSelectorRANDOM_PREFER_LOCALstatic ClusterNodeSelectorROUND_ROBINUse available nodes in a round-robin fashion, regardless of whether it is connected.
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Modifier and Type Method Description static 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.StringselectNode(String clusterName, String[] connectedNodes, String[] totalAvailableNodes)Returns a node from among thetotalAvailableNodes, as the target node for EJB 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 ClusterNodeSelectoruseRoundRobinConnectedNode(ClusterNodeSelector fallback)Always try to round-robin among connected nodes.static ClusterNodeSelectoruseRoundRobinUnconnectedNode(ClusterNodeSelector fallback)Always try to use an unconnected node in a round-robin fashion.
-
-
-
Field Detail
-
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 usessimpleConnectionThresholdRandomSelector(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 Detail
-
selectNode
String selectNode(String clusterName, String[] connectedNodes, String[] totalAvailableNodes)
Returns a node from among thetotalAvailableNodes, as the target node for EJB 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
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 benull)- 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 benull)- Returns:
- the node selector (not
null)
-
useRoundRobinConnectedNode
static ClusterNodeSelector useRoundRobinConnectedNode(ClusterNodeSelector fallback)
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 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
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 benull)- Returns:
- the node selector (not
null)
-
useRoundRobinUnconnectedNode
static ClusterNodeSelector useRoundRobinUnconnectedNode(ClusterNodeSelector fallback)
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 benull)- Returns:
- the node selector (not
null)
-
-