本文整理了Java中net.sf.ehcache.Ehcache.getName()
方法的一些代码示例,展示了Ehcache.getName()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ehcache.getName()
方法的具体详情如下:
包路径:net.sf.ehcache.Ehcache
类名称:Ehcache
方法名:getName
[英]Gets the cache name.
[中]获取缓存名称。
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* 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);
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* 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);
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* 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);
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* {@inheritDoc}
*/
public void removeAll() throws CacheException {
LOG.debug("cache {} removeAll", cache.getName());
List keys = getKeys();
for (Object key : keys) {
remove(key);
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* 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());
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* 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());
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* {@inheritDoc}
*/
public int getSize() {
LOG.debug("cache {} getSize", cache.getName());
XATransactionContext context = getOrCreateTransactionContext();
int size = underlyingStore.getSize();
return Math.max(0, size + context.getSizeModifier());
}
代码示例来源:origin: net.sf.ehcache/ehcache
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);
代码示例来源:origin: net.sf.ehcache/ehcache
@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;
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
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;
}
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
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);
代码示例来源:origin: net.sf.ehcache/ehcache
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;
}
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
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);
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* {@inheritDoc}
*/
public boolean containsKey(Object key) {
LOG.debug("cache {} containsKey", cache.getName(), key);
XATransactionContext context = getOrCreateTransactionContext();
return !context.isRemoved(key) && (context.getAddedKeys().contains(key) || underlyingStore.containsKey(key));
}
代码示例来源:origin: net.sf.ehcache/ehcache
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;
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* {@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;
}
代码示例来源:origin: net.sf.ehcache/ehcache
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) {
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* {@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));
}
代码示例来源:origin: net.sf.ehcache/ehcache
/**
* 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);
}
}
代码示例来源:origin: net.sf.ehcache/ehcache
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();
内容来源于网络,如有侵权,请联系作者删除!