public class PreferPrimaryDestinationConnectionStrategy extends Object implements DestinationConnectionStrategy
Prefer to connect to the primary destination. If the primary destination is down, try other destinations.
Connections are attempted to each destination in order until a connection succeeds.
Logs will be sent to the first destination for which the connection succeeds
until the connection breaks or (if the connection is to a secondary destination)
the secondaryConnectionTTL elapses.
| Constructor and Description |
|---|
PreferPrimaryDestinationConnectionStrategy() |
| Modifier and Type | Method and Description |
|---|---|
void |
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.
|
ch.qos.logback.core.util.Duration |
getSecondaryConnectionTTL() |
int |
selectNextDestinationIndex(int previousDestinationIndex,
int numDestinations)
Returns the index of the destination to which to connect next.
|
void |
setSecondaryConnectionTTL(ch.qos.logback.core.util.Duration secondaryConnectionTTL)
Time period for connections to secondary destinations to be used
before attempting to reconnect to primary destination.
|
boolean |
shouldReconnect(long currentTimeInMillis,
int currentDestinationIndex,
int numDestinations)
Returns whether the connection should be reestablished.
|
public PreferPrimaryDestinationConnectionStrategy()
public int selectNextDestinationIndex(int previousDestinationIndex,
int numDestinations)
DestinationConnectionStrategyselectNextDestinationIndex in interface DestinationConnectionStrategypreviousDestinationIndex - The previous destination index to which a connection was attempted (either success or failure)numDestinations - The total number of destinations available.public void connectSuccess(long connectionStartTimeInMillis,
int connectedDestinationIndex,
int numDestinations)
DestinationConnectionStrategyconnectSuccess in interface DestinationConnectionStrategyconnectionStartTimeInMillis - 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.public void connectFailed(long connectionStartTimeInMillis,
int failedDestinationIndex,
int numDestinations)
DestinationConnectionStrategyconnectFailed in interface DestinationConnectionStrategyconnectionStartTimeInMillis - 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.public boolean shouldReconnect(long currentTimeInMillis,
int currentDestinationIndex,
int numDestinations)
DestinationConnectionStrategyshouldReconnect in interface DestinationConnectionStrategycurrentTimeInMillis - 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.DestinationConnectionStrategy.selectNextDestinationIndex(int, int), false otherwise.public ch.qos.logback.core.util.Duration getSecondaryConnectionTTL()
public void setSecondaryConnectionTTL(ch.qos.logback.core.util.Duration secondaryConnectionTTL)
secondaryConnectionTTL - Copyright © 2017. All Rights Reserved.