Class FailoverUriPool
- java.lang.Object
-
- org.apache.qpid.jms.provider.failover.FailoverUriPool
-
public class FailoverUriPool extends java.lang.ObjectManages the list of available failover URIs that are used to connect and recover a connection.
-
-
Field Summary
Fields Modifier and Type Field Description static booleanDEFAULT_RANDOMIZE_ENABLED
-
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 voidadd(java.net.URI uri)Adds a new URI to the pool if not already contained within.voidaddAll(java.util.List<java.net.URI> additions)Adds a list of new URIs to the pool if not already contained within.voidaddFirst(java.net.URI uri)Adds a new URI to the pool if not already contained within.voidconnected()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.URIgetNext()Returns the next URI in the pool of URIs.booleanisEmpty()booleanisRandomize()booleanremove(java.net.URI uri)Remove a URI from the pool if present, otherwise has no effect.voidremoveAll()Removes all currently configured URIs from the pool, no new URIs will be served from this pool until new ones are added.voidreplaceAll(java.util.List<java.net.URI> replacements)Removes all currently configured URIs from the pool and replaces them with the new set given.voidsetRandomize(boolean random)Sets whether the URIs that are returned by this pool are returned in random order or not.intsize()java.lang.StringtoString()
-
-
-
Field Detail
-
DEFAULT_RANDOMIZE_ENABLED
public static final boolean DEFAULT_RANDOMIZE_ENABLED
- See Also:
- Constant Field Values
-
-
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:
toStringin classjava.lang.Object
-
-