net.sf.ehcache.distribution.jgroups
Class JGroupsCacheReplicator

java.lang.Object
  extended by net.sf.ehcache.distribution.jgroups.JGroupsCacheReplicator
All Implemented Interfaces:
Cloneable, net.sf.ehcache.distribution.CacheReplicator, net.sf.ehcache.event.CacheEventListener

public class JGroupsCacheReplicator
extends Object
implements net.sf.ehcache.distribution.CacheReplicator

Version:
$Id$

This implements CacheReplicator using JGroups as underlying replication mechanism The peer provider should be of type JGroupsCacheManagerPeerProvider It is assumed that the cachepeer is a JGroupsCacheManagerPeerProvider

Author:
Pierre Monestie (pmonestie[at]@gmail.com), Greg Luck

Field Summary
static long DEFAULT_ASYNC_INTERVAL
          The default interval for async cache replication
 
Constructor Summary
JGroupsCacheReplicator(boolean replicatePuts, boolean replicateUpdates, boolean replicateUpdatesViaCopy, boolean replicateRemovals)
          Constructor called by factory, does synchronous replication
JGroupsCacheReplicator(boolean replicatePuts, boolean replicateUpdates, boolean replicateUpdatesViaCopy, boolean replicateRemovals, long asynchronousReplicationInterval)
          Constructor called by factory, does asynchronous replication
 
Method Summary
 boolean alive()
          
 Object clone()
          
 void dispose()
          
 boolean isReplicateUpdatesViaCopy()
          
 boolean notAlive()
          
 void notifyElementEvicted(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
          
 void notifyElementExpired(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
          
 void notifyElementPut(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
          
 void notifyElementRemoved(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
          
 void notifyElementUpdated(net.sf.ehcache.Ehcache cache, net.sf.ehcache.Element element)
          
 void notifyRemoveAll(net.sf.ehcache.Ehcache cache)
          
protected  void sendNotification(net.sf.ehcache.Ehcache cache, JGroupEventMessage eventMessage)
          Used to send notification to the peer.
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_ASYNC_INTERVAL

public static final long DEFAULT_ASYNC_INTERVAL
The default interval for async cache replication

See Also:
Constant Field Values
Constructor Detail

JGroupsCacheReplicator

public JGroupsCacheReplicator(boolean replicatePuts,
                              boolean replicateUpdates,
                              boolean replicateUpdatesViaCopy,
                              boolean replicateRemovals)
Constructor called by factory, does synchronous replication


JGroupsCacheReplicator

public JGroupsCacheReplicator(boolean replicatePuts,
                              boolean replicateUpdates,
                              boolean replicateUpdatesViaCopy,
                              boolean replicateRemovals,
                              long asynchronousReplicationInterval)
Constructor called by factory, does asynchronous replication

Method Detail

alive

public boolean alive()

Specified by:
alive in interface net.sf.ehcache.distribution.CacheReplicator

isReplicateUpdatesViaCopy

public boolean isReplicateUpdatesViaCopy()

Specified by:
isReplicateUpdatesViaCopy in interface net.sf.ehcache.distribution.CacheReplicator

notAlive

public boolean notAlive()

Specified by:
notAlive in interface net.sf.ehcache.distribution.CacheReplicator

dispose

public void dispose()

Specified by:
dispose in interface net.sf.ehcache.event.CacheEventListener

notifyElementExpired

public void notifyElementExpired(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)

Specified by:
notifyElementExpired in interface net.sf.ehcache.event.CacheEventListener

notifyElementPut

public void notifyElementPut(net.sf.ehcache.Ehcache cache,
                             net.sf.ehcache.Element element)
                      throws net.sf.ehcache.CacheException

Specified by:
notifyElementPut in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

notifyElementRemoved

public void notifyElementRemoved(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)
                          throws net.sf.ehcache.CacheException

Specified by:
notifyElementRemoved in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

notifyElementUpdated

public void notifyElementUpdated(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)
                          throws net.sf.ehcache.CacheException

Specified by:
notifyElementUpdated in interface net.sf.ehcache.event.CacheEventListener
Throws:
net.sf.ehcache.CacheException

notifyElementEvicted

public void notifyElementEvicted(net.sf.ehcache.Ehcache cache,
                                 net.sf.ehcache.Element element)

Specified by:
notifyElementEvicted in interface net.sf.ehcache.event.CacheEventListener

notifyRemoveAll

public void notifyRemoveAll(net.sf.ehcache.Ehcache cache)

Specified by:
notifyRemoveAll in interface net.sf.ehcache.event.CacheEventListener

sendNotification

protected void sendNotification(net.sf.ehcache.Ehcache cache,
                                JGroupEventMessage eventMessage)
Used to send notification to the peer. If Async this method simply add the element to the replication queue. If not async, searches for the cachePeer and send the Message. That way the class handles both async and sync replication Sending is delegated to the peer (of type JGroupsCacheManagerPeerProvider)

Parameters:
cache -
eventMessage -

clone

public Object clone()
             throws CloneNotSupportedException

Specified by:
clone in interface net.sf.ehcache.event.CacheEventListener
Overrides:
clone in class Object
Throws:
CloneNotSupportedException


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