net.sf.ehcache.distribution.jgroups
Class JGroupsCacheManagerPeerProvider

java.lang.Object
  extended by net.sf.ehcache.distribution.jgroups.JGroupsCacheManagerPeerProvider
All Implemented Interfaces:
net.sf.ehcache.distribution.CacheManagerPeerProvider, net.sf.ehcache.management.ManagedCacheManagerPeerProvider

public class JGroupsCacheManagerPeerProvider
extends Object
implements net.sf.ehcache.management.ManagedCacheManagerPeerProvider

The main Jgroup class for replication via JGroup. Starts up the Jgroup communication bus and listen for message in the bus. Because of Ehcache design we have to register this as a CachePeer. In reality this class listen for change on the bus and tells the cachemanager to update.

Version:
$Id: JGroupsCacheManagerPeerProvider.java 2608 2010-08-05 06:06:01Z gluck $
Author:
Pierre Monestie (pmonestie__REMOVE__THIS__@gmail.com), Greg Luck

Field Summary
static String SCHEME_NAME
          Constant that defines the value returned by getScheme()
 
Constructor Summary
JGroupsCacheManagerPeerProvider(net.sf.ehcache.CacheManager cacheManager, String properties)
          Construct a new JGroupsCacheManagerPeerProvider with a specific JGroups connection String
JGroupsCacheManagerPeerProvider(net.sf.ehcache.CacheManager cacheManager, URL configUrl)
          Construct a new JGroupsCacheManagerPeerProvider with a specific JGroups connection String
 
Method Summary
 void dispose()
          
 JGroupsBootstrapManager getBootstrapManager()
           
static JGroupsCacheManagerPeerProvider getCachePeerProvider(net.sf.ehcache.CacheManager cacheManager)
          Given an CacheManager get the corresponding instance of this class.
static JGroupsCacheManagerPeerProvider getCachePeerProvider(net.sf.ehcache.Ehcache cache)
          Given an Ehcache get the corresponding instance of this class.
 org.jgroups.JChannel getChannel()
           
 String getClusterName()
           
 String getScheme()
          The replication scheme.
 net.sf.ehcache.Status getStatus()
           
 long getTimeForClusterToForm()
          JGroups will be connected once init() returns and there is no per-cache connect time to worry about.
 void init()
          
 List<net.sf.ehcache.distribution.CachePeer> listRemoteCachePeers(net.sf.ehcache.Ehcache cache)
          
 void register(MBeanServer mBeanServer)
          
 void registerPeer(String rmiUrl)
          
 void setChannelName(String channelName)
          Set the name of the JChannel, if null the cache manager name is used.
 void unregisterPeer(String rmiUrl)
          
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SCHEME_NAME

public static final String SCHEME_NAME
Constant that defines the value returned by getScheme()

See Also:
Constant Field Values
Constructor Detail

JGroupsCacheManagerPeerProvider

public JGroupsCacheManagerPeerProvider(net.sf.ehcache.CacheManager cacheManager,
                                       String properties)
Construct a new JGroupsCacheManagerPeerProvider with a specific JGroups connection String

Parameters:
cacheManager - the cache manager
properties - the JGroups connection String

JGroupsCacheManagerPeerProvider

public JGroupsCacheManagerPeerProvider(net.sf.ehcache.CacheManager cacheManager,
                                       URL configUrl)
Construct a new JGroupsCacheManagerPeerProvider with a specific JGroups connection String

Parameters:
cacheManager - the cache manager
configUrl - the JGroups configuration file
Method Detail

setChannelName

public void setChannelName(String channelName)
Set the name of the JChannel, if null the cache manager name is used.


getCachePeerProvider

public static JGroupsCacheManagerPeerProvider getCachePeerProvider(net.sf.ehcache.Ehcache cache)
Given an Ehcache get the corresponding instance of this class.


getCachePeerProvider

public static JGroupsCacheManagerPeerProvider getCachePeerProvider(net.sf.ehcache.CacheManager cacheManager)
Given an CacheManager get the corresponding instance of this class.


init

public void init()

Specified by:
init in interface net.sf.ehcache.distribution.CacheManagerPeerProvider

register

public void register(MBeanServer mBeanServer)

Specified by:
register in interface net.sf.ehcache.management.ManagedCacheManagerPeerProvider

dispose

public void dispose()
             throws net.sf.ehcache.CacheException

Specified by:
dispose in interface net.sf.ehcache.distribution.CacheManagerPeerProvider
Throws:
net.sf.ehcache.CacheException

getTimeForClusterToForm

public long getTimeForClusterToForm()
JGroups will be connected once init() returns and there is no per-cache connect time to worry about.

Specified by:
getTimeForClusterToForm in interface net.sf.ehcache.distribution.CacheManagerPeerProvider

getScheme

public String getScheme()
The replication scheme. Each peer provider has a scheme name, which can be used to specify the scheme for replication and bootstrap purposes. Each CacheReplicator should lookup the provider for its scheme type during replication. Similarly a BootstrapCacheLoader should also look up the provider for its scheme.

Specified by:
getScheme in interface net.sf.ehcache.distribution.CacheManagerPeerProvider
Returns:
the well-known scheme name, which is determined by the replication provider author.
Since:
1.6 introduced to permit multiple distribution schemes to be used in the same CacheManager

listRemoteCachePeers

public List<net.sf.ehcache.distribution.CachePeer> listRemoteCachePeers(net.sf.ehcache.Ehcache cache)
                                                                 throws net.sf.ehcache.CacheException

Specified by:
listRemoteCachePeers in interface net.sf.ehcache.distribution.CacheManagerPeerProvider
Throws:
net.sf.ehcache.CacheException

registerPeer

public void registerPeer(String rmiUrl)

Specified by:
registerPeer in interface net.sf.ehcache.distribution.CacheManagerPeerProvider

unregisterPeer

public void unregisterPeer(String rmiUrl)

Specified by:
unregisterPeer in interface net.sf.ehcache.distribution.CacheManagerPeerProvider

getChannel

public org.jgroups.JChannel getChannel()
Returns:
The underlying JGroups JChannel

getBootstrapManager

public JGroupsBootstrapManager getBootstrapManager()
Returns:
the JGroupsBootstrapManager

getStatus

public net.sf.ehcache.Status getStatus()
Returns:
the Status of the manager

getClusterName

public String getClusterName()
Returns:
The cluster name for JMX registration


Copyright © 2003-2012 Terracotta, Inc.. All Rights Reserved.