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));
context.put( "cacheInfoRecords", admin.buildCacheInfo() );
context.put( "cacheInfoRecords", admin.buildCacheInfo() );
/** * Create a test region and then verify that we get it from the list. * * @throws Exception * */ public void testGetRegionInfo() throws Exception { String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); cache.put( "key", "value" ); JCSAdminBean admin = new JCSAdminBean(); CacheRegionInfo[] regions = admin.buildCacheInfo(); boolean foundRegion = false; for (CacheRegionInfo info : regions) { if ( info.getCacheName().equals( regionName ) ) { foundRegion = true; assertTrue( "Byte count should be greater than 5.", info.getByteCount() > 5 ); assertNotNull( "Should have stats.", info.getCacheStatistics() ); } } assertTrue( "Should have found the region we just created.", foundRegion ); }
/** * Create a test region and then verify that we get it from the list. * * @throws Exception * */ public void testGetRegionInfo() throws Exception { String regionName = "myRegion"; CacheAccess<String, String> cache = JCS.getInstance( regionName ); cache.put( "key", "value" ); JCSAdminBean admin = new JCSAdminBean(); CacheRegionInfo[] regions = admin.buildCacheInfo(); boolean foundRegion = false; for (CacheRegionInfo info : regions) { if ( info.getCacheName().equals( regionName ) ) { foundRegion = true; assertTrue( "Byte count should be greater than 5.", info.getByteCount() > 5 ); assertNotNull( "Should have stats.", info.getCacheStatistics() ); } } assertTrue( "Should have found the region we just created.", foundRegion ); }