Interface DiscoveredURISelector


  • public interface DiscoveredURISelector
    A selector which selects and returns a URI, from among the passed eligible URIs, that can handle a specific deployment within a EJB client context. Typical usage of DiscoveredURISelector involves load balancing calls to multiple targets which can all handle the same deployment. This allows the application to have a deterministic target selection policy while dealing with multiple targets with same deployment.

    Target selection is only used when discovery yields more than one URI as a result of its query to locate an EJB.

    Author:
    David M. Lloyd, Jaikiran Pai
    • Field Detail

      • FIRST

        static final DiscoveredURISelector FIRST
        A deployment URI selector which prefers the first URI always. This will generally avoid load balancing in most cases.
      • RANDOM

        static final DiscoveredURISelector RANDOM
        A deployment URI selector which randomly chooses the next URI. This will generally provide the best possible load balancing over a large number of requests.
      • ROUND_ROBIN

        static final DiscoveredURISelector ROUND_ROBIN
        A deployment URI selector which uses an approximate round-robin policy among all of the eligible URIs. Note that the round-robin URI count may be shared among multiple node sets, thus certain specific usage patterns may defeat the round-robin behavior.
    • Method Detail

      • selectNode

        URI selectNode​(List<URI> eligibleUris,
                       EJBLocator<?> locator)
        Selects and returns a URI from among the eligibleUris to handle the invocation on a deployment represented by the passed in locator. Implementations of this method must not return null or any other node name which isn't in the eligibleUris list.

        Note that the list sent in for eligibleUris is indexed, meaning that the contains operation is guaranteed to run in constant time.

        Parameters:
        eligibleUris - an indexed list of the eligible nodes which can handle the deployment; not null, will not be empty
        locator - the locator of the EJB being invoked upon
        Returns:
        the URI selection (must not be null, must be one of the URIs from eligibleUris)
      • favorite

        static DiscoveredURISelector favorite​(Collection<URI> favorites,
                                              DiscoveredURISelector fallback)
        Create a deployment URI selector that prefers one or more favorite nodes, falling back to another selector if none of the favorites are found.
        Parameters:
        favorites - the favorite nodes, in decreasing order of preference (must not be null)
        fallback - the fallback selector (must not be null)
        Returns:
        the selector (not null)