Class FailoverUriPool


  • public class FailoverUriPool
    extends java.lang.Object
    Manages the list of available failover URIs that are used to connect and recover a connection.
    • Constructor Summary

      Constructors 
      Constructor Description
      FailoverUriPool()  
      FailoverUriPool​(java.util.List<java.net.URI> uris, java.util.Map<java.lang.String,​java.lang.String> nestedOptions)  
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void add​(java.net.URI uri)
      Adds a new URI to the pool if not already contained within.
      void addAll​(java.util.List<java.net.URI> additions)
      Adds a list of new URIs to the pool if not already contained within.
      void addFirst​(java.net.URI uri)
      Adds a new URI to the pool if not already contained within.
      void connected()
      Reports that the Failover Provider connected to the last URI returned from this pool.
      java.util.List<java.net.URI> getList()
      Gets the current list of URIs.
      java.util.Map<java.lang.String,​java.lang.String> getNestedOptions()
      Returns the currently set value for nested options which will be added to each URI that is returned from the pool.
      java.net.URI getNext()
      Returns the next URI in the pool of URIs.
      boolean isEmpty()  
      boolean isRandomize()  
      boolean remove​(java.net.URI uri)
      Remove a URI from the pool if present, otherwise has no effect.
      void removeAll()
      Removes all currently configured URIs from the pool, no new URIs will be served from this pool until new ones are added.
      void replaceAll​(java.util.List<java.net.URI> replacements)
      Removes all currently configured URIs from the pool and replaces them with the new set given.
      void setRandomize​(boolean random)
      Sets whether the URIs that are returned by this pool are returned in random order or not.
      int size()  
      java.lang.String toString()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Field Detail

      • DEFAULT_RANDOMIZE_ENABLED

        public static final boolean DEFAULT_RANDOMIZE_ENABLED
        See Also:
        Constant Field Values
    • Constructor Detail

      • FailoverUriPool

        public FailoverUriPool()
      • FailoverUriPool

        public FailoverUriPool​(java.util.List<java.net.URI> uris,
                               java.util.Map<java.lang.String,​java.lang.String> nestedOptions)
    • Method Detail

      • size

        public int size()
        Returns:
        the current size of the URI pool.
      • isEmpty

        public boolean isEmpty()
        Returns:
        true if the URI pool is empty.
      • getNext

        public java.net.URI getNext()
        Returns the next URI in the pool of URIs. The URI will be shifted to the end of the list and not be attempted again until the full list has been returned once.
        Returns:
        the next URI that should be used for a connection attempt.
      • connected

        public void connected()
        Reports that the Failover Provider connected to the last URI returned from this pool. If the Pool is set to randomize this will result in the Pool of URIs being shuffled in preparation for the next connect cycle.
      • isRandomize

        public boolean isRandomize()
        Returns:
        true if this pool returns the URI values in random order.
      • setRandomize

        public void setRandomize​(boolean random)
        Sets whether the URIs that are returned by this pool are returned in random order or not. If false the URIs are returned in FIFO order.
        Parameters:
        random - true to have the URIs returned in a random order.
      • add

        public void add​(java.net.URI uri)
        Adds a new URI to the pool if not already contained within. The URI will have any nest options that have been configured added to its existing set of options.
        Parameters:
        uri - The new URI to add to the pool.
      • addAll

        public void addAll​(java.util.List<java.net.URI> additions)
        Adds a list of new URIs to the pool if not already contained within. The URIs will have any nest options that have been configured added to their existing set of options.
        Parameters:
        additions - The new list of URIs to add to the pool.
      • addFirst

        public void addFirst​(java.net.URI uri)
        Adds a new URI to the pool if not already contained within. The URI will have any nested options that have been configured added to its existing set of options. The URI is added to the head of the pooled URIs and will be the next value that is returned from the pool.
        Parameters:
        uri - The new URI to add to the pool.
      • remove

        public boolean remove​(java.net.URI uri)
        Remove a URI from the pool if present, otherwise has no effect.
        Parameters:
        uri - The URI to attempt to remove from the pool.
        Returns:
        true if the given URI was removed from the pool.
      • removeAll

        public void removeAll()
        Removes all currently configured URIs from the pool, no new URIs will be served from this pool until new ones are added.
      • replaceAll

        public void replaceAll​(java.util.List<java.net.URI> replacements)
        Removes all currently configured URIs from the pool and replaces them with the new set given.
        Parameters:
        replacements - The new set of failover URIs to serve from this pool.
      • getList

        public java.util.List<java.net.URI> getList()
        Gets the current list of URIs. The returned list is a copy.
        Returns:
        a copy of the current list of URIs in the pool.
      • getNestedOptions

        public java.util.Map<java.lang.String,​java.lang.String> getNestedOptions()
        Returns the currently set value for nested options which will be added to each URI that is returned from the pool.
        Returns:
        the Map instance containing the nest options which can be empty if none set.
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class java.lang.Object