I
- Type of the incoming heartbeat payloadO
- Type of the outgoing heartbeat payload@ThreadSafe public class HeartbeatManagerImpl<I,O> extends Object implements HeartbeatManager<I,O>
HeartbeatListener
about it. A heartbeat times out iff no heartbeat signal has been
received within a given timeout interval.Modifier and Type | Field and Description |
---|---|
protected org.slf4j.Logger |
log |
protected boolean |
stopped
Running state of the heartbeat manager.
|
Constructor and Description |
---|
HeartbeatManagerImpl(long heartbeatTimeoutIntervalMs,
ResourceID ownResourceID,
HeartbeatListener<I,O> heartbeatListener,
ScheduledExecutor mainThreadExecutor,
org.slf4j.Logger log) |
Modifier and Type | Method and Description |
---|---|
long |
getLastHeartbeatFrom(ResourceID resourceId)
Returns the last received heartbeat from the given target.
|
void |
monitorTarget(ResourceID resourceID,
HeartbeatTarget<O> heartbeatTarget)
Start monitoring a
HeartbeatTarget . |
void |
receiveHeartbeat(ResourceID heartbeatOrigin,
I heartbeatPayload)
Sends a heartbeat response to the target.
|
void |
requestHeartbeat(ResourceID requestOrigin,
I heartbeatPayload)
Requests a heartbeat from the target.
|
void |
stop()
Stops the heartbeat manager.
|
void |
unmonitorTarget(ResourceID resourceID)
Stops monitoring the heartbeat target with the associated resource ID.
|
protected final org.slf4j.Logger log
protected volatile boolean stopped
public HeartbeatManagerImpl(long heartbeatTimeoutIntervalMs, ResourceID ownResourceID, HeartbeatListener<I,O> heartbeatListener, ScheduledExecutor mainThreadExecutor, org.slf4j.Logger log)
public void monitorTarget(ResourceID resourceID, HeartbeatTarget<O> heartbeatTarget)
HeartbeatManager
HeartbeatTarget
. Heartbeat timeouts for this target are reported
to the HeartbeatListener
associated with this heartbeat manager.monitorTarget
in interface HeartbeatManager<I,O>
resourceID
- Resource ID identifying the heartbeat targetheartbeatTarget
- Interface to send heartbeat requests and responses to the heartbeat
targetpublic void unmonitorTarget(ResourceID resourceID)
HeartbeatManager
unmonitorTarget
in interface HeartbeatManager<I,O>
resourceID
- Resource ID of the heartbeat target which shall no longer be monitoredpublic void stop()
HeartbeatManager
stop
in interface HeartbeatManager<I,O>
public long getLastHeartbeatFrom(ResourceID resourceId)
HeartbeatManager
getLastHeartbeatFrom
in interface HeartbeatManager<I,O>
resourceId
- for which to return the last heartbeatpublic void receiveHeartbeat(ResourceID heartbeatOrigin, I heartbeatPayload)
HeartbeatTarget
receiveHeartbeat
in interface HeartbeatTarget<I>
heartbeatOrigin
- Resource ID identifying the machine for which a heartbeat shall be reported.heartbeatPayload
- Payload of the heartbeat. Null indicates an empty payload.public void requestHeartbeat(ResourceID requestOrigin, I heartbeatPayload)
HeartbeatTarget
requestHeartbeat
in interface HeartbeatTarget<I>
requestOrigin
- Resource ID identifying the machine issuing the heartbeat request.heartbeatPayload
- Payload of the heartbeat request. Null indicates an empty payload.Copyright © 2014–2020 The Apache Software Foundation. All rights reserved.