if (!isSerializable()) { return 0;
/** * Spools all elements to disk, in preparation for shutdown. * <p> * This revised implementation is a little slower but avoids using increased memory during the method. */ protected final void spoolAllToDisk() { boolean clearOnFlush = cache.getCacheConfiguration().isClearOnFlush(); for (Object key : getKeys()) { Element element = (Element) map.get(key); if (element != null) { if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and is not being overflowed to disk."); } } else { spoolToDisk(element); //Don't notify listeners. They are not being removed from the cache, only a store //Leave it in the memory store for performance if do not want to clear on flush if (clearOnFlush) { remove(key); } } } } }
/** * 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()); } }
if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey()
/** * Evict the <code>Element</code>. * <p> * Evict means that the <code>Element</code> is: * <ul> * <li>if, the store is diskPersistent, the <code>Element</code> is spooled to the DiskStore * <li>if not, the <code>Element</code> is removed. * </ul> * * @param element the <code>Element</code> to be evicted. */ protected final void evict(Element element) throws CacheException { if (cache.getCacheConfiguration().isOverflowToDisk()) { if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn(new StringBuilder("Object with key ").append(element.getObjectKey()) .append(" is not Serializable and cannot be overflowed to disk").toString()); } cache.getCacheEventNotificationService().notifyElementEvicted(copyStrategyHandler.copyElementForReadIfNeeded(element), false); } else { spoolToDisk(element); } } else { evictionObserver.begin(); evictionObserver.end(EvictionOutcome.SUCCESS); cache.getCacheEventNotificationService().notifyElementEvicted(copyStrategyHandler.copyElementForReadIfNeeded(element), false); } }
if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and cannot be replicated.");
if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and cannot be updated via copy.");
private void replicateViaCopy(final Ehcache cache, final Element element) { if (element.isSerializable()) { replicatePutNotification(cache, element); return; } if (!element.isKeySerializable()) { logUnserializableKey(element); } if (LOG.isWarnEnabled() && !(element.getObjectValue() instanceof Serializable)) { LOG.error("Value class {} is not Serializable => cannot be replicated", element.getObjectValue().getClass().getName()); } }
/** * Spools all elements to disk, in preparation for shutdown. <p/> Relies on being called from a synchronized method * <p/> This revised implementation is a little slower but avoids using increased memory during the method. */ protected final void spoolAllToDisk() { Object[] keys = getKeyArray(); for (int i = 0; i < keys.length; i++) { Element element = (Element) map.get(keys[i]); if (element != null) { if (!element.isSerializable()) { if (LOG.isDebugEnabled()) { LOG.debug("Object with key " + element.getObjectKey() + " is not Serializable and is not being overflowed to disk."); } } else { spoolToDisk(element); // Don't notify listeners. They are not being removed from the cache, only a store remove(keys[i]); } } } }
/** * Retrieve a payload from the cache for this key if one can be found. * * @param key the key for this cache element * @return the payload or null if none found */ private Object getCachePayload(String key, boolean quiet) { Object payload = null; Element e; if (quiet) { e = cache.getQuiet(key); } else { e = cache.get(key); } if (e != null) { // attempt to get the serialized value first if (e.isSerializable()) { payload = e.getValue(); } else { // not serializable so get the object value payload = e.getObjectValue(); } } return payload; }
/** * Evict the <code>Element</code>. <p/> Evict means that the <code>Element</code> is: * <ul> * <li>if, the store is diskPersistent, the <code>Element</code> is spooled to the DiskStore * <li>if not, the <code>Element</code> is removed. * </ul> * * @param element the <code>Element</code> to be evicted. */ protected final void evict(Element element) throws CacheException { boolean spooled = false; if (cache.isOverflowToDisk()) { if (!element.isSerializable()) { if (LOG.isDebugEnabled()) { LOG.debug(new StringBuffer("Object with key ").append(element.getObjectKey()) .append(" is not Serializable and cannot be overflowed to disk")); } } else { spoolToDisk(element); spooled = true; } } if (!spooled) { cache.getCacheEventNotificationService().notifyElementEvicted(element, false); } }
/** * Retrieve a payload from the cache for this key if one can be found. * @param key the key for this cache element * @return the payload or null if none found */ private Object getCachePayload(String key, boolean quiet) { Object payload = null; Element e; if (quiet) { e = cache.getQuiet(key); } else { e = cache.get(key); } if (e != null) { // attempt to get the serialized value first if (e.isSerializable()) { payload = e.getValue(); } else { // not serializable so get the object value payload = e.getObjectValue(); } } return payload; }
/** * Retrieve a payload from the cache for this key if one can be found. * @param key the key for this cache element * @return the payload or null if none found */ private Object getCachePayload(String key, boolean quiet) { Object payload = null; Element e; if (quiet) { e = cache.getQuiet(key); } else { e = cache.get(key); } if (e != null) { // attempt to get the serialized value first if (e.isSerializable()) { payload = e.getValue(); } else { // not serializable so get the object value payload = e.getObjectValue(); } } return payload; }
return; if (!element.isSerializable()) { LOG.warning("Object with key " + element.getObjectKey() + " is not Serializable and cannot be replicated"); return;
private void replicatePutNotification(Ehcache cache, Element element) { if (!element.isKeySerializable()) { LOG.warn("Key {} is not Serializable and cannot be replicated.", element.getObjectKey()); return; } if (!element.isSerializable()) { LOG.warn("Object with key {} is not Serializable and cannot be updated via copy", element.getObjectKey()); return; } JGroupEventMessage e = new JGroupEventMessage(JGroupEventMessage.PUT, (Serializable) element.getObjectKey(), element, cache.getName(), this.asynchronousReplicationInterval); sendNotification(cache, e); }
/** * Spools all elements to disk, in preparation for shutdown. * <p/> * This revised implementation is a little slower but avoids using increased memory during the method. */ protected final void spoolAllToDisk() { boolean clearOnFlush = cache.getCacheConfiguration().isClearOnFlush(); for (Object key : getKeys()) { Element element = (Element) map.get(key); if (element != null) { if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and is not being overflowed to disk."); } } else { spoolToDisk(element); //Don't notify listeners. They are not being removed from the cache, only a store //Leave it in the memory store for performance if do not want to clear on flush if (clearOnFlush) { remove(key); } } } } }
/** * Spools all elements to disk, in preparation for shutdown. * <p/> * This revised implementation is a little slower but avoids using increased memory during the method. */ protected final void spoolAllToDisk() { boolean clearOnFlush = cache.getCacheConfiguration().isClearOnFlush(); for (Object key : getKeys()) { Element element = (Element) map.get(key); if (element != null) { if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and is not being overflowed to disk."); } } else { spoolToDisk(element); //Don't notify listeners. They are not being removed from the cache, only a store //Leave it in the memory store for performance if do not want to clear on flush if (clearOnFlush) { remove(key); } } } } }
/** * Spools all elements to disk, in preparation for shutdown. * <p> * This revised implementation is a little slower but avoids using increased memory during the method. */ protected final void spoolAllToDisk() { boolean clearOnFlush = cache.getCacheConfiguration().isClearOnFlush(); for (Object key : getKeys()) { Element element = (Element) map.get(key); if (element != null) { if (!element.isSerializable()) { if (LOG.isWarnEnabled()) { LOG.warn("Object with key " + element.getObjectKey() + " is not Serializable and is not being overflowed to disk."); } } else { spoolToDisk(element); //Don't notify listeners. They are not being removed from the cache, only a store //Leave it in the memory store for performance if do not want to clear on flush if (clearOnFlush) { remove(key); } } } } }
/** * 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 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()); } }