/** * Replaces the lateral cache service handle with the given handle and reset the queue by * starting up a new instance. * <p> * @param lateral */ public void fixCache( ICacheServiceNonLocal<K, V> lateral ) { cache.fixCache( lateral ); resetEventQ(); }
/** * Gets multiple items from the cache based on the given set of keys. * <p> * @param keys * @return a map of K key to ICacheElement<K, V> element, or an empty map if there is no * data in cache for any of these keys * @throws IOException */ @Override protected Map<K, ICacheElement<K, V>> processGetMultiple( Set<K> keys ) throws IOException { Map<K, ICacheElement<K, V>> elements = new HashMap<K, ICacheElement<K, V>>(); if ( keys != null && !keys.isEmpty() ) { for (K key : keys) { ICacheElement<K, V> element = get( key ); if ( element != null ) { elements.put( key, element ); } } } return elements; }
/** * @return Returns the AuxiliaryCacheAttributes. */ @Override public AuxiliaryCacheAttributes getAuxiliaryCacheAttributes() { return cache.getAuxiliaryCacheAttributes(); }
/** * Add a no wait from an unknown facade. */ public void testAddNoWait_FacadeNotInList() { // SETUP String cacheName = "testAddNoWaitFacade_FacadeInList"; ILateralCacheAttributes cattr = new LateralCacheAttributes(); cattr.setCacheName( cacheName ); LateralCache<String, String> cache = new LateralCache<String, String>( cattr ); LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache ); // DO WORK boolean result = listener.addNoWait( noWait ); // VERIFY assertFalse( "Should not have added the no wait.", result ); }
protected <K, V> LateralCacheNoWait<K, V> createCacheNoWait( ITCPLateralCacheAttributes lca, ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer ) { ICacheServiceNonLocal<K, V> lateralService = getCSNLInstance(lca); LateralCache<K, V> cache = new LateralCache<K, V>( lca, lateralService, this.monitor ); cache.setCacheEventLogger( cacheEventLogger ); cache.setElementSerializer( elementSerializer ); if ( log.isDebugEnabled() ) { log.debug( "Created cache for noWait, cache [" + cache + "]" ); } LateralCacheNoWait<K, V> lateralNoWait = new LateralCacheNoWait<K, V>( cache ); lateralNoWait.setCacheEventLogger( cacheEventLogger ); lateralNoWait.setElementSerializer( elementSerializer ); if ( log.isInfoEnabled() ) { log.info( "Created LateralCacheNoWait for [" + lca + "] LateralCacheNoWait = [" + lateralNoWait + "]" ); } return lateralNoWait; }
/** * Constructs with the given lateral cache, and fires up an event queue for asynchronous * processing. * <p> * @param cache */ public LateralCacheNoWait( LateralCache<K, V> cache ) { this.cache = cache; if ( log.isDebugEnabled() ) { log.debug( "Constructing LateralCacheNoWait, LateralCache = [" + cache + "]" ); } CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>(); this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<K, V>( cache ), CacheInfo.listenerId, cache .getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache .getAuxiliaryCacheAttributes().getEventQueueType() ); // need each no wait to handle each of its real updates and removes, // since there may // be more than one per cache? alternative is to have the cache // perform updates using a different method that specifies the listener // this.q = new CacheEventQueue(new CacheAdaptor(this), // LateralCacheInfo.listenerId, cache.getCacheName()); if ( cache.getStatus() == CacheStatus.ERROR ) { eventQueue.destroy(); } }
/** * Resets the event q by first destroying the existing one and starting up new one. */ public void resetEventQ() { if ( eventQueue.isWorking() ) { eventQueue.destroy(); } CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>(); this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<K, V>( cache ), CacheInfo.listenerId, cache .getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache .getAuxiliaryCacheAttributes().getEventQueueType() ); }
/** * Gets the cacheName attribute of the LateralCacheNoWait object * <p> * @return The cacheName value */ @Override public String getCacheName() { return cache.getCacheName(); }
/** * Returns the asyn cache status. An error status indicates either the lateral connection is not * available, or the asyn queue has been unexpectedly destroyed. No lateral invocation. * <p> * @return The status value */ @Override public CacheStatus getStatus() { return eventQueue.isWorking() ? cache.getStatus() : CacheStatus.ERROR; }
/** * No lateral invocation. * <p> * @return The size value */ @Override public int getSize() { return cache.getSize(); }
/** * No lateral invocation. * <p> * @return The cacheType value */ @Override public CacheType getCacheType() { return cache.getCacheType(); }
/** * Return the keys in this cache. * <p> * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getKeySet() */ @Override public Set<K> getKeySet() throws IOException { try { return cache.getKeySet(); } catch ( IOException ex ) { log.error( ex ); eventQueue.destroy(); } return Collections.emptySet(); }
return cache.getMatching( pattern ); try return cache.getMatching( pattern );
/** * Remove a no wait from an unknown facade. */ public void testRemoveNoWait_FacadeNotInList() { // SETUP String cacheName = "testRemoveNoWaitFacade_FacadeNotInList"; ILateralCacheAttributes cattr = new LateralCacheAttributes(); cattr.setCacheName( cacheName ); LateralCache<String, String> cache = new LateralCache<String, String>( cattr ); LateralCacheNoWait<String, String> noWait = new LateralCacheNoWait<String, String>( cache ); // DO WORK boolean result = listener.removeNoWait( noWait ); // VERIFY assertFalse( "Should not have removed the no wait.", result ); }
protected <K, V> LateralCacheNoWait<K, V> createCacheNoWait( ITCPLateralCacheAttributes lca, ICacheEventLogger cacheEventLogger, IElementSerializer elementSerializer ) { ICacheServiceNonLocal<K, V> lateralService = getCSNLInstance(lca); LateralCache<K, V> cache = new LateralCache<K, V>( lca, lateralService, this.monitor ); cache.setCacheEventLogger( cacheEventLogger ); cache.setElementSerializer( elementSerializer ); if ( log.isDebugEnabled() ) { log.debug( "Created cache for noWait, cache [" + cache + "]" ); } LateralCacheNoWait<K, V> lateralNoWait = new LateralCacheNoWait<K, V>( cache ); lateralNoWait.setCacheEventLogger( cacheEventLogger ); lateralNoWait.setElementSerializer( elementSerializer ); if ( log.isInfoEnabled() ) { log.info( "Created LateralCacheNoWait for [" + lca + "] LateralCacheNoWait = [" + lateralNoWait + "]" ); } return lateralNoWait; }
/** * Constructs with the given lateral cache, and fires up an event queue for asynchronous * processing. * <p> * @param cache */ public LateralCacheNoWait( LateralCache<K, V> cache ) { this.cache = cache; if ( log.isDebugEnabled() ) { log.debug( "Constructing LateralCacheNoWait, LateralCache = [" + cache + "]" ); } CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>(); this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<K, V>( cache ), CacheInfo.listenerId, cache .getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache .getAuxiliaryCacheAttributes().getEventQueueType() ); // need each no wait to handle each of its real updates and removes, // since there may // be more than one per cache? alternative is to have the cache // perform updates using a different method that specifies the listener // this.q = new CacheEventQueue(new CacheAdaptor(this), // LateralCacheInfo.listenerId, cache.getCacheName()); if ( cache.getStatus() == CacheStatus.ERROR ) { eventQueue.destroy(); } }
/** * Resets the event q by first destroying the existing one and starting up new one. */ public void resetEventQ() { if ( eventQueue.isWorking() ) { eventQueue.destroy(); } CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>(); this.eventQueue = fact.createCacheEventQueue( new CacheAdaptor<K, V>( cache ), CacheInfo.listenerId, cache .getCacheName(), cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), cache .getAuxiliaryCacheAttributes().getEventQueueType() ); }
/** * Gets the cacheName attribute of the LateralCacheNoWait object * <p> * @return The cacheName value */ @Override public String getCacheName() { return cache.getCacheName(); }
/** * Returns the asyn cache status. An error status indicates either the lateral connection is not * available, or the asyn queue has been unexpectedly destroyed. No lateral invocation. * <p> * @return The status value */ @Override public CacheStatus getStatus() { return eventQueue.isWorking() ? cache.getStatus() : CacheStatus.ERROR; }
/** * No lateral invocation. * <p> * @return The size value */ @Override public int getSize() { return cache.getSize(); }