Class ReconnectLocationPool
java.lang.Object
org.apache.qpid.protonj2.client.util.ReconnectLocationPool
Manages the list of available reconnect entries that are used to connect
and recover a connection.
-
Constructor Summary
ConstructorDescriptionCreates an emptyReconnectLocationPool
.ReconnectLocationPool
(List<ReconnectLocation> backups) Creates a newReconnectLocationPool
with the providedReconnectLocation
values. -
Method Summary
Modifier and TypeMethodDescriptionvoid
add
(ReconnectLocation entry) Adds a new entry to the pool if not already contained within.void
addAll
(List<ReconnectLocation> additions) Adds a list of newReconnectLocation
values to the pool if not already contained within.void
addFirst
(ReconnectLocation entry) Adds a newReconnectLocation
to the pool if not already contained within.getList()
Gets the current list ofReconnectLocation
values.getNext()
Returns the next entry in the pool of entries.boolean
isEmpty()
boolean
remove
(ReconnectLocation entry) Remove aReconnectLocation
from the pool if present, otherwise has no effect.void
Removes all currently configuredReconnectLocation
from the pool, no newReconnectLocation
values will be served from this pool until new ones are added.void
replaceAll
(List<ReconnectLocation> replacements) Removes all currently configuredReconnectLocation
values from the pool and replaces them with the new set given.void
shuffle()
Randomizes the order of the list of entries contained within the pool.int
size()
toString()
-
Constructor Details
-
ReconnectLocationPool
public ReconnectLocationPool()Creates an emptyReconnectLocationPool
. -
ReconnectLocationPool
Creates a newReconnectLocationPool
with the providedReconnectLocation
values.- Parameters:
backups
- a list of location where a reconnection attempt should be made.
-
-
Method Details
-
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
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
Adds a new entry to the pool if not already contained within.- Parameters:
entry
- The newReconnectLocation
to add to the pool.
-
addAll
Adds a list of newReconnectLocation
values to the pool if not already contained within.- Parameters:
additions
- The new list ofReconnectLocation
to add to the pool.
-
addFirst
Adds a newReconnectLocation
to the pool if not already contained within. TheReconnectLocation
is added to the head of the pooledReconnectLocation
list and will be the next value that is returned from the pool.- Parameters:
entry
- The newReconnectLocation
to add to the pool.
-
remove
Remove aReconnectLocation
from the pool if present, otherwise has no effect.- Parameters:
entry
- TheReconnectLocation
to attempt to remove from the pool.- Returns:
- true if the given
ReconnectLocation
was removed from the pool.
-
removeAll
public void removeAll()Removes all currently configuredReconnectLocation
from the pool, no newReconnectLocation
values will be served from this pool until new ones are added. -
replaceAll
Removes all currently configuredReconnectLocation
values from the pool and replaces them with the new set given.- Parameters:
replacements
- The new set of reconnectReconnectLocation
values to serve from this pool.
-
getList
Gets the current list ofReconnectLocation
values. The returned list is a copy.- Returns:
- a copy of the current list of
ReconnectLocation
values in the pool.
-
toString
-