Package net.sf.ehcache.distribution
Class MulticastKeepaliveHeartbeatSender
- java.lang.Object
-
- net.sf.ehcache.distribution.MulticastKeepaliveHeartbeatSender
-
public final class MulticastKeepaliveHeartbeatSender extends java.lang.ObjectSends heartbeats to a multicast group containing a compressed list of URLs.You can control how far the multicast packets propagate by setting the badly misnamed "TTL". Using the multicast IP protocol, the TTL value indicates the scope or range in which a packet may be forwarded. By convention:
- 0 is restricted to the same host
- 1 is restricted to the same subnet
- 32 is restricted to the same site
- 64 is restricted to the same region
- 128 is restricted to the same continent
- 255 is unrestricted
- Version:
- $Id$
- Author:
- Greg Luck
-
-
Constructor Summary
Constructors Constructor Description MulticastKeepaliveHeartbeatSender(CacheManager cacheManager, java.net.InetAddress multicastAddress, java.lang.Integer multicastPort, java.lang.Integer timeToLive, java.net.InetAddress hostAddress)Constructor.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voiddispose()Shutdown this heartbeat senderstatic longgetHeartBeatInterval()Returns the heartbeat interval.static longgetHeartBeatStaleTime()Returns the time after which a heartbeat is considered stale.java.lang.IntegergetTimeToLive()voidinit()Start the heartbeat threadstatic voidsetHeartBeatInterval(long heartBeatInterval)Sets the heartbeat interval to something other than the default of 5000ms.static voidsetHeartBeatStaleTime(long heartBeatStaleTime)Sets the heartbeat stale time to something other than the default of((2 * HeartBeatInterval) + 100)ms.
-
-
-
Constructor Detail
-
MulticastKeepaliveHeartbeatSender
public MulticastKeepaliveHeartbeatSender(CacheManager cacheManager, java.net.InetAddress multicastAddress, java.lang.Integer multicastPort, java.lang.Integer timeToLive, java.net.InetAddress hostAddress)
Constructor.- Parameters:
cacheManager- the bound CacheManager. Each CacheManager has a maximum of one sendermulticastAddress-multicastPort-timeToLive- See class description for the meaning of this parameter.
-
-
Method Detail
-
init
public final void init()
Start the heartbeat thread
-
dispose
public final void dispose()
Shutdown this heartbeat sender
-
setHeartBeatInterval
public static void setHeartBeatInterval(long heartBeatInterval)
Sets the heartbeat interval to something other than the default of 5000ms. This is useful for testing, but not recommended for production. This method is static and so affects the heartbeat interval of all senders. The change takes effect after the next scheduled heartbeat.- Parameters:
heartBeatInterval- a time in ms, greater than 1000
-
setHeartBeatStaleTime
public static void setHeartBeatStaleTime(long heartBeatStaleTime)
Sets the heartbeat stale time to something other than the default of((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.- Parameters:
heartBeatStaleTime- a time in ms
-
getHeartBeatInterval
public static long getHeartBeatInterval()
Returns the heartbeat interval.
-
getHeartBeatStaleTime
public static long getHeartBeatStaleTime()
Returns the time after which a heartbeat is considered stale.
-
getTimeToLive
public java.lang.Integer getTimeToLive()
- Returns:
- the TTL
-
-