Interface DestinationConnectionStrategy
- All Known Implementing Classes:
DelegateDestinationConnectionStrategy
,DestinationConnectionStrategyWithTtl
,PreferPrimaryDestinationConnectionStrategy
,RandomDestinationConnectionStrategy
,RoundRobinDestinationConnectionStrategy
public interface DestinationConnectionStrategy
Strategy used to determine to which destination to connect, and when to reconnect.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
connectFailed
(long connectionStartTimeInMillis, int failedDestinationIndex, int numDestinations) Called when a connection fails to the given failedDestinationIndex.void
connectSuccess
(long connectionStartTimeInMillis, int connectedDestinationIndex, int numDestinations) Called when a connection was successful to the given connectedDestinationIndex.int
selectNextDestinationIndex
(int previousDestinationIndex, int numDestinations) Returns the index of the destination to which to connect next.boolean
shouldReconnect
(long currentTimeInMillis, int currentDestinationIndex, int numDestinations) Returns whether the connection should be reestablished.
-
Method Details
-
selectNextDestinationIndex
int selectNextDestinationIndex(int previousDestinationIndex, int numDestinations) Returns the index of the destination to which to connect next.- Parameters:
previousDestinationIndex
- The previous destination index to which a connection was attempted (either success or failure)numDestinations
- The total number of destinations available.- Returns:
- the index of the destination to which to connect next.
-
shouldReconnect
boolean shouldReconnect(long currentTimeInMillis, int currentDestinationIndex, int numDestinations) Returns whether the connection should be reestablished.- Parameters:
currentTimeInMillis
- The time in millis for which to reevaluate whether the connection should be reestablished.currentDestinationIndex
- The index of the destination which is currently connectednumDestinations
- The total number of destinations available.- Returns:
- true if the connection should be reestablished (to the destination returned by the next call to
selectNextDestinationIndex(int, int)
, false otherwise.
-
connectSuccess
void connectSuccess(long connectionStartTimeInMillis, int connectedDestinationIndex, int numDestinations) Called when a connection was successful to the given connectedDestinationIndex.- Parameters:
connectionStartTimeInMillis
- The time in millis at which the connection was initiated (not completed).connectedDestinationIndex
- The index of the destination which was successfully connected.numDestinations
- The total number of destinations available.
-
connectFailed
void connectFailed(long connectionStartTimeInMillis, int failedDestinationIndex, int numDestinations) Called when a connection fails to the given failedDestinationIndex.- Parameters:
connectionStartTimeInMillis
- The time in millis at which the connection was initiated (not completed).failedDestinationIndex
- The index of the destination which failed to connect.numDestinations
- The total number of destinations available.
-