public JcsCache(final CompositeCache cache) throws CacheException { this(cache.getCacheName(), cache.getCacheAttributes()); }
/** * Returns the cache (aka "region") name. * <p> * @return The cacheName value */ public String getCacheName() { String attributeCacheName = this.cacheAttributes.getCacheName(); if(attributeCacheName != null) { return attributeCacheName; } return cache.getCacheName(); }
JCSAdminBean admin = new JCSAdminBean(); LinkedList linkedList = admin.buildCacheInfo(); ListIterator iterator = linkedList.listIterator(); while (iterator.hasNext()) { CacheRegionInfo info = (CacheRegionInfo)iterator.next(); CompositeCache compCache = info.getCache(); System.out.println("Cache Name: " + compCache.getCacheName()); System.out.println("Cache Type: " + compCache.getCacheType()); System.out.println("Cache Misses (not found): " + compCache.getMissCountNotFound()); System.out.println("Cache Misses (expired): " + compCache.getMissCountExpired()); System.out.println("Cache Hits (memory): " + compCache.getHitCountRam()); System.out.println("Cache value: " + compCache.get(propId));
private GroupAttrName<String> getGroupAttrName(String group, String name) { GroupId gid = new GroupId(groupCacheAccess.getCacheControl() .getCacheName(), group); return new GroupAttrName<String>(gid, name); }
/** * For post reflection creation initialization * <p> * @param hub */ @Override public void initialize( CompositeCache<K, V> hub ) { lock.lock(); try { this.cacheName = hub.getCacheName(); this.cacheAttributes = hub.getCacheAttributes(); this.cache = hub; map = createMap(); chunkSize = cacheAttributes.getSpoolChunkSize(); status = CacheStatus.ALIVE; } finally { lock.unlock(); } }
/** * Internal method used for group functionality. * <p> * @param group * @param name * @return GroupAttrName */ private GroupAttrName<K> getGroupAttrName( String group, K name ) { GroupId gid = new GroupId( this.getCacheControl().getCacheName(), group ); return new GroupAttrName<K>( gid, name ); }
/** * Internal method used for group functionality. * <p> * @param group * @param name * @return GroupAttrName */ private GroupAttrName<K> getGroupAttrName( String group, K name ) { GroupId gid = new GroupId( this.getCacheControl().getCacheName(), group ); return new GroupAttrName<K>( gid, name ); }
log.warn("No element event queue available for cache " + getCacheName()); return;
/** * Gets the set of keys of objects currently in the group. * <p> * @param group * @return A Set of keys. */ @Override public Set<K> getGroupKeys( String group ) { Set<K> groupKeys = new HashSet<K>(); GroupId groupId = new GroupId( this.getCacheControl().getCacheName(), group ); for (GroupAttrName<K> gan : this.getCacheControl().getKeySet()) { if (gan.groupId.equals( groupId )) { groupKeys.add( gan.attrName ); } } return groupKeys; }
/** * Gets the set of keys of objects currently in the group. * <p> * @param group * @return A Set of keys. */ @Override public Set<K> getGroupKeys( String group ) { Set<K> groupKeys = new HashSet<K>(); GroupId groupId = new GroupId( this.getCacheControl().getCacheName(), group ); for (GroupAttrName<K> gan : this.getCacheControl().getKeySet()) { if (gan.groupId.equals( groupId )) { groupKeys.add( gan.attrName ); } } return groupKeys; }
/** * This returns data gathered for this region and all the auxiliaries it currently uses. * <p> * @return Statistics and Info on the Region. */ public ICacheStats getStatistics() { ICacheStats stats = new CacheStats(); stats.setRegionName( this.getCacheName() ); // store the composite cache stats first ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>(); elems.add(new StatElement<Integer>( "HitCountRam", Integer.valueOf(getHitCountRam()) ) ); elems.add(new StatElement<Integer>( "HitCountAux", Integer.valueOf(getHitCountAux()) ) ); stats.setStatElements( elems ); // memory + aux, memory is not considered an auxiliary internally int total = auxCaches.length + 1; ArrayList<IStats> auxStats = new ArrayList<IStats>(total); auxStats.add(getMemoryCache().getStatistics()); for ( AuxiliaryCache<K, V> aux : auxCaches ) { auxStats.add(aux.getStatistics()); } // store the auxiliary stats stats.setAuxiliaryCacheStats( auxStats ); return stats; }
/** * This returns data gathered for this region and all the auxiliaries it currently uses. * <p> * @return Statistics and Info on the Region. */ public ICacheStats getStatistics() { ICacheStats stats = new CacheStats(); stats.setRegionName( this.getCacheName() ); // store the composite cache stats first ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>(); elems.add(new StatElement<Integer>( "HitCountRam", Integer.valueOf(getHitCountRam()) ) ); elems.add(new StatElement<Integer>( "HitCountAux", Integer.valueOf(getHitCountAux()) ) ); stats.setStatElements( elems ); // memory + aux, memory is not considered an auxiliary internally int total = auxCaches.length + 1; ArrayList<IStats> auxStats = new ArrayList<IStats>(total); auxStats.add(getMemoryCache().getStatistics()); for ( AuxiliaryCache<K, V> aux : auxCaches ) { auxStats.add(aux.getStatistics()); } // store the auxiliary stats stats.setAuxiliaryCacheStats( auxStats ); return stats; }
cache.getCacheName(), cache.getSize(), cache.getStatus().toString(),
cache.getCacheName(), cache.getSize(), cache.getStatus().toString(),
CacheElement<K, V> ce = new CacheElement<K, V>( this.getCacheControl().getCacheName(), key, val );
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestSoftReferenceCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); SoftReferenceMemoryCache<String, String> srmc = new SoftReferenceMemoryCache<String, String>(); srmc.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); srmc.update( ice ); } Set<String> keys = srmc.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestLHMLRUCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); LHMLRUMemoryCache<String, String> mru = new LHMLRUMemoryCache<String, String>(); mru.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); mru.update( ice ); } Set<String> keys = mru.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestMRUCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); MRUMemoryCache<String, String> mru = new MRUMemoryCache<String, String>(); mru.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); mru.update( ice ); } Set<String> keys = mru.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestLHMLRUCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); LHMLRUMemoryCache<String, String> mru = new LHMLRUMemoryCache<String, String>(); mru.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); mru.update( ice ); } Set<String> keys = mru.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }
/** * Put half the max and clear. get the key array and verify that it has the correct number of * items. * <p> * @throws Exception */ public void testGetKeyArray() throws Exception { CompositeCacheManager cacheMgr = CompositeCacheManager.getUnconfiguredInstance(); cacheMgr.configure( "/TestMRUCache.ccf" ); CompositeCache<String, String> cache = cacheMgr.getCache( "testGetKeyArray" ); MRUMemoryCache<String, String> mru = new MRUMemoryCache<String, String>(); mru.initialize( cache ); int max = cache.getCacheAttributes().getMaxObjects(); int items = max / 2; for ( int i = 0; i < items; i++ ) { ICacheElement<String, String> ice = new CacheElement<String, String>( cache.getCacheName(), i + ":key", cache.getCacheName() + " data " + i ); ice.setElementAttributes( cache.getElementAttributes() ); mru.update( ice ); } Set<String> keys = mru.getKeySet(); assertEquals( "Wrong number of keys.", items, keys.size() ); }