public class RMISynchronousCacheReplicator extends Object implements CacheReplicator
Modifier and Type | Field and Description |
---|---|
protected boolean |
replicatePuts
Whether to replicate puts.
|
protected boolean |
replicatePutsViaCopy
Whether a put should replicated by copy or by invalidation, (a remove).
|
protected boolean |
replicateRemovals
Whether to replicate removes
|
protected boolean |
replicateUpdates
Whether to replicate updates.
|
protected boolean |
replicateUpdatesViaCopy
Whether an update (a put) should be by copy or by invalidation, (a remove).
|
protected Status |
status
The status of the replicator.
|
Constructor and Description |
---|
RMISynchronousCacheReplicator(boolean replicatePuts,
boolean replicatePutsViaCopy,
boolean replicateUpdates,
boolean replicateUpdatesViaCopy,
boolean replicateRemovals)
Constructor for internal and subclass use
|
Modifier and Type | Method and Description |
---|---|
boolean |
alive()
Checks that the replicator is is
STATUS_ALIVE . |
Object |
clone()
Creates a clone of this listener.
|
void |
dispose()
Give the replicator a chance to cleanup and free resources when no longer needed
|
boolean |
isReplicateUpdatesViaCopy()
Returns whether update is through copy or invalidate
|
boolean |
notAlive()
Asserts that the replicator is active.
|
void |
notifyElementEvicted(Ehcache cache,
Element element)
Called immediately after an element is evicted from the cache.
|
void |
notifyElementExpired(Ehcache cache,
Element element)
Called immediately after an element is found to be expired.
|
void |
notifyElementPut(Ehcache cache,
Element element)
Called immediately after an element has been put into the cache.
|
void |
notifyElementRemoved(Ehcache cache,
Element element)
Called immediately after an attempt to remove an element.
|
void |
notifyElementUpdated(Ehcache cache,
Element element)
Called immediately after an element has been put into the cache and the element already
existed in the cache.
|
void |
notifyRemoveAll(Ehcache cache)
Called during
Ehcache.removeAll() to indicate that the all
elements have been removed from the cache in a bulk operation. |
protected static void |
replicatePutNotification(Ehcache cache,
Element element)
Does the actual RMI remote call.
|
protected static void |
replicateRemovalNotification(Ehcache cache,
Serializable key)
Does the actual RMI remote call.
|
protected void |
replicateRemoveAllNotification(Ehcache cache)
Does the actual RMI remote call.
|
protected Status status
STATUS_ALIVE
protected final boolean replicatePuts
protected boolean replicatePutsViaCopy
#replicateUpdates
is true.protected final boolean replicateUpdates
protected final boolean replicateUpdatesViaCopy
#replicateUpdates
is true.protected final boolean replicateRemovals
public RMISynchronousCacheReplicator(boolean replicatePuts, boolean replicatePutsViaCopy, boolean replicateUpdates, boolean replicateUpdatesViaCopy, boolean replicateRemovals)
replicatePuts
- replicateUpdates
- replicateUpdatesViaCopy
- replicateRemovals
- public void notifyElementPut(Ehcache cache, Element element) throws CacheException
Cache.put(net.sf.ehcache.Element)
method
will block until this method returns.
Implementers may wish to have access to the Element's fields, including value, so the element is provided.
Implementers should be careful not to modify the element. The effect of any modifications is undefined.notifyElementPut
in interface CacheEventListener
cache
- the cache emitting the notificationelement
- the element which was just put into the cache.CacheException
protected static void replicatePutNotification(Ehcache cache, Element element) throws RemoteCacheException
RemoteCacheException
public void notifyElementUpdated(Ehcache cache, Element element) throws CacheException
Cache.put(net.sf.ehcache.Element)
method
will block until this method returns.
Implementers may wish to have access to the Element's fields, including value, so the element is provided.
Implementers should be careful not to modify the element. The effect of any modifications is undefined.notifyElementUpdated
in interface CacheEventListener
cache
- the cache emitting the notificationelement
- the element which was just put into the cache.CacheException
public void notifyElementRemoved(Ehcache cache, Element element) throws CacheException
notifyElementRemoved
in interface CacheEventListener
cache
- the cache emitting the notificationelement
- the element just deleted, or a synthetic element with just the key set if
no element was removed.param element just deletedCacheException
protected static void replicateRemovalNotification(Ehcache cache, Serializable key) throws RemoteCacheException
RemoteCacheException
public final void notifyElementExpired(Ehcache cache, Element element)
Cache.remove(Object)
method will block until this method returns.
Elements are checked for expiry in ehcache at the following times:
Cache.DEFAULT_EXPIRY_THREAD_INTERVAL_SECONDS
notifyElementExpired
in interface CacheEventListener
cache
- the cache emitting the notificationelement
- the element that has just expired
Deadlock Warning: expiry will often come from the DiskStore
expiry thread. It holds a lock to the DiskStorea the time the
notification is sent. If the implementation of this method calls into a
synchronized Cache
method and that subsequently calls into
DiskStore a deadlock will result. Accordingly implementers of this method
should not call back into Cache.public void notifyElementEvicted(Ehcache cache, Element element)
notifyElementEvicted
in interface CacheEventListener
cache
- the cache emitting the notificationelement
- the element that has just been evictedpublic void notifyRemoveAll(Ehcache cache)
Ehcache.removeAll()
to indicate that the all
elements have been removed from the cache in a bulk operation. The usual
notifyElementRemoved(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)
is not called.
This notification exists because clearing a cache is a special case. It is often
not practical to serially process notifications where potentially millions of elements
have been bulk deleted.notifyRemoveAll
in interface CacheEventListener
cache
- the cache emitting the notificationprotected void replicateRemoveAllNotification(Ehcache cache)
public final boolean isReplicateUpdatesViaCopy()
CacheReplicator
isReplicateUpdatesViaCopy
in interface CacheReplicator
public final boolean notAlive()
notAlive
in interface CacheReplicator
public final boolean alive()
STATUS_ALIVE
.alive
in interface CacheReplicator
STATUS_ALIVE
, else false.public void dispose()
dispose
in interface CacheEventListener
public Object clone() throws CloneNotSupportedException
clone
in interface CacheEventListener
clone
in class Object
CloneNotSupportedException
- if the listener could not be cloned.Copyright © 2003–2016 Terracotta, Inc.. All rights reserved.