/** * Creates a clone of this listener. This method will only be called by ehcache before a cache is initialized. * <p> * This may not be possible for listeners after they have been initialized. Implementations should throw * CloneNotSupportedException if they do not support clone. * * @return a clone * @throws CloneNotSupportedException if the listener could not be cloned. */ public Object clone() throws CloneNotSupportedException { //shutup checkstyle super.clone(); return new RMISynchronousCacheReplicator(replicatePuts, replicatePutsViaCopy, replicateUpdates, replicateUpdatesViaCopy, replicateRemovals); } }
/** * Asserts that the replicator is active. * * @return true if the status is not STATUS_ALIVE */ public final boolean notAlive() { return !alive(); }
/** * Creates a clone of this listener. This method will only be called by ehcache before a cache is initialized. * <p> * This may not be possible for listeners after they have been initialized. Implementations should throw * CloneNotSupportedException if they do not support clone. * * @return a clone * @throws CloneNotSupportedException if the listener could not be cloned. */ public Object clone() throws CloneNotSupportedException { //shutup checkstyle super.clone(); return new RMIAsynchronousCacheReplicator(replicatePuts, replicatePutsViaCopy, replicateUpdates, replicateUpdatesViaCopy, replicateRemovals, replicationInterval, maximumBatchSize); }
/** * Called during {@link net.sf.ehcache.Ehcache#removeAll()} to indicate that the all * elements have been removed from the cache in a bulk operation. The usual * {@link #notifyElementRemoved(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)} * is not called. * <p> * 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. * * @param cache the cache emitting the notification */ public void notifyRemoveAll(final Ehcache cache) { if (notAlive()) { return; } if (!replicateRemovals) { return; } replicateRemoveAllNotification(cache); }
/** * Called immediately after an element has been put into the cache. The {@link net.sf.ehcache.Cache#put(net.sf.ehcache.Element)} method * will block until this method returns. * <p> * 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. * * @param cache the cache emitting the notification * @param element the element which was just put into the cache. */ public void notifyElementPut(final Ehcache cache, final Element element) throws CacheException { if (notAlive()) { return; } if (!replicatePuts) { return; } if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and cannot be replicated"); } return; } if (replicatePutsViaCopy) { replicatePutNotification(cache, element); } else { replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); } }
/** * Called immediately after an attempt to remove an element. The remove method will block until * this method returns. * <p> * This notification is received regardless of whether the cache had an element matching * the removal key or not. If an element was removed, the element is passed to this method, * otherwise a synthetic element, with only the key set is passed in. * <p> * * @param cache the cache emitting the notification * @param element the element just deleted, or a synthetic element with just the key set if * no element was removed.param element just deleted */ public void notifyElementRemoved(final Ehcache cache, final Element element) throws CacheException { if (notAlive()) { return; } if (!replicateRemovals) { return; } if (!element.isKeySerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Key " + element.getObjectKey() + " is not Serializable and cannot be replicated."); } return; } replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); }
/** * Does the actual RMI remote call. * <p> * If a Throwable occurs a SEVERE log message will be logged, but attempts to replicate to the other * peers will continue. */ protected static void replicateRemovalNotification(Ehcache cache, Serializable key) throws RemoteCacheException { List cachePeers = listRemoteCachePeers(cache); for (Object cachePeer1 : cachePeers) { CachePeer cachePeer = (CachePeer) cachePeer1; try { cachePeer.remove(key); } catch (Throwable t) { LOG.error("Exception on replication of removeNotification. " + t.getMessage() + ". Continuing...", t); } } }
if (notAlive()) { return; replicatePutNotification(cache, element); } else { if (!element.isKeySerializable()) { replicateRemovalNotification(cache, (Serializable) element.getObjectKey());
/** * Called during {@link net.sf.ehcache.Ehcache#removeAll()} to indicate that the all * elements have been removed from the cache in a bulk operation. The usual * {@link #notifyElementRemoved(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)} * is not called. * <p> * 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. * * @param cache the cache emitting the notification */ public void notifyRemoveAll(final Ehcache cache) { if (notAlive()) { return; } if (!replicateRemovals) { return; } replicateRemoveAllNotification(cache); }
/** * Called immediately after an attempt to remove an element. The remove method will block until * this method returns. * <p/> * This notification is received regardless of whether the cache had an element matching * the removal key or not. If an element was removed, the element is passed to this method, * otherwise a synthetic element, with only the key set is passed in. * <p/> * * @param cache the cache emitting the notification * @param element the element just deleted, or a synthetic element with just the key set if * no element was removed.param element just deleted */ public void notifyElementRemoved(final Ehcache cache, final Element element) throws CacheException { if (notAlive()) { return; } if (!replicateRemovals) { return; } if (!element.isKeySerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Key " + element.getObjectKey() + " is not Serializable and cannot be replicated."); } return; } replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); }
/** * Does the actual RMI remote call. * <p> * If a Throwable occurs a SEVERE log message will be logged, but attempts to replicate to the other * peers will continue. */ protected static void replicatePutNotification(Ehcache cache, Element element) throws RemoteCacheException { List cachePeers = listRemoteCachePeers(cache); for (Object cachePeer1 : cachePeers) { CachePeer cachePeer = (CachePeer) cachePeer1; try { cachePeer.put(element); } catch (Throwable t) { LOG.error("Exception on replication of putNotification. " + t.getMessage() + ". Continuing...", t); } } }
/** * Called immediately after an element has been put into the cache. The {@link net.sf.ehcache.Cache#put(net.sf.ehcache.Element)} method * will block until this method returns. * <p> * 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. * * @param cache the cache emitting the notification * @param element the element which was just put into the cache. */ public void notifyElementPut(final Ehcache cache, final Element element) throws CacheException { if (notAlive()) { return; } if (!replicatePuts) { return; } if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and cannot be replicated"); } return; } if (replicatePutsViaCopy) { replicatePutNotification(cache, element); } else { replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); } }
/** * Called during {@link net.sf.ehcache.Ehcache#removeAll()} to indicate that the all * elements have been removed from the cache in a bulk operation. The usual * {@link #notifyElementRemoved(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)} * is not called. * <p/> * 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. * * @param cache the cache emitting the notification */ public void notifyRemoveAll(final Ehcache cache) { if (notAlive()) { return; } if (!replicateRemovals) { return; } replicateRemoveAllNotification(cache); }
/** * Called immediately after an attempt to remove an element. The remove method will block until * this method returns. * <p/> * This notification is received regardless of whether the cache had an element matching * the removal key or not. If an element was removed, the element is passed to this method, * otherwise a synthetic element, with only the key set is passed in. * <p/> * * @param cache the cache emitting the notification * @param element the element just deleted, or a synthetic element with just the key set if * no element was removed.param element just deleted */ public void notifyElementRemoved(final Ehcache cache, final Element element) throws CacheException { if (notAlive()) { return; } if (!replicateRemovals) { return; } if (!element.isKeySerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Key " + element.getObjectKey() + " is not Serializable and cannot be replicated."); } return; } replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); }
/** * Creates a clone of this listener. This method will only be called by ehcache before a cache is initialized. * <p/> * This may not be possible for listeners after they have been initialized. Implementations should throw * CloneNotSupportedException if they do not support clone. * * @return a clone * @throws CloneNotSupportedException if the listener could not be cloned. */ public Object clone() throws CloneNotSupportedException { //shutup checkstyle super.clone(); return new RMISynchronousCacheReplicator(replicatePuts, replicatePutsViaCopy, replicateUpdates, replicateUpdatesViaCopy, replicateRemovals); } }
/** * Does the actual RMI remote call. * * If a Throwable occurs a SEVERE log message will be logged, but attempts to replicate to the other * peers will continue. * */ protected void replicateRemoveAllNotification(Ehcache cache) { List cachePeers = listRemoteCachePeers(cache); for (Object cachePeer1 : cachePeers) { CachePeer cachePeer = (CachePeer) cachePeer1; try { cachePeer.removeAll(); } catch (Throwable t) { LOG.error("Exception on replication of removeAllNotification. " + t.getMessage() + ". Continuing...", t); } } }
/** * Asserts that the replicator is active. * * @return true if the status is not STATUS_ALIVE */ public final boolean notAlive() { return !alive(); }
/** * Creates a clone of this listener. This method will only be called by ehcache before a cache is initialized. * <p/> * This may not be possible for listeners after they have been initialized. Implementations should throw * CloneNotSupportedException if they do not support clone. * * @return a clone * @throws CloneNotSupportedException if the listener could not be cloned. */ public Object clone() throws CloneNotSupportedException { //shutup checkstyle super.clone(); return new RMIAsynchronousCacheReplicator(replicatePuts, replicatePutsViaCopy, replicateUpdates, replicateUpdatesViaCopy, replicateRemovals, replicationInterval, maximumBatchSize); }
/** * Called immediately after an element has been put into the cache. The {@link net.sf.ehcache.Cache#put(net.sf.ehcache.Element)} method * will block until this method returns. * <p/> * 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. * * @param cache the cache emitting the notification * @param element the element which was just put into the cache. */ public void notifyElementPut(final Ehcache cache, final Element element) throws CacheException { if (notAlive()) { return; } if (!replicatePuts) { return; } if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and cannot be replicated"); } return; } if (replicatePutsViaCopy) { replicatePutNotification(cache, element); } else { replicateRemovalNotification(cache, (Serializable) element.getObjectKey()); } }
/** * Called during {@link net.sf.ehcache.Ehcache#removeAll()} to indicate that the all * elements have been removed from the cache in a bulk operation. The usual * {@link #notifyElementRemoved(net.sf.ehcache.Ehcache,net.sf.ehcache.Element)} * is not called. * <p/> * 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. * * @param cache the cache emitting the notification */ public void notifyRemoveAll(final Ehcache cache) { if (notAlive()) { return; } if (!replicateRemovals) { return; } replicateRemoveAllNotification(cache); }