new HashMap<K, ICacheElement<K, V>>(); CacheType cacheType = aux.getCacheType(); log.debug( "Attempting to get from aux [" + aux.getCacheName() + "] which is of type: " + cacheType ); elementsFromAuxiliary.putAll( aux.getMultiple( remainingKeys ) );
if ( aux != null ) if(!localOnly || aux.getCacheType() == CacheType.DISK_CACHE) allKeys.addAll( aux.getKeySet() );
new HashMap<K, ICacheElement<K, V>>(); CacheType cacheType = aux.getCacheType(); log.debug( "Attempting to get from aux [" + aux.getCacheName() + "] which is of type: " + cacheType ); elementsFromAuxiliary.putAll( aux.getMatching( pattern ) );
ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key", "value"); cache.update(element); SleepUtil.sleepAtLeast(50); assertEquals("Cache is alive", CacheStatus.ALIVE, cache.getStatus()); assertEquals("Wrong number of puts", 1, server.getPutCount() - numPutsPrior); System.out.println(cache.getStats()); System.out.println(server.getStats()); throw e; ICacheElement<String, String> result = cache.get("key"); cache.remove("key"); SleepUtil.sleepAtLeast(200); ICacheElement<String, String> resultAfterRemote = cache.get("key");
CacheType cacheType = aux.getCacheType(); log.debug( "Attempting to get from aux [" + aux.getCacheName() + "] which is of type: " + cacheType ); element = aux.get( key ); log.debug( cacheAttr.getCacheName() + " - Aux cache[" + aux.getCacheName() + "] hit, but element expired." ); log.debug( cacheAttr.getCacheName() + " - Aux cache[" + aux.getCacheName() + "] hit" );
cache.update(element); assertEquals("Cache is alive", CacheStatus.ALIVE, cache.getStatus()); assertEquals("Wrong number of puts", numToPut, server.getPutCount() - numPutsPrior); assertEquals("Wrong number of puts to listener.", numToPut, listener.putCount); System.out.println(cache.getStats()); System.out.println(server.getStats()); throw e;
log.debug( cacheAttr.getCacheName() + " - Aux cache[" + aux.getCacheName() + "] hit, but element expired." ); log.debug( cacheAttr.getCacheName() + " - Aux cache[" + aux.getCacheName() + "] hit" );
AuxiliaryCacheAttributes aca = ic.getAuxiliaryCacheAttributes(); if (aca instanceof ITCPLateralCacheAttributes)
/** * Return the keys in this cache. * <p> * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getKeySet() */ @Override public Set<K> getKeySet() throws IOException { HashSet<K> allKeys = new HashSet<K>(); for ( int i = 0; i < noWaits.length; i++ ) { AuxiliaryCache<K, V> aux = noWaits[i]; if ( aux != null ) { Set<K> keys = aux.getKeySet(); if(keys != null) { allKeys.addAll( keys ); } } } return allKeys; }
/** * 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.update(element); SleepUtil.sleepAtLeast(50); assertEquals("Cache is alive", CacheStatus.ALIVE, cache.getStatus()); assertEquals("Wrong number of puts", 1, server.getPutCount() - numPutsPrior); System.out.println(cache.getStats()); System.out.println(server.getStats()); throw e; ICacheElement<String, String> result = cache.get("key"); cache.remove("key"); SleepUtil.sleepAtLeast(200); ICacheElement<String, String> resultAfterRemote = cache.get("key");
CacheType cacheType = aux.getCacheType(); log.debug( "Attempting to get from aux [" + aux.getCacheName() + "] which is of type: " + cacheType ); element = aux.get( key );
cache.update(element); SleepUtil.sleepAtLeast(50); assertEquals("Cache is alive", CacheStatus.ALIVE, cache.getStatus()); assertEquals("Wrong number of puts", 1, server.getPutCount() - numPutsPrior); assertEquals("Wrong number of puts to listener.", 1, listener.putCount); System.out.println(cache.getStats()); System.out.println(server.getStats()); throw e;
AuxiliaryCacheAttributes aca = ic.getAuxiliaryCacheAttributes(); if (aca instanceof ITCPLateralCacheAttributes)
/** * Return the keys in this cache. * <p> * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getKeySet() */ @Override public Set<K> getKeySet() throws IOException { HashSet<K> allKeys = new HashSet<K>(); for ( int i = 0; i < noWaits.length; i++ ) { AuxiliaryCache<K, V> aux = noWaits[i]; if ( aux != null ) { Set<K> keys = aux.getKeySet(); if(keys != null) { allKeys.addAll( keys ); } } } return allKeys; }
/** * 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; }
server.addCacheListener(cache.getCacheName(), listener); for (int i = 0; i < numToPut; i++) ICacheElement<String, String> element = new CacheElement<String, String>(cache.getCacheName(), "key" + 1, "value" + i); cache.update(element); assertEquals("Cache is alive", CacheStatus.ALIVE, cache.getStatus()); assertEquals("Wrong number of puts", numToPut, server.getPutCount() - numPutsPrior); assertEquals("Wrong number of puts to listener.", numToPut, listener.putCount); System.out.println(cache.getStats()); System.out.println(server.getStats()); throw e;
new HashMap<K, ICacheElement<K, V>>(); CacheType cacheType = aux.getCacheType(); log.debug( "Attempting to get from aux [" + aux.getCacheName() + "] which is of type: " + cacheType ); elementsFromAuxiliary.putAll( aux.getMultiple( remainingKeys ) );
new HashMap<K, ICacheElement<K, V>>(); CacheType cacheType = aux.getCacheType(); log.debug( "Attempting to get from aux [" + aux.getCacheName() + "] which is of type: " + cacheType ); elementsFromAuxiliary.putAll( aux.getMatching( pattern ) );
/** * Get a set of the keys for all elements in the cache * <p> * @param localOnly true if only memory keys are requested * * @return A set of the key type */ public Set<K> getKeySet(boolean localOnly) { HashSet<K> allKeys = new HashSet<K>(); allKeys.addAll( memCache.getKeySet() ); for ( AuxiliaryCache<K, V> aux : auxCaches ) { if ( aux != null ) { if(!localOnly || aux.getCacheType() == CacheType.DISK_CACHE) { try { allKeys.addAll( aux.getKeySet() ); } catch ( IOException e ) { // ignore } } } } return allKeys; }