Package io.deephaven.util.grpc
Class FailedChannelDetector<CHANNEL,STATE>
java.lang.Object
io.deephaven.util.grpc.FailedChannelDetector<CHANNEL,STATE>
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.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceClass to avoid a particular import path for gRPC classes, so that different clients can use our functionality for different shadowed gRPC packages. -
Constructor Summary
ConstructorsConstructorDescriptionFailedChannelDetector(String logPfx, ScheduledExecutorService executor, FailedChannelDetector.ChannelStateReader<CHANNEL, STATE> channelStateReader, long channelDownForTimeIsFailurePeriodMillis, int repeatedChannelDownIsFailureCount, long repeatedChannelDownIsFailurePeriodMillis, Runnable failedCb) Creates the failed channel detector object. -
Method Summary
Modifier and TypeMethodDescriptionvoidForce a failure to be triggered on the next channel state change, no matter what the resulting state is.voidshutdown()voidstartTracking(CHANNEL channel) Start tracking for channel failures.voidStop tracking for channel failures
-
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 messageexecutor- a scheduled executor to use for timed checkschannelStateReader- an implementation of stateReaderchannelDownForTimeIsFailurePeriodMillis- 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 failedrepeatedChannelDownIsFailureCount- 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
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()
-