Class RandomDestinationConnectionStrategy

java.lang.Object
net.logstash.logback.appender.destination.DestinationConnectionStrategyWithTtl
net.logstash.logback.appender.destination.RandomDestinationConnectionStrategy
All Implemented Interfaces:
DestinationConnectionStrategy

public class RandomDestinationConnectionStrategy extends DestinationConnectionStrategyWithTtl
This strategy attempts connections to the destination in a random order. If a connection fails, the next random destination is attempted.

The connectionTTL can be set to gracefully close connections after a specific duration. This will force the the appender to reattempt to connect to the next random destination.

  • Constructor Details

    • RandomDestinationConnectionStrategy

      public RandomDestinationConnectionStrategy()
    • RandomDestinationConnectionStrategy

      public RandomDestinationConnectionStrategy(UnaryOperator<Integer> randomSupplier)
  • Method Details

    • selectNextDestinationIndex

      public int selectNextDestinationIndex(int previousDestinationIndex, int numDestinations)
      Description copied from interface: DestinationConnectionStrategy
      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.