Class FailedChannelDetector<CHANNEL,STATE>

java.lang.Object
io.deephaven.util.grpc.FailedChannelDetector<CHANNEL,STATE>

public class FailedChannelDetector<CHANNEL,STATE> extends Object
Class to support defining a condition for when a gRPC managed channel is failed, based on either (a) a number of disconnects and reconnects quick in a row, or (b) a sustained period of disconnection. Note that using this class will prevent the channel from staying in IDLE state; if the channel is not configured to do keepalives and avoid IDLE, any time the channel turns to idle using this class will trigger a reconnect attempt on the channel. Note that in some circumstances, the failure callback can be called more than once.
  • Constructor Details

    • FailedChannelDetector

      public FailedChannelDetector(String logPfx, ScheduledExecutorService executor, FailedChannelDetector.ChannelStateReader<CHANNEL,STATE> channelStateReader, long channelDownForTimeIsFailurePeriodMillis, int repeatedChannelDownIsFailureCount, long repeatedChannelDownIsFailurePeriodMillis, Runnable failedCb)
      Creates the failed channel detector object.
      Parameters:
      logPfx - a prefix String for every log message
      executor - a scheduled executor to use for timed checks
      channelStateReader - an implementation of stateReader
      channelDownForTimeIsFailurePeriodMillis - a period of time where, if the channel stops being ready and does not get back to ready in that period, the channel is considered failed
      repeatedChannelDownIsFailureCount - together with the next argument, defines a number of times and a period of time such that, if the channel repeatedly bounces from ready to not ready in that period (or less), the channel will be considered failed.
      repeatedChannelDownIsFailurePeriodMillis - together with the previous argument, defines a number of times and a period of time such that, if the channel repeatedly bounces from ready to not ready in that period (or less), the channel will be considered failed.
      failedCb - a callback to invoke to notify the a condition for channel failed has been met. Note that in some circumstances, the callback may be invoked more than once.
  • Method Details

    • forceFailure

      public void forceFailure()
      Force a failure to be triggered on the next channel state change, no matter what the resulting state is.
    • startTracking

      public void startTracking(CHANNEL channel)
      Start tracking for channel failures. Can only be called once.
      Parameters:
      channel - the channel to track.
    • stopTracking

      public void stopTracking()
      Stop tracking for channel failures
    • shutdown

      public void shutdown()