public final class MulticastKeepaliveHeartbeatSender
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
private class |
MulticastKeepaliveHeartbeatSender.MulticastServerThread
A thread which sends a multicast heartbeat every second
|
Modifier and Type | Field and Description |
---|---|
private CacheManager |
cacheManager |
private static int |
DEFAULT_HEARTBEAT_INTERVAL |
private java.net.InetAddress |
groupMulticastAddress |
private java.lang.Integer |
groupMulticastPort |
private static long |
heartBeatInterval |
private static long |
heartBeatStaleTime |
private java.net.InetAddress |
hostAddress |
private static org.slf4j.Logger |
LOG |
private static int |
MAXIMUM_PEERS_PER_SEND |
private static int |
MINIMUM_HEARTBEAT_INTERVAL |
private static int |
ONE_HUNDRED_MS |
private MulticastKeepaliveHeartbeatSender.MulticastServerThread |
serverThread |
private boolean |
stopped |
private java.lang.Integer |
timeToLive |
Constructor and Description |
---|
MulticastKeepaliveHeartbeatSender(CacheManager cacheManager,
java.net.InetAddress multicastAddress,
java.lang.Integer multicastPort,
java.lang.Integer timeToLive,
java.net.InetAddress hostAddress)
Constructor.
|
Modifier and Type | Method and Description |
---|---|
void |
dispose()
Shutdown this heartbeat sender
|
static long |
getHeartBeatInterval()
Returns the heartbeat interval.
|
static long |
getHeartBeatStaleTime()
Returns the time after which a heartbeat is considered stale.
|
java.lang.Integer |
getTimeToLive() |
void |
init()
Start the heartbeat thread
|
static void |
setHeartBeatInterval(long heartBeatInterval)
Sets the heartbeat interval to something other than the default of 5000ms.
|
static void |
setHeartBeatStaleTime(long heartBeatStaleTime)
Sets the heartbeat stale time to something other than the default of
((2 * HeartBeatInterval) + 100)ms . |
private static final org.slf4j.Logger LOG
private static final int DEFAULT_HEARTBEAT_INTERVAL
private static final int MINIMUM_HEARTBEAT_INTERVAL
private static final int MAXIMUM_PEERS_PER_SEND
private static final int ONE_HUNDRED_MS
private static long heartBeatInterval
private static long heartBeatStaleTime
private final java.net.InetAddress groupMulticastAddress
private final java.lang.Integer groupMulticastPort
private final java.lang.Integer timeToLive
private MulticastKeepaliveHeartbeatSender.MulticastServerThread serverThread
private volatile boolean stopped
private final CacheManager cacheManager
private java.net.InetAddress hostAddress
public MulticastKeepaliveHeartbeatSender(CacheManager cacheManager, java.net.InetAddress multicastAddress, java.lang.Integer multicastPort, java.lang.Integer timeToLive, java.net.InetAddress hostAddress)
cacheManager
- the bound CacheManager. Each CacheManager has a maximum of one sendermulticastAddress
- multicastPort
- timeToLive
- See class description for the meaning of this parameter.public final void init()
public final void dispose()
public static void setHeartBeatInterval(long heartBeatInterval)
heartBeatInterval
- a time in ms, greater than 1000public static void setHeartBeatStaleTime(long heartBeatStaleTime)
((2 * HeartBeatInterval) + 100)ms
.
This is useful for testing, but not recommended for production. This method is static and so affects the stale
time all users.heartBeatStaleTime
- a time in mspublic static long getHeartBeatInterval()
public static long getHeartBeatStaleTime()
public java.lang.Integer getTimeToLive()