/** * Dispose of this factory, clean up shared resources */ @Override public void dispose() { for (ICacheServiceNonLocal<?, ?> service : this.csnlInstances.values()) { try { service.dispose(""); } catch (IOException e) { log.error("Could not dispose service " + service, e); } } this.csnlInstances.clear(); // TODO: shut down discovery listeners this.lTCPDLInstances.clear(); if (this.monitor != null) { this.monitor.notifyShutdown(); // this.monitor.join(5000); this.monitor = null; } }
@Override public ICacheElement<K, V> call() throws IOException { return getRemoteCacheService().get( cacheName, key, getListenerId() ); } };
/** * Return the keys in this cache. * <p> * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getKeySet() */ @Override public Set<K> getKeySet() throws IOException { return getRemoteCacheService().getKeySet(cacheName); }
remoteCacheService.get( request.getCacheName(), request.getKey(), request.getRequesterId() ); response.setPayload(element); break; case GET_MULTIPLE: Map<Serializable, ICacheElement<Serializable, Serializable>> elementMap = remoteCacheService.getMultiple( request.getCacheName(), request.getKeySet(), request.getRequesterId() ); if ( elementMap != null ) case GET_MATCHING: Map<Serializable, ICacheElement<Serializable, Serializable>> elementMapMatching = remoteCacheService.getMatching( request.getCacheName(), request.getPattern(), request.getRequesterId() ); if ( elementMapMatching != null ) remoteCacheService.remove( request.getCacheName(), request.getKey(), request.getRequesterId() ); break; case REMOVE_ALL: remoteCacheService.removeAll( request.getCacheName(), request.getRequesterId() ); break; case UPDATE: remoteCacheService.update( request.getCacheElement(), request.getRequesterId() ); break; case ALIVE_CHECK: Set<Serializable> keys = remoteCacheService.getKeySet( request.getCacheName() ); response.setPayload( keys ); break;
/** * Synchronously removeAll from the remote cache; if failed, replace the remote handle with a * zombie. * <p> * @throws IOException */ @Override protected void processRemoveAll() throws IOException { try { lateralCacheService.removeAll( cacheName, CacheInfo.listenerId ); } catch ( IOException ex ) { handleException( ex, "Failed to remove all from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); } }
/** * @param pattern * @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>> processGetMatching( String pattern ) throws IOException { if ( this.lateralCacheAttributes.getPutOnlyMode() ) { return Collections.emptyMap(); } try { return lateralCacheService.getMatching( cacheName, pattern ); } catch ( IOException e ) { log.error( e ); handleException( e, "Failed to getMatching [" + pattern + "] from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); return Collections.emptyMap(); } }
/** * Synchronously remove from the remote cache; if failed, replace the remote handle with a * zombie. * <p> * @param key * @return false always * @throws IOException */ @Override protected boolean processRemove( K key ) throws IOException { if ( log.isDebugEnabled() ) { log.debug( "removing key:" + key ); } try { lateralCacheService.remove( cacheName, key, CacheInfo.listenerId ); } catch ( Exception ex ) { handleException( ex, "Failed to remove " + key + " from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); } return false; }
/** * Update lateral. * <p> * @param ce * @throws IOException */ @Override protected void processUpdate( ICacheElement<K, V> ce ) throws IOException { try { if (ce != null) { if ( log.isDebugEnabled() ) { log.debug( "update: lateral = [" + lateralCacheService + "], " + "CacheInfo.listenerId = " + CacheInfo.listenerId ); } lateralCacheService.update( ce, CacheInfo.listenerId ); } } catch ( IOException ex ) { handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes ); } }
ICacheElement<K, V> element = getRemoteCacheService().get( request.getCacheName(), request.getKey(), request.getRequesterId() ); response.setPayload(element); break; case GET_MULTIPLE: Map<K, ICacheElement<K, V>> elementMap = getRemoteCacheService().getMultiple( request.getCacheName(), request.getKeySet(), request.getRequesterId() ); Map<K, ICacheElement<K, V>> elementMapMatching = getRemoteCacheService().getMatching( request.getCacheName(), request.getPattern(), request.getRequesterId() ); getRemoteCacheService().remove( request.getCacheName(), request.getKey(), request.getRequesterId() ); break; case REMOVE_ALL: getRemoteCacheService().removeAll( request.getCacheName(), request.getRequesterId() ); break; case UPDATE: getRemoteCacheService().update( request.getCacheElement(), request.getRequesterId() ); break; case ALIVE_CHECK: Set<K> keys = getRemoteCacheService().getKeySet( request.getCacheName() ); response.setPayload( keys ); break;
/** * Synchronously removeAll from the remote cache; if failed, replace the remote handle with a * zombie. * <p> * @throws IOException */ @Override protected void processRemoveAll() throws IOException { try { lateralCacheService.removeAll( cacheName, CacheInfo.listenerId ); } catch ( Exception ex ) { handleException( ex, "Failed to remove all from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); } }
/** * @param pattern * @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>> processGetMatching( String pattern ) throws IOException { if ( this.lateralCacheAttributes.getPutOnlyMode() ) { return Collections.emptyMap(); } try { return lateralCacheService.getMatching( cacheName, pattern ); } catch ( IOException e ) { log.error( e ); handleException( e, "Failed to getMatching [" + pattern + "] from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); return Collections.emptyMap(); } }
/** * Synchronously remove from the remote cache; if failed, replace the remote handle with a * zombie. * <p> * @param key * @return false always * @throws IOException */ @Override protected boolean processRemove( K key ) throws IOException { if ( log.isDebugEnabled() ) { log.debug( "removing key:" + key ); } try { lateralCacheService.remove( cacheName, key, CacheInfo.listenerId ); } catch ( IOException ex ) { handleException( ex, "Failed to remove " + key + " from " + lateralCacheAttributes.getCacheName() + "@" + lateralCacheAttributes ); } return false; }
/** * Update lateral. * <p> * @param ce * @throws IOException */ @Override protected void processUpdate( ICacheElement<K, V> ce ) throws IOException { try { if ( log.isDebugEnabled() ) { log.debug( "update: lateral = [" + lateralCacheService + "], " + "CacheInfo.listenerId = " + CacheInfo.listenerId ); } lateralCacheService.update( ce, CacheInfo.listenerId ); } catch ( NullPointerException npe ) { log.error( "Failure updating lateral. lateral = " + lateralCacheService, npe ); handleException( npe, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes ); return; } catch ( Exception ex ) { handleException( ex, "Failed to put [" + ce.getKey() + "] to " + ce.getCacheName() + "@" + lateralCacheAttributes ); } }
@Override public ICacheElement<K, V> call() throws IOException { return getRemoteCacheService().get( cacheName, key, getListenerId() ); } };
/** * Return the keys in this cache. * <p> * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getKeySet() */ @Override public Set<K> getKeySet() throws java.rmi.RemoteException, IOException { return getRemoteCacheService().getKeySet(cacheName); }
/** * Synchronously removeAll from the remote cache; if failed, replace the remote handle with a * zombie. * <p> * @throws IOException */ @Override protected void processRemoveAll() throws IOException { if ( !this.getRemoteCacheAttributes().getGetOnly() ) { try { getRemoteCacheService().removeAll( cacheName, getListenerId() ); } catch ( Exception ex ) { handleException( ex, "Failed to remove all from " + cacheName, ICacheEventLogger.REMOVEALL_EVENT ); } } }
service.dispose("");
try Map<K, ICacheElement<K, V>> rawResults = getRemoteCacheService().getMatching( cacheName, pattern, getListenerId() );