ehcache

net.sf.ehcache.distribution
Class MulticastKeepaliveHeartbeatSender

java.lang.Object
  extended by net.sf.ehcache.distribution.MulticastKeepaliveHeartbeatSender

public final class MulticastKeepaliveHeartbeatSender
extends Object

Sends 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:

You can also control how often the heartbeat sends by setting the interval.

Version:
$Id: MulticastKeepaliveHeartbeatSender.java 6489 2012-10-30 18:08:36Z cdennis $
Author:
Greg Luck

Constructor Summary
MulticastKeepaliveHeartbeatSender(CacheManager cacheManager, InetAddress multicastAddress, Integer multicastPort, Integer timeToLive, InetAddress hostAddress)
          Constructor.
 
Method Summary
 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.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MulticastKeepaliveHeartbeatSender

public MulticastKeepaliveHeartbeatSender(CacheManager cacheManager,
                                         InetAddress multicastAddress,
                                         Integer multicastPort,
                                         Integer timeToLive,
                                         InetAddress hostAddress)
Constructor.

Parameters:
cacheManager - the bound CacheManager. Each CacheManager has a maximum of one sender
multicastAddress -
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 Integer getTimeToLive()
Returns:
the TTL

ehcache

Copyright 2001-2014, Terracotta, Inc.