Refine search
/** * Removes all cached items. * * @throws IllegalStateException if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE} */ public void removeAll() throws RemoteException, IllegalStateException { if (LOG.isDebugEnabled()) { LOG.debug("RMICachePeer for cache " + cache.getName() + ": remote removeAll received"); } cache.removeAll(true); }
/** * Removes an Element from the underlying cache without notifying listeners or updating statistics. * * @param key * @return true if the element was removed, false if it was not found in the cache * @throws RemoteException * @throws IllegalStateException */ public boolean remove(Serializable key) throws RemoteException, IllegalStateException { if (LOG.isDebugEnabled()) { LOG.debug("RMICachePeer for cache " + cache.getName() + ": remote remove received for key: " + key); } return cache.remove(key, true); }
/** * Puts an Element into the underlying cache without notifying listeners or updating statistics. * * @param element * @throws java.rmi.RemoteException * @throws IllegalArgumentException * @throws IllegalStateException */ public void put(Element element) throws RemoteException, IllegalArgumentException, IllegalStateException { cache.put(element, true); if (LOG.isDebugEnabled()) { LOG.debug("RMICachePeer for cache " + cache.getName() + ": remote put received. Element is: " + element); } }
/** * Puts the element in the DiskStore. * Should only be called if isOverflowToDisk is true * <p> * Relies on being called from a synchronized method * * @param element The Element */ protected void spoolToDisk(Element element) { diskStore.put(element); if (LOG.isDebugEnabled()) { LOG.debug(cache.getName() + "Cache: spool to disk done for: " + element.getObjectKey()); } }
/** * Performs bootstrap loading. May be executed on a independent thread. */ protected void doLoad(Ehcache cache) { int loadedElements = 0; final Iterator iterator = cache.getKeys().iterator(); while (iterator.hasNext() && !isInMemoryLimitReached(cache, loadedElements)) { if (cache.get(iterator.next()) != null) { ++loadedElements; } } LOG.debug("Loaded {} elements from disk into heap for cache {}", loadedElements, cache.getName()); }
null : defaultCacheConfiguration.getCacheDecoratorConfigurations(); if (defaultCacheDecoratorConfigurations == null || defaultCacheDecoratorConfigurations.size() == 0) { LOG.debug("CacheDecoratorFactory not configured for defaultCache. Skipping for '" + cache.getName() + "'."); return Collections.emptyList(); Ehcache decoratedCache = createDecoratedCache(cache, factoryConfiguration, true, loader); if (decoratedCache != null) { if (newCacheNames.contains(decoratedCache.getName())) { throw new InvalidConfigurationException( "Looks like the defaultCache is configured with multiple CacheDecoratorFactory's " + "CacheDecoratorFactory and/or the config to set unique names for newly created caches."); newCacheNames.add(decoratedCache.getName()); result.add(decoratedCache);
@Override public Element remove(Object key) { if (key == null) { return null; } String pKey = generatePortableKeyFor(key); Serializable value = backend.remove(pKey); Element element = this.valueModeHandler.createElement(key, value); if (keyLookupCache != null) { keyLookupCache.remove(key); } if (element != null) { return element; } else { if (LOG.isDebugEnabled()) { LOG.debug(cache.getName() + " Cache: Cannot remove entry as key " + key + " was not found"); } return null; } }
private Element getQuietFromUnderlyingStore(final Object key) { while (true) { long timeLeft = assertNotTimedOut(); LOG.debug("cache {} underlying.getQuiet key {} not timed out, time left: " + timeLeft, cache.getName(), key); Element element = underlyingStore.getQuiet(key); if (element == null) { return null; } Object value = element.getObjectValue(); if (value instanceof SoftLockID) { SoftLockID softLockId = (SoftLockID) value; SoftLock softLock = softLockManager.findSoftLockById(softLockId); if (softLock == null) { LOG.debug("cache {} underlying.getQuiet key {} soft lock died, retrying...", cache.getName(), key); continue; } else { try { LOG.debug("cache {} key {} soft locked, awaiting unlock...", cache.getName(), key); if (softLock.tryLock(timeLeft)) { softLock.clearTryLock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } else { return element; } } }
String rmiUrlCacheName = extractCacheName(rmiUrl); try { if (!rmiUrlCacheName.equals(cache.getName())) { continue; } else { LOG.debug("rmiUrl is stale. Either the remote peer is shutdown or the " + "network connectivity has been interrupted. Will be removed from list of remote cache peers", rmiUrl);
private Element getFromUnderlyingStore(final Object key) { while (true) { long timeLeft = assertNotTimedOut(); LOG.debug("cache {} underlying.get key {} not timed out, time left: " + timeLeft, cache.getName(), key); Element element = underlyingStore.get(key); if (element == null) { return null; } Object value = element.getObjectValue(); if (value instanceof SoftLockID) { SoftLockID softLockId = (SoftLockID) value; SoftLock softLock = softLockManager.findSoftLockById(softLockId); if (softLock == null) { LOG.debug("cache {} underlying.get key {} soft lock died, retrying...", cache.getName(), key); continue; } else { try { LOG.debug("cache {} key {} soft locked, awaiting unlock...", cache.getName(), key); if (softLock.tryLock(timeLeft)) { softLock.clearTryLock(); } } catch (InterruptedException e) { Thread.currentThread().interrupt(); } } } else { return element; } } }
String rmiUrlCacheName = extractCacheName(rmiUrl); if (!rmiUrlCacheName.equals(cache.getName())) { continue; } catch (Exception e) { if (LOG.isDebugEnabled()) { LOG.debug("Looking up rmiUrl " + rmiUrl + " through exception " + e.getMessage() + ". This may be normal if a node has gone offline. Or it may indicate network connectivity" + " difficulties", e); LOG.debug("rmiUrl {} should never be stale for a manually configured cluster.", rmiUrl); staleList.add(rmiUrl);
LOG.debug("Attempting to acquire cache peers for cache " + cache.getName() + " to bootstrap from. Will wait up to " + timeForClusterToForm + "ms for cache to join cluster."); Thread.sleep(ONE_SECOND); } catch (InterruptedException e) { LOG.debug("doLoad for " + cache.getName() + " interrupted."); LOG.debug("cache peers: {}", cachePeers); return cachePeers;
/** * {@inheritDoc} */ public final Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException { if (key == null) { return null; } // remove single item. Element element; final ReentrantReadWriteLock.WriteLock writeLock = map.lockFor(key).writeLock(); writeLock.lock(); try { element = map.remove(key); if (writerManager != null) { writerManager.remove(new CacheEntry(key, element)); } } finally { writeLock.unlock(); } if (element == null && LOG.isDebugEnabled()) { LOG.debug(cache.getName() + "Cache: Cannot remove entry as key " + key + " was not found"); } return element; }
LOG.debug("Empty list of cache peers for cache " + cache.getName() + ". No cache peer to bootstrap from."); return; int randomPeerNumber = random.nextInt(cachePeers.size()); CachePeer cachePeer = (CachePeer) cachePeers.get(randomPeerNumber); LOG.debug("Bootstrapping " + cache.getName() + " from " + cachePeer); LOG.debug("All cache peer elements were either null or empty. Nothing to bootstrap from. Cache was " + cache.getName() + ". Cache peer was " + cachePeer); return; LOG.debug("Bootstrap of " + cache.getName() + " from " + cachePeer + " finished. " + keys.size() + " keys requested."); } catch (Throwable t) {
/** * {@inheritDoc} */ public Element remove(Object key) { LOG.debug("cache {} remove {}", cache.getName(), key); // this forces enlistment so the XA transaction timeout can be propagated to the XA resource getOrCreateTransactionContext(); Element oldElement = getQuietFromUnderlyingStore(key); return removeInternal(new StoreRemoveCommand(key, oldElement)); }
/** * Remove the cache and make it unuseable. * <p> * * @throws CacheException */ public final void destroy() throws CacheException { try { cache.getCacheManager().removeCache(cache.getName()); } catch (IllegalStateException e) { //When Spring and Hibernate are both involved this will happen in normal shutdown operation. //Do not throw an exception, simply log this one. LOG.debug("This can happen if multiple frameworks both try to shutdown ehcache", e); } catch (net.sf.ehcache.CacheException e) { throw new CacheException(e); } }
LOG.debug("recover [{}]", prettyPrintXAResourceFlags(flags)); Thread t = new Thread("ehcache [" + cache.getName() + "] XA recovery thread") { @Override public void run() { Exception exception = new Exception("thread dump"); exception.setStackTrace(t.getStackTrace()); LOG.debug("XA recovery thread was interrupted after timeout", exception); t.interrupt();