/** * 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; } addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.REMOVE_ALL, null, null)); }
/** * RemoteDebugger method for the replicationQueue thread. * <p> * Note that the replicationQueue thread locks the cache for the entire time it is writing elements to the disk. */ private void replicationThreadMain() { while (true) { // Wait for elements in the replicationQueue while (alive() && replicationQueue != null && replicationQueue.isEmpty()) { try { Thread.sleep(replicationInterval); } catch (InterruptedException e) { LOG.debug("Spool Thread interrupted."); return; } } if (notAlive()) { return; } try { writeReplicationQueue(); } catch (Throwable e) { LOG.error("Exception on flushing of replication queue: " + e.getMessage() + ". Continuing...", e); } } }
List<EventMessage> eventMessages = extractEventMessages(maximumBatchSize); for (CachePeer cachePeer : listRemoteCachePeers(eventMessages.get(0).getEhcache())) { try { cachePeer.send(eventMessages);
/** * Give the replicator a chance to flush the replication queue, then cleanup and free resources when no longer needed */ public final void dispose() { status = Status.STATUS_SHUTDOWN; flushReplicationQueue(); }
private void flushReplicationQueue() { while (!replicationQueue.isEmpty()) { writeReplicationQueue(); } }
List<EventMessage> eventMessages = extractEventMessages(maximumBatchSize); for (CachePeer cachePeer : listRemoteCachePeers(eventMessages.get(0).getEhcache())) { try { cachePeer.send(eventMessages);
/** * Give the replicator a chance to flush the replication queue, then cleanup and free resources when no longer needed */ public final void dispose() { status = Status.STATUS_SHUTDOWN; flushReplicationQueue(); }
private void flushReplicationQueue() { while (!replicationQueue.isEmpty()) { writeReplicationQueue(); } }
/** * 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. */ public final 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; } addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.REMOVE, element.getKey(), null)); }
/** * RemoteDebugger method for the replicationQueue thread. * <p/> * Note that the replicationQueue thread locks the cache for the entire time it is writing elements to the disk. */ private void replicationThreadMain() { while (true) { // Wait for elements in the replicationQueue while (alive() && replicationQueue != null && replicationQueue.isEmpty()) { try { Thread.sleep(replicationInterval); } catch (InterruptedException e) { LOG.debug("Spool Thread interrupted."); return; } } if (notAlive()) { return; } try { writeReplicationQueue(); } catch (Throwable e) { LOG.error("Exception on flushing of replication queue: " + e.getMessage() + ". Continuing...", e); } } }
return new RMIAsynchronousCacheReplicator( replicatePuts, replicatePutsViaCopy,
List<EventMessage> eventMessages = extractEventMessages(maximumBatchSize); for (CachePeer cachePeer : listRemoteCachePeers(eventMessages.get(0).getEhcache())) { try { cachePeer.send(eventMessages);
/** * Give the replicator a chance to flush the replication queue, then cleanup and free resources when no longer needed */ public final void dispose() { status = Status.STATUS_SHUTDOWN; flushReplicationQueue(); }
private void flushReplicationQueue() { while (!replicationQueue.isEmpty()) { writeReplicationQueue(); } }
if (notAlive()) { return; addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.PUT, null, element)); } else { if (!element.isKeySerializable()) { addToReplicationQueue(new RmiEventMessage(cache, RmiEventType.REMOVE, element.getKey(), null));
/** * RemoteDebugger method for the replicationQueue thread. * <p> * Note that the replicationQueue thread locks the cache for the entire time it is writing elements to the disk. */ private void replicationThreadMain() { while (true) { // Wait for elements in the replicationQueue while (alive() && replicationQueue != null && replicationQueue.isEmpty()) { try { Thread.sleep(replicationInterval); } catch (InterruptedException e) { LOG.debug("Spool Thread interrupted."); return; } } if (notAlive()) { return; } try { writeReplicationQueue(); } catch (Throwable e) { LOG.error("Exception on flushing of replication queue: " + e.getMessage() + ". Continuing...", e); } } }
/** * 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); }
List<EventMessage> eventMessages = extractEventMessages(maximumBatchSize); for (CachePeer cachePeer : listRemoteCachePeers(eventMessages.get(0).getEhcache())) { try { cachePeer.send(eventMessages);
/** * Give the replicator a chance to flush the replication queue, then cleanup and free resources when no longer needed */ public final void dispose() { status = Status.STATUS_SHUTDOWN; flushReplicationQueue(); }