net.sf.ehcache.Ehcache.getName()方法的使用及代码示例

x33g5p2x  于2022-01-19 转载在 其他  
字(9.9k)|赞(0)|评价(0)|浏览(227)

本文整理了Java中net.sf.ehcache.Ehcache.getName()方法的一些代码示例,展示了Ehcache.getName()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Ehcache.getName()方法的具体详情如下:
包路径:net.sf.ehcache.Ehcache
类名称:Ehcache
方法名:getName

Ehcache.getName介绍

[英]Gets the cache name.
[中]获取缓存名称。

代码示例

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * Removes all cached items.
  3. *
  4. * @throws IllegalStateException if the cache is not {@link net.sf.ehcache.Status#STATUS_ALIVE}
  5. */
  6. public void removeAll() throws RemoteException, IllegalStateException {
  7. if (LOG.isDebugEnabled()) {
  8. LOG.debug("RMICachePeer for cache " + cache.getName() + ": remote removeAll received");
  9. }
  10. cache.removeAll(true);
  11. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * Removes an Element from the underlying cache without notifying listeners or updating statistics.
  3. *
  4. * @param key
  5. * @return true if the element was removed, false if it was not found in the cache
  6. * @throws RemoteException
  7. * @throws IllegalStateException
  8. */
  9. public boolean remove(Serializable key) throws RemoteException, IllegalStateException {
  10. if (LOG.isDebugEnabled()) {
  11. LOG.debug("RMICachePeer for cache " + cache.getName() + ": remote remove received for key: " + key);
  12. }
  13. return cache.remove(key, true);
  14. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * Puts an Element into the underlying cache without notifying listeners or updating statistics.
  3. *
  4. * @param element
  5. * @throws java.rmi.RemoteException
  6. * @throws IllegalArgumentException
  7. * @throws IllegalStateException
  8. */
  9. public void put(Element element) throws RemoteException, IllegalArgumentException, IllegalStateException {
  10. cache.put(element, true);
  11. if (LOG.isDebugEnabled()) {
  12. LOG.debug("RMICachePeer for cache " + cache.getName() + ": remote put received. Element is: " + element);
  13. }
  14. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public void removeAll() throws CacheException {
  5. LOG.debug("cache {} removeAll", cache.getName());
  6. List keys = getKeys();
  7. for (Object key : keys) {
  8. remove(key);
  9. }
  10. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * Puts the element in the DiskStore.
  3. * Should only be called if isOverflowToDisk is true
  4. * <p>
  5. * Relies on being called from a synchronized method
  6. *
  7. * @param element The Element
  8. */
  9. protected void spoolToDisk(Element element) {
  10. diskStore.put(element);
  11. if (LOG.isDebugEnabled()) {
  12. LOG.debug(cache.getName() + "Cache: spool to disk done for: " + element.getObjectKey());
  13. }
  14. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * Performs bootstrap loading. May be executed on a independent thread.
  3. */
  4. protected void doLoad(Ehcache cache) {
  5. int loadedElements = 0;
  6. final Iterator iterator = cache.getKeys().iterator();
  7. while (iterator.hasNext() && !isInMemoryLimitReached(cache, loadedElements)) {
  8. if (cache.get(iterator.next()) != null) {
  9. ++loadedElements;
  10. }
  11. }
  12. LOG.debug("Loaded {} elements from disk into heap for cache {}", loadedElements, cache.getName());
  13. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public int getSize() {
  5. LOG.debug("cache {} getSize", cache.getName());
  6. XATransactionContext context = getOrCreateTransactionContext();
  7. int size = underlyingStore.getSize();
  8. return Math.max(0, size + context.getSizeModifier());
  9. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. null : defaultCacheConfiguration.getCacheDecoratorConfigurations();
  2. if (defaultCacheDecoratorConfigurations == null || defaultCacheDecoratorConfigurations.size() == 0) {
  3. LOG.debug("CacheDecoratorFactory not configured for defaultCache. Skipping for '" + cache.getName() + "'.");
  4. return Collections.emptyList();
  5. Ehcache decoratedCache = createDecoratedCache(cache, factoryConfiguration, true, loader);
  6. if (decoratedCache != null) {
  7. if (newCacheNames.contains(decoratedCache.getName())) {
  8. throw new InvalidConfigurationException(
  9. "Looks like the defaultCache is configured with multiple CacheDecoratorFactory's "
  10. + "CacheDecoratorFactory and/or the config to set unique names for newly created caches.");
  11. newCacheNames.add(decoratedCache.getName());
  12. result.add(decoratedCache);

代码示例来源:origin: net.sf.ehcache/ehcache

  1. @Override
  2. public Element remove(Object key) {
  3. if (key == null) { return null; }
  4. String pKey = generatePortableKeyFor(key);
  5. Serializable value = backend.remove(pKey);
  6. Element element = this.valueModeHandler.createElement(key, value);
  7. if (keyLookupCache != null) {
  8. keyLookupCache.remove(key);
  9. }
  10. if (element != null) {
  11. return element;
  12. } else {
  13. if (LOG.isDebugEnabled()) {
  14. LOG.debug(cache.getName() + " Cache: Cannot remove entry as key " + key + " was not found");
  15. }
  16. return null;
  17. }
  18. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. private Element getQuietFromUnderlyingStore(final Object key) {
  2. while (true) {
  3. long timeLeft = assertNotTimedOut();
  4. LOG.debug("cache {} underlying.getQuiet key {} not timed out, time left: " + timeLeft, cache.getName(), key);
  5. Element element = underlyingStore.getQuiet(key);
  6. if (element == null) {
  7. return null;
  8. }
  9. Object value = element.getObjectValue();
  10. if (value instanceof SoftLockID) {
  11. SoftLockID softLockId = (SoftLockID) value;
  12. SoftLock softLock = softLockManager.findSoftLockById(softLockId);
  13. if (softLock == null) {
  14. LOG.debug("cache {} underlying.getQuiet key {} soft lock died, retrying...", cache.getName(), key);
  15. continue;
  16. } else {
  17. try {
  18. LOG.debug("cache {} key {} soft locked, awaiting unlock...", cache.getName(), key);
  19. if (softLock.tryLock(timeLeft)) {
  20. softLock.clearTryLock();
  21. }
  22. } catch (InterruptedException e) {
  23. Thread.currentThread().interrupt();
  24. }
  25. }
  26. } else {
  27. return element;
  28. }
  29. }
  30. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. String rmiUrlCacheName = extractCacheName(rmiUrl);
  2. try {
  3. if (!rmiUrlCacheName.equals(cache.getName())) {
  4. continue;
  5. } else {
  6. LOG.debug("rmiUrl is stale. Either the remote peer is shutdown or the " +
  7. "network connectivity has been interrupted. Will be removed from list of remote cache peers",
  8. rmiUrl);

代码示例来源:origin: net.sf.ehcache/ehcache

  1. private Element getFromUnderlyingStore(final Object key) {
  2. while (true) {
  3. long timeLeft = assertNotTimedOut();
  4. LOG.debug("cache {} underlying.get key {} not timed out, time left: " + timeLeft, cache.getName(), key);
  5. Element element = underlyingStore.get(key);
  6. if (element == null) {
  7. return null;
  8. }
  9. Object value = element.getObjectValue();
  10. if (value instanceof SoftLockID) {
  11. SoftLockID softLockId = (SoftLockID) value;
  12. SoftLock softLock = softLockManager.findSoftLockById(softLockId);
  13. if (softLock == null) {
  14. LOG.debug("cache {} underlying.get key {} soft lock died, retrying...", cache.getName(), key);
  15. continue;
  16. } else {
  17. try {
  18. LOG.debug("cache {} key {} soft locked, awaiting unlock...", cache.getName(), key);
  19. if (softLock.tryLock(timeLeft)) {
  20. softLock.clearTryLock();
  21. }
  22. } catch (InterruptedException e) {
  23. Thread.currentThread().interrupt();
  24. }
  25. }
  26. } else {
  27. return element;
  28. }
  29. }
  30. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. String rmiUrlCacheName = extractCacheName(rmiUrl);
  2. if (!rmiUrlCacheName.equals(cache.getName())) {
  3. continue;
  4. } catch (Exception e) {
  5. if (LOG.isDebugEnabled()) {
  6. LOG.debug("Looking up rmiUrl " + rmiUrl + " through exception " + e.getMessage()
  7. + ". This may be normal if a node has gone offline. Or it may indicate network connectivity"
  8. + " difficulties", e);
  9. LOG.debug("rmiUrl {} should never be stale for a manually configured cluster.", rmiUrl);
  10. staleList.add(rmiUrl);

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public boolean containsKey(Object key) {
  5. LOG.debug("cache {} containsKey", cache.getName(), key);
  6. XATransactionContext context = getOrCreateTransactionContext();
  7. return !context.isRemoved(key) && (context.getAddedKeys().contains(key) || underlyingStore.containsKey(key));
  8. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. LOG.debug("Attempting to acquire cache peers for cache " + cache.getName()
  2. + " to bootstrap from. Will wait up to " + timeForClusterToForm + "ms for cache to join cluster.");
  3. Thread.sleep(ONE_SECOND);
  4. } catch (InterruptedException e) {
  5. LOG.debug("doLoad for " + cache.getName() + " interrupted.");
  6. LOG.debug("cache peers: {}", cachePeers);
  7. return cachePeers;

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public final Element removeWithWriter(Object key, CacheWriterManager writerManager) throws CacheException {
  5. if (key == null) {
  6. return null;
  7. }
  8. // remove single item.
  9. Element element;
  10. final ReentrantReadWriteLock.WriteLock writeLock = map.lockFor(key).writeLock();
  11. writeLock.lock();
  12. try {
  13. element = map.remove(key);
  14. if (writerManager != null) {
  15. writerManager.remove(new CacheEntry(key, element));
  16. }
  17. } finally {
  18. writeLock.unlock();
  19. }
  20. if (element == null && LOG.isDebugEnabled()) {
  21. LOG.debug(cache.getName() + "Cache: Cannot remove entry as key " + key + " was not found");
  22. }
  23. return element;
  24. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. LOG.debug("Empty list of cache peers for cache " + cache.getName() + ". No cache peer to bootstrap from.");
  2. return;
  3. int randomPeerNumber = random.nextInt(cachePeers.size());
  4. CachePeer cachePeer = (CachePeer) cachePeers.get(randomPeerNumber);
  5. LOG.debug("Bootstrapping " + cache.getName() + " from " + cachePeer);
  6. LOG.debug("All cache peer elements were either null or empty. Nothing to bootstrap from. Cache was "
  7. + cache.getName() + ". Cache peer was " + cachePeer);
  8. return;
  9. LOG.debug("Bootstrap of " + cache.getName() + " from " + cachePeer + " finished. "
  10. + keys.size() + " keys requested.");
  11. } catch (Throwable t) {

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * {@inheritDoc}
  3. */
  4. public Element remove(Object key) {
  5. LOG.debug("cache {} remove {}", cache.getName(), key);
  6. // this forces enlistment so the XA transaction timeout can be propagated to the XA resource
  7. getOrCreateTransactionContext();
  8. Element oldElement = getQuietFromUnderlyingStore(key);
  9. return removeInternal(new StoreRemoveCommand(key, oldElement));
  10. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. /**
  2. * Remove the cache and make it unuseable.
  3. * <p>
  4. *
  5. * @throws CacheException
  6. */
  7. public final void destroy() throws CacheException {
  8. try {
  9. cache.getCacheManager().removeCache(cache.getName());
  10. } catch (IllegalStateException e) {
  11. //When Spring and Hibernate are both involved this will happen in normal shutdown operation.
  12. //Do not throw an exception, simply log this one.
  13. LOG.debug("This can happen if multiple frameworks both try to shutdown ehcache", e);
  14. } catch (net.sf.ehcache.CacheException e) {
  15. throw new CacheException(e);
  16. }
  17. }

代码示例来源:origin: net.sf.ehcache/ehcache

  1. LOG.debug("recover [{}]", prettyPrintXAResourceFlags(flags));
  2. Thread t = new Thread("ehcache [" + cache.getName() + "] XA recovery thread") {
  3. @Override
  4. public void run() {
  5. Exception exception = new Exception("thread dump");
  6. exception.setStackTrace(t.getStackTrace());
  7. LOG.debug("XA recovery thread was interrupted after timeout", exception);
  8. t.interrupt();

相关文章

Ehcache类方法