Class RoundRobinAddressFunction
java.lang.Object
com.illumon.iris.db.v2.locations.remote.RoundRobinAddressFunction
- All Implemented Interfaces:
Supplier<SocketAddress>
A round-robin connection address supplier that cycles through a list of socket addresses.
This implementation uses an atomic counter to ensure thread-safe round-robin selection
across multiple addresses.
-
Constructor Summary
ConstructorsConstructorDescriptionRoundRobinAddressFunction(SocketAddress... addresses) Constructs a round-robin address function with the specified socket addresses.RoundRobinAddressFunction(Collection<String> hosts, int port) Constructs a round-robin address function from a collection of host names and a port. -
Method Summary
-
Constructor Details
-
RoundRobinAddressFunction
Constructs a round-robin address function with the specified socket addresses.- Parameters:
addresses- the socket addresses to cycle through; must be non-empty and contain no null elements- Throws:
IllegalArgumentException- if addresses is empty or contains null elements
-
RoundRobinAddressFunction
Constructs a round-robin address function from a collection of host names and a port. Creates InetSocketAddress instances for each host with the specified port.- Parameters:
hosts- the collection of host namesport- the port number to use for all addresses
-
-
Method Details
-
get
Returns the next socket address in round-robin order. This method is thread-safe and will cycle through all addresses indefinitely.- Specified by:
getin interfaceSupplier<SocketAddress>- Returns:
- the next socket address
-