/** Adds a dispose request to the remote cache. */ @Override public void dispose() { try { cacheEventQueue.addDisposeEvent(); } catch ( IOException e ) { log.error( "Problem adding DisposeEvent to queue.", e ); cacheEventQueue.destroy(); } }
/** * @param ce * @throws IOException */ @Override public void update( ICacheElement<K, V> ce ) throws IOException { putCount++; try { eventQueue.addPutEvent( ce ); } catch ( IOException ex ) { log.error( ex ); eventQueue.destroy(); } }
/** Adds a removeAll request to the lateral cache. */ @Override public void removeAll() { try { eventQueue.addRemoveAllEvent(); } catch ( IOException ex ) { log.error( ex ); eventQueue.destroy(); } }
/** * Resets the event q by first destroying the existing one and starting up new one. * <p> * There may be no good reason to kill the existing queue. We will sometimes need to set a new * listener id, so we should create a new queue. We should let the old queue drain. If we were * Connected to the failover, it would be best to finish sending items. */ public void resetEventQ() { ICacheEventQueue<K, V> previousQueue = cacheEventQueue; this.cacheEventQueue = createCacheEventQueue(this.remoteCacheClient); if ( previousQueue.isWorking() ) { // we don't expect anything, it would have all gone to the zombie if ( log.isInfoEnabled() ) { log.info( "resetEventQ, previous queue has [" + previousQueue.size() + "] items queued up." ); } previousQueue.destroy(); } }
/** * 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(); }
/** * Adds a remove request to the lateral cache. * <p> * @param key * @return always false */ @Override public boolean remove( K key ) { removeCount++; try { eventQueue.addRemoveEvent( key ); } catch ( IOException ex ) { log.error( ex ); eventQueue.destroy(); } return false; }
/** * 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() ); }
@Override public void run() { boolean keepGoing = true; long total = 0; long interval = 100; while ( keepGoing ) { keepGoing = !cacheEventQueue.isEmpty(); try { Thread.sleep( interval ); total += interval; // log.info( "total = " + total ); } catch ( InterruptedException e ) { break; } } log.info( "No longer waiting for event queue to finish: " + cacheEventQueue.getStatistics() ); } };
if ( q.isWorking() && q.getListenerId() != requesterId )
/** * 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; }
/** * Returns semi-structured data. * * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getStatistics() */ @Override public IStats getStatistics() { IStats stats = new Stats(); stats.setTypeName( "Abstract Disk Cache" ); ArrayList<IStatElement<?>> elems = new ArrayList<IStatElement<?>>(); elems.add(new StatElement<Integer>( "Purgatory Hits", Integer.valueOf(purgHits) ) ); elems.add(new StatElement<Integer>( "Purgatory Size", Integer.valueOf(purgatory.size()) ) ); // get the stats from the event queue too IStats eqStats = this.cacheEventQueue.getStatistics(); elems.addAll(eqStats.getStatElements()); stats.setStatElements( elems ); return stats; }
/** * Frees all remote caches. * <p> * @throws IOException */ @Override public void release() throws IOException { for (CacheListeners<K, V> cacheDesc : cacheListenersMap.values()) { ICacheEventQueue<K, V>[] qlist = getEventQList( cacheDesc, 0 ); for ( int i = 0; i < qlist.length; i++ ) { qlist[i].addDisposeEvent(); } } cacheManager.release(); }
qlist[i].addRemoveEvent( key );
qlist[i].addPutEvent( item );
/** * Resets the event q by first destroying the existing one and starting up new one. * <p> * There may be no good reason to kill the existing queue. We will sometimes need to set a new * listener id, so we should create a new queue. We should let the old queue drain. If we were * Connected to the failover, it would be best to finish sending items. */ public void resetEventQ() { ICacheEventQueue<K, V> previousQueue = cacheEventQueue; CacheEventQueueFactory<K, V> fact = new CacheEventQueueFactory<K, V>(); this.cacheEventQueue = fact.createCacheEventQueue( new CacheAdaptor<K, V>( remoteCacheClient ), remoteCacheClient .getListenerId(), remoteCacheClient.getCacheName(), remoteCacheClient.getAuxiliaryCacheAttributes() .getEventQueuePoolName(), remoteCacheClient.getAuxiliaryCacheAttributes().getEventQueueType() ); if ( previousQueue.isWorking() ) { // we don't expect anything, it would have all gone to the zombie if ( log.isInfoEnabled() ) { log.info( "resetEventQ, previous queue has [" + previousQueue.size() + "] items queued up." ); } previousQueue.destroy(); } }
/** * 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(); }
/** * Adds a remove request to the lateral cache. * <p> * @param key * @return always false */ @Override public boolean remove( K key ) { removeCount++; try { eventQueue.addRemoveEvent( key ); } catch ( IOException ex ) { log.error( ex ); eventQueue.destroy(); } return false; }
/** * 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() ); }