private void handleExceptionInTerracottaStoreCreation(IllegalArgumentException e) { if (e.getMessage().contains("copyOnReadEnabled")) { throw new InvalidConfigurationException("Conflict in configuration for clustered cache " + getName() + " . " + "Source is either copyOnRead or transactional mode setting."); } else { throw new InvalidConfigurationException("Conflict in configuration for clustered cache " + getName() + " : " + e.getMessage()); } }
assertSame(objectType, objectType2); CacheConfiguration config = cache.getCacheConfiguration(); assertEquals("myCache1", cache.getName()); if (useCacheManagerFb){ assertEquals("myCache1.maxElements", 300, config.getMaxEntriesLocalHeap()); cache = (Cache) cacheFb.getObject(); config = cache.getCacheConfiguration(); assertEquals("undefinedCache", cache.getName()); assertTrue("default maxElements is correct", config.getMaxEntriesLocalHeap() == 10000); assertFalse("default eternal is correct", config.isEternal()); config = cache.getCacheConfiguration(); assertEquals("undefinedCache2", cache.getName()); assertTrue("overridden maxElements is correct", config.getMaxEntriesLocalHeap() == 5); assertTrue("default timeToLive is correct", config.getTimeToLiveSeconds() == 8);
/** * {@inheritDoc} */ public <T> Attribute<T> getSearchAttribute(String attributeName) throws CacheException { // We don't trust config here since the store is the real authority checkStatus(); Attribute<T> searchAttribute = compoundStore.getSearchAttribute(attributeName); if (searchAttribute == null) { final String msg; if (attributeName.equals(Query.KEY.getAttributeName())) { msg = "Key search attribute is disabled for cache [" + getName() + "]. It can be enabled with <searchable keys=\"true\"..."; } else if (attributeName.equals(Query.VALUE.getAttributeName())) { msg = "Value search attribute is disabled for cache [" + getName() + "]. It can be enabled with <searchable values=\"true\"..."; } else { msg = "No such search attribute [" + attributeName + "] defined for this cache [" + getName() + "]"; } throw new CacheException(msg); } return searchAttribute; }
&& !clusteredTransactionalMode.equals(getCacheConfiguration().getTransactionalMode())) { throw new InvalidConfigurationException("Transactional mode cannot be changed on clustered caches. " + "Please reconfigure cache '" + getName() + "' with transactionalMode = " + clusteredTransactionalMode);
/** * {@inheritDoc} */ public void init(Cache cache) throws CacheException { CacheWriter cacheWriter = cache.getRegisteredCacheWriter(); if (null == cacheWriter) { throw new CacheException("No cache writer was registered for cache " + cache.getName()); } if (cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteCoalescing()) { writeBehind.setOperationsFilter(new CoalesceKeysFilter()); } writeBehind.start(cacheWriter); }
public String getRegionName() { return cache.getName(); }
private void handleExceptionInTerracottaStoreCreation(IllegalArgumentException e) { if (e.getMessage().contains("copyOnReadEnabled")) { throw new InvalidConfigurationException("Conflict in configuration for clustered cache " + getName() + " . " + "Source is either copyOnRead or transactional mode setting."); } else { throw new InvalidConfigurationException("Conflict in configuration for clustered cache " + getName() + " : " + e.getMessage()); } }
private void handleExceptionInTerracottaStoreCreation(IllegalArgumentException e) { if (e.getMessage().contains("copyOnReadEnabled")) { throw new InvalidConfigurationException("Conflict in configuration for clustered cache " + getName() + " . " + "Source is either copyOnRead or transactional mode setting."); } else { throw new InvalidConfigurationException("Conflict in configuration for clustered cache " + getName() + " : " + e.getMessage()); } }
public EhcacheBackedProxyGrantingTicketStorageImpl() { this(CacheManager.getInstance().getCache(EHCACHE_CACHE_NAME)); logger.info("Created cache with name: {}", this.cache.getName()); }
public EhcacheBackedProxyGrantingTicketStorageImpl() { this(CacheManager.getInstance().getCache(EHCACHE_CACHE_NAME)); logger.info("Created cache with name: {}", this.cache.getName()); }
getCacheManager().getClusteredInstanceFactory().unlinkCache(getName());
private void shutdownIfActive( Cache cache ) { if( Status.STATUS_ALIVE.equals( cache.getStatus() ) ) { System.out.println( "Attempting to dispose of: " + cache.getName() + "..." ); cache.dispose(); } else { System.out.println( "Cache('"+ cache.getName() +"') was not alive. Skipping dispose()..." ); } } }
/** * {@inheritDoc} */ public Results executeQuery(StoreQuery query) { if (searchManager == null) { throw new UnsupportedOperationException("Query execution not supported by this store type: " + getClass().getName()); } return searchManager.executeQuery(query.getCache().getName(), query, attributeExtractors); }
if (!getName().startsWith(CacheManager.LOCAL_CACHE_NAME_PREFIX)) { throw new CacheException("This cache (" + getName() + ") is configurated with a different classloader reference than its containing cache manager"); if (getCacheConfiguration().getTerracottaConfiguration().getConcurrency() > maxConcurrency) { throw new InvalidConfigurationException("Maximum supported concurrency for Terracotta clustered caches is " + maxConcurrency + ". Please reconfigure cache '" + getName() + "' with concurrency value <= " + maxConcurrency + " or use system property '" + EHCACHE_CLUSTERREDSTORE_MAX_CONCURRENCY_PROP + "' to override the default");
/** * 根据名称创建缓存区 * * @param p_Cache */ public static void create(Cache p_Cache) { if (!m_Manager.cacheExists(p_Cache.getName())) { m_Manager.addCache(p_Cache); } } public static void create(String p_CacheName) {
@Cacheable(value = "myCache", key = "'get'+#id") public UserInfo getUserById(int id) { Cache cache = ehCacheService.getCache("myCache"); System.out.println("进来了查询方法......cache.getKeys()="+cache.getName()); UserInfo u = new UserInfo(); u.setName("土豆大人"); return u; }
public void close() throws IOException { getCacheManager().removeCache(getCache().getName()); } }
/** * {@inheritDoc} */ public void init(Cache cache) throws CacheException { CacheWriter cacheWriter = cache.getRegisteredCacheWriter(); if (null == cacheWriter) { throw new CacheException("No cache writer was registered for cache " + cache.getName()); } if (cache.getCacheConfiguration().getCacheWriterConfiguration().getWriteCoalescing()) { writeBehind.setOperationsFilter(new CoalesceKeysFilter()); } writeBehind.start(cacheWriter); }