Class ReconnectLocationPool
- java.lang.Object
-
- org.apache.qpid.protonj2.client.util.ReconnectLocationPool
-
public class ReconnectLocationPool extends java.lang.ObjectManages the list of available reconnect entries that are used to connect and recover a connection.
-
-
Constructor Summary
Constructors Constructor Description ReconnectLocationPool()Creates an emptyReconnectLocationPool.ReconnectLocationPool(java.util.List<ReconnectLocation> backups)Creates a newReconnectLocationPoolwith the providedReconnectLocationvalues.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidadd(ReconnectLocation entry)Adds a new entry to the pool if not already contained within.voidaddAll(java.util.List<ReconnectLocation> additions)Adds a list of newReconnectLocationvalues to the pool if not already contained within.voidaddFirst(ReconnectLocation entry)Adds a newReconnectLocationto the pool if not already contained within.java.util.List<ReconnectLocation>getList()Gets the current list ofReconnectLocationvalues.ReconnectLocationgetNext()Returns the next entry in the pool of entries.booleanisEmpty()booleanremove(ReconnectLocation entry)Remove aReconnectLocationfrom the pool if present, otherwise has no effect.voidremoveAll()Removes all currently configuredReconnectLocationfrom the pool, no newReconnectLocationvalues will be served from this pool until new ones are added.voidreplaceAll(java.util.List<ReconnectLocation> replacements)Removes all currently configuredReconnectLocationvalues from the pool and replaces them with the new set given.voidshuffle()Randomizes the order of the list of entries contained within the pool.intsize()java.lang.StringtoString()
-
-
-
Constructor Detail
-
ReconnectLocationPool
public ReconnectLocationPool()
Creates an emptyReconnectLocationPool.
-
ReconnectLocationPool
public ReconnectLocationPool(java.util.List<ReconnectLocation> backups)
Creates a newReconnectLocationPoolwith the providedReconnectLocationvalues.- Parameters:
backups- a list of location where a reconnection attempt should be made.
-
-
Method Detail
-
size
public int size()
- Returns:
- the current size of the entry pool.
-
isEmpty
public boolean isEmpty()
- Returns:
- true if the entry pool is empty.
-
getNext
public ReconnectLocation getNext()
Returns the next entry in the pool of entries. The entry 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 entry that should be used for a connection attempt.
-
shuffle
public void shuffle()
Randomizes the order of the list of entries contained within the pool.
-
add
public void add(ReconnectLocation entry)
Adds a new entry to the pool if not already contained within.- Parameters:
entry- The newReconnectLocationto add to the pool.
-
addAll
public void addAll(java.util.List<ReconnectLocation> additions)
Adds a list of newReconnectLocationvalues to the pool if not already contained within.- Parameters:
additions- The new list ofReconnectLocationto add to the pool.
-
addFirst
public void addFirst(ReconnectLocation entry)
Adds a newReconnectLocationto the pool if not already contained within. TheReconnectLocationis added to the head of the pooledReconnectLocationlist and will be the next value that is returned from the pool.- Parameters:
entry- The newReconnectLocationto add to the pool.
-
remove
public boolean remove(ReconnectLocation entry)
Remove aReconnectLocationfrom the pool if present, otherwise has no effect.- Parameters:
entry- TheReconnectLocationto attempt to remove from the pool.- Returns:
- true if the given
ReconnectLocationwas removed from the pool.
-
removeAll
public void removeAll()
Removes all currently configuredReconnectLocationfrom the pool, no newReconnectLocationvalues will be served from this pool until new ones are added.
-
replaceAll
public void replaceAll(java.util.List<ReconnectLocation> replacements)
Removes all currently configuredReconnectLocationvalues from the pool and replaces them with the new set given.- Parameters:
replacements- The new set of reconnectReconnectLocationvalues to serve from this pool.
-
getList
public java.util.List<ReconnectLocation> getList()
Gets the current list ofReconnectLocationvalues. The returned list is a copy.- Returns:
- a copy of the current list of
ReconnectLocationvalues in the pool.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
-