Class HeartbeatMonitor
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.HeartbeatMonitor
-
public class HeartbeatMonitor extends Object
Monitor dealing with all the logic around sending out heartbeats.
-
-
Constructor Summary
Constructors Constructor Description HeartbeatMonitor(ScheduledExecutorService executor, HeartbeatSender heartbeatSender, Runnable onConnectionCorrupted)Constructs aHeartbeatMonitor.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddisableHeartbeat()Turn off heartbeat sending by thisHeartbeatMonitor.voidenableHeartbeat(long interval, long timeout, TimeUnit timeUnit)Turn on heartbeat sending by thisHeartbeatMonitor.voidhandleIncomingBeat(ReplyChannel<PlatformInboundInstruction> reply)Handler ofPlatformInboundInstructionrequesting a heartbeat from this connector.voidpause()Pause the process of sending out heartbeats by this monitor.voidresume()Resume the process of sending out heartbeats by this monitor.
-
-
-
Constructor Detail
-
HeartbeatMonitor
public HeartbeatMonitor(ScheduledExecutorService executor, HeartbeatSender heartbeatSender, Runnable onConnectionCorrupted)
Constructs aHeartbeatMonitor.- Parameters:
executor- theScheduledExecutorServiceused to schedule operations to validate if a heartbeat should be send with the givenheartbeatSenderheartbeatSender- theHeartbeatSenderused to send heartbeats withonConnectionCorrupted- operation to perform if a heartbeat has been missed. Can be used to force a reconnect of a channel for example
-
-
Method Detail
-
enableHeartbeat
public void enableHeartbeat(long interval, long timeout, TimeUnit timeUnit)Turn on heartbeat sending by thisHeartbeatMonitor.- Parameters:
interval- the interval at which heartbeats occur. Will use a minimal value of500milliseconds to reschedule heartbeat validationtimeout- the timeout within which this monitor expects responses to the dispatched heartbeats. If this timeout is hit, the givenonHeartbeatMissedon construction will be calledtimeUnit- theTimeUnitused to define in which time frame both the givenintervalandtimeoutreside. Will be used to change both values to their representative in milliseconds
-
disableHeartbeat
public void disableHeartbeat()
Turn off heartbeat sending by thisHeartbeatMonitor.
-
pause
public void pause()
Pause the process of sending out heartbeats by this monitor.
-
resume
public void resume()
Resume the process of sending out heartbeats by this monitor.
-
handleIncomingBeat
public void handleIncomingBeat(ReplyChannel<PlatformInboundInstruction> reply)
Handler ofPlatformInboundInstructionrequesting a heartbeat from this connector. The givenReplyChannelis used to send responding heartbeat message with.- Parameters:
reply- theReplyChannelto send a heartbeat reply message over
-
-