Top Description Inners Fields Constructors Methods
net.sf.ehcache.distribution

public final Class MulticastRMICacheManagerPeerProvider

extends RMICacheManagerPeerProvider
implements CacheManagerPeerProvider
Class Inheritance
All Implemented Interfaces
net.sf.ehcache.distribution.CacheManagerPeerProvider
Imports
net.sf.ehcache.CacheException, .CacheManager, .Ehcache, java.io.IOException, java.net.InetAddress, java.rmi.NotBoundException, java.util.ArrayList, .Date, .Iterator, .List, org.slf4j.Logger, .LoggerFactory

A peer provider which discovers peers using Multicast.

Hosts can be in three different levels of conformance with the Multicast specification (RFC1112), according to the requirements they meet.

  1. Level 0 is the "no support for IP Multicasting" level. Lots of hosts and routers in the Internet are in this state, as multicast support is not mandatory in IPv4 (it is, however, in IPv6). Not too much explanation is needed here: hosts in this level can neither send nor receive multicast packets. They must ignore the ones sent by other multicast capable hosts.
  2. Level 1 is the "support for sending but not receiving multicast IP datagrams" level. Thus, note that it is not necessary to join a multicast group to be able to send datagrams to it. Very few additions are needed in the IP module to make a "Level 0" host "Level 1-compliant".
  3. Level 2 is the "full support for IP multicasting" level. Level 2 hosts must be able to both send and receive multicast traffic. They must know the way to join and leave multicast groups and to propagate this information to multicast routers. Thus, they must include an Internet Group Management Protocol (IGMP) implementation in their TCP/IP stack.

The list of CachePeers is maintained via heartbeats. rmiUrls are looked up using RMI and converted to CachePeers on registration. On lookup any stale references are removed.

Author
Greg Luck
Version
$Id: MulticastRMICacheManagerPeerProvider.java 10789 2018-04-26 02:08:13Z adahanne $

Nested and Inner Type Summary

Modifier and TypeClass and Description
protected static class
MulticastRMICacheManagerPeerProvider.CachePeerEntry

Entry containing a looked up CachePeer and date

Field Summary

Modifier and TypeField and Description
private final MulticastKeepaliveHeartbeatReceiver
private final MulticastKeepaliveHeartbeatSender
private static final Logger
protected static final int
SHORT_DELAY

One tenth of a second, in ms

Inherited from net.sf.ehcache.distribution.RMICacheManagerPeerProvider:
cacheManagerpeerUrls

Constructor Summary

AccessConstructor and Description
public
MulticastRMICacheManagerPeerProvider(CacheManager cacheManager, InetAddress
224.0.0.1 to 239.255.255.255 e.g. 230.0.0.1
groupMulticastAddress
,
Integer
1025 to 65536 e.g. 4446
groupMulticastPort
,
Integer timeToLive, InetAddress
the address of the interface to use for sending and receiving multicast. May be null.
hostAddress
)

Creates and starts a multicast peer provider

Method Summary

Modifier and TypeMethod and Description
public final void
public MulticastKeepaliveHeartbeatReceiver

Returns:

the MulticastKeepaliveHeartbeatReceiver
getHeartBeatReceiver
()

public MulticastKeepaliveHeartbeatSender

Returns:

the MulticastKeepaliveHeartbeatSender
getHeartBeatSender
()

protected long
getStaleTime()

The time after which an unrefreshed peer provider entry is considered stale.

public long

Returns:

the time in ms, for a cluster to form
getTimeForClusterToForm
()

Implements net.sf.ehcache.distribution.CacheManagerPeerProvider.getTimeForClusterToForm.

Time for a cluster to form.
public final void
init()

Implements abstract net.sf.ehcache.distribution.RMICacheManagerPeerProvider.init.

Implements net.sf.ehcache.distribution.CacheManagerPeerProvider.init.

Notifies providers to initialise themselves.
public final synchronized List<E>
public final void
registerPeer(String rmiUrl)

Implements abstract net.sf.ehcache.distribution.RMICacheManagerPeerProvider.registerPeer.

Implements net.sf.ehcache.distribution.CacheManagerPeerProvider.registerPeer.

Register a new peer, but only if the peer is new, otherwise the last seen timestamp is updated.
protected final boolean

Returns:

true if stale
stale
(Date
the date the entry was created
date
)

Implements abstract net.sf.ehcache.distribution.RMICacheManagerPeerProvider.stale.

Whether the entry should be considered stale.
Inherited from net.sf.ehcache.distribution.RMICacheManagerPeerProvider:
extractCacheNamegetCacheManagergetSchemelookupRemoteCachePeerunregisterPeer

Field Detail

heartBeatReceiverback to summary
private final MulticastKeepaliveHeartbeatReceiver heartBeatReceiver
heartBeatSenderback to summary
private final MulticastKeepaliveHeartbeatSender heartBeatSender
LOGback to summary
private static final Logger LOG

Hides net.sf.ehcache.distribution.RMICacheManagerPeerProvider.LOG.

SHORT_DELAYback to summary
protected static final int SHORT_DELAY

One tenth of a second, in ms

Constructor Detail

MulticastRMICacheManagerPeerProviderback to summary
public MulticastRMICacheManagerPeerProvider(CacheManager cacheManager, InetAddress groupMulticastAddress, Integer groupMulticastPort, Integer timeToLive, InetAddress hostAddress)

Creates and starts a multicast peer provider

Parameters
groupMulticastAddress:InetAddress

224.0.0.1 to 239.255.255.255 e.g. 230.0.0.1

groupMulticastPort:Integer

1025 to 65536 e.g. 4446

hostAddress:InetAddress

the address of the interface to use for sending and receiving multicast. May be null.

Method Detail

disposeback to summary
public final void dispose()

Overrides net.sf.ehcache.distribution.RMICacheManagerPeerProvider.dispose.

Implements net.sf.ehcache.distribution.CacheManagerPeerProvider.dispose.

Shutdown the heartbeat

getHeartBeatReceiverback to summary
public MulticastKeepaliveHeartbeatReceiver getHeartBeatReceiver()
Returns:MulticastKeepaliveHeartbeatReceiver

the MulticastKeepaliveHeartbeatReceiver

getHeartBeatSenderback to summary
public MulticastKeepaliveHeartbeatSender getHeartBeatSender()
Returns:MulticastKeepaliveHeartbeatSender

the MulticastKeepaliveHeartbeatSender

getStaleTimeback to summary
protected long getStaleTime()

The time after which an unrefreshed peer provider entry is considered stale.

getTimeForClusterToFormback to summary
public long getTimeForClusterToForm()

Implements net.sf.ehcache.distribution.CacheManagerPeerProvider.getTimeForClusterToForm.

Time for a cluster to form. This varies considerably, depending on the implementation.

Returns:long

the time in ms, for a cluster to form

initback to summary
public final void init() throws CacheException

Implements abstract net.sf.ehcache.distribution.RMICacheManagerPeerProvider.init.

Implements net.sf.ehcache.distribution.CacheManagerPeerProvider.init.

Doc from net.sf.ehcache.distribution.CacheManagerPeerProvider.init.

Notifies providers to initialise themselves.

listRemoteCachePeersback to summary
public final synchronized List<E> listRemoteCachePeers(Ehcache cache) throws CacheException

Implements abstract net.sf.ehcache.distribution.RMICacheManagerPeerProvider.listRemoteCachePeers.

Implements net.sf.ehcache.distribution.CacheManagerPeerProvider.listRemoteCachePeers.

Returns:List<E>

a list of CachePeer peers, excluding the local peer.

registerPeerback to summary
public final void registerPeer(String rmiUrl)

Implements abstract net.sf.ehcache.distribution.RMICacheManagerPeerProvider.registerPeer.

Implements net.sf.ehcache.distribution.CacheManagerPeerProvider.registerPeer.

Register a new peer, but only if the peer is new, otherwise the last seen timestamp is updated.

This method is thread-safe. It relies on peerUrls being a synchronizedMap

staleback to summary
protected final boolean stale(Date date)

Implements abstract net.sf.ehcache.distribution.RMICacheManagerPeerProvider.stale.

Whether the entry should be considered stale. This will depend on the type of RMICacheManagerPeerProvider. This method should be overridden for implementations that go stale based on date

Parameters
date:Date

the date the entry was created

Returns:boolean

true if stale

net.sf.ehcache.distribution back to summary

protected final Class MulticastRMICacheManagerPeerProvider.CachePeerEntry

extends Object
Class Inheritance
  • java.lang.Object
  • net.sf.ehcache.distribution.MulticastRMICacheManagerPeerProvider.CachePeerEntry

Entry containing a looked up CachePeer and date

Field Summary

Modifier and TypeField and Description
private final CachePeer
private Date

Constructor Summary

AccessConstructor and Description
public
CachePeerEntry(CachePeer
the cache peer part of this entry
cachePeer
,
Date
the date part of this entry
date
)

Constructor

Method Summary

Modifier and TypeMethod and Description
public final CachePeer

Returns:

the cache peer part of this entry
getCachePeer
()

public final Date

Returns:

the date part of this entry
getDate
()

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

cachePeerback to summary
private final CachePeer cachePeer
dateback to summary
private Date date

Constructor Detail

CachePeerEntryback to summary
public CachePeerEntry(CachePeer cachePeer, Date date)

Constructor

Parameters
cachePeer:CachePeer

the cache peer part of this entry

date:Date

the date part of this entry

Method Detail

getCachePeerback to summary
public final CachePeer getCachePeer()
Returns:CachePeer

the cache peer part of this entry

getDateback to summary
public final Date getDate()
Returns:Date

the date part of this entry