/** * This starts the ListenerThread on the specified port. */ @Override public synchronized void init() { try { this.port = getTcpLateralCacheAttributes().getTcpListenerPort(); pooledExecutor = Executors.newCachedThreadPool( new DaemonThreadFactory("JCS-LateralTCPListener-")); terminated = false; shutdown = false; log.info( "Listening on port " + port ); ServerSocket serverSocket = new ServerSocket( port ); serverSocket.setSoTimeout( acceptTimeOut ); receiver = new ListenerThread(serverSocket); receiver.setDaemon( true ); receiver.start(); } catch ( Exception ex ) { log.error( ex ); throw new IllegalStateException( ex.getMessage() ); } }
/** * This starts the ListenerThread on the specified port. */ @Override public synchronized void init() { try { this.port = getTcpLateralCacheAttributes().getTcpListenerPort(); pooledExecutor = Executors.newCachedThreadPool( new DaemonThreadFactory("JCS-LateralTCPListener-")); terminated = new AtomicBoolean(false); shutdown = new AtomicBoolean(false); log.info( "Listening on port " + port ); ServerSocket serverSocket = new ServerSocket( port ); serverSocket.setSoTimeout( acceptTimeOut ); receiver = new ListenerThread(serverSocket); receiver.setDaemon( true ); receiver.start(); } catch ( IOException ex ) { throw new IllegalStateException( ex ); } }
/** * Gets the cache that was injected by the lateral factory. Calls get on the cache. * <p> * @param cacheName * @param key * @return a ICacheElement * @throws IOException */ public ICacheElement<K, V> handleGet( String cacheName, K key ) throws IOException { getCnt++; if ( log.isInfoEnabled() ) { if ( getGetCnt() % 100 == 0 ) { log.info( "Get Count (port " + getTcpLateralCacheAttributes().getTcpListenerPort() + ") = " + getGetCnt() ); } } if ( log.isDebugEnabled() ) { log.debug( "handleGet> cacheName=" + cacheName + ", key = " + key ); } return getCache( cacheName ).localGet( key ); }
/** * Gets the cache that was injected by the lateral factory. Calls get on the cache. * <p> * @param cacheName the name of the cache * @param pattern the matching pattern * @return Map * @throws IOException */ public Map<K, ICacheElement<K, V>> handleGetMatching( String cacheName, String pattern ) throws IOException { getCnt++; if ( log.isInfoEnabled() ) { if ( getGetCnt() % 100 == 0 ) { log.info( "GetMatching Count (port " + getTcpLateralCacheAttributes().getTcpListenerPort() + ") = " + getGetCnt() ); } } if ( log.isDebugEnabled() ) { log.debug( "handleGetMatching> cacheName=" + cacheName + ", pattern = " + pattern ); } return getCache( cacheName ).localGetMatching( pattern ); }
/** * Gets the cache that was injected by the lateral factory. Calls get on the cache. * <p> * @param cacheName * @param key * @return a ICacheElement * @throws IOException */ public ICacheElement<K, V> handleGet( String cacheName, K key ) throws IOException { getCnt++; if ( log.isInfoEnabled() ) { if ( getGetCnt() % 100 == 0 ) { log.info( "Get Count (port " + getTcpLateralCacheAttributes().getTcpListenerPort() + ") = " + getGetCnt() ); } } if ( log.isDebugEnabled() ) { log.debug( "handleGet> cacheName=" + cacheName + ", key = " + key ); } return getCache( cacheName ).localGet( key ); }
/** * Gets the cache that was injected by the lateral factory. Calls get on the cache. * <p> * @param cacheName the name of the cache * @param pattern the matching pattern * @return Map * @throws IOException */ public Map<K, ICacheElement<K, V>> handleGetMatching( String cacheName, String pattern ) throws IOException { getCnt++; if ( log.isInfoEnabled() ) { if ( getGetCnt() % 100 == 0 ) { log.info( "GetMatching Count (port " + getTcpLateralCacheAttributes().getTcpListenerPort() + ") = " + getGetCnt() ); } } if ( log.isDebugEnabled() ) { log.debug( "handleGetMatching> cacheName=" + cacheName + ", pattern = " + pattern ); } return getCache( cacheName ).localGetMatching( pattern ); }
/** * Increments the put count. Gets the cache that was injected by the lateral factory. Calls put * on the cache. * <p> * @see org.apache.commons.jcs.engine.behavior.ICacheListener#handlePut(org.apache.commons.jcs.engine.behavior.ICacheElement) */ @Override public void handlePut( ICacheElement<K, V> element ) throws IOException { putCnt++; if ( log.isInfoEnabled() ) { if ( getPutCnt() % 100 == 0 ) { log.info( "Put Count (port " + getTcpLateralCacheAttributes().getTcpListenerPort() + ") = " + getPutCnt() ); } } if ( log.isDebugEnabled() ) { log.debug( "handlePut> cacheName=" + element.getCacheName() + ", key=" + element.getKey() ); } getCache( element.getCacheName() ).localUpdate( element ); }
/** * Increments the put count. Gets the cache that was injected by the lateral factory. Calls put * on the cache. * <p> * @see org.apache.commons.jcs.engine.behavior.ICacheListener#handlePut(org.apache.commons.jcs.engine.behavior.ICacheElement) */ @Override public void handlePut( ICacheElement<K, V> element ) throws IOException { putCnt++; if ( log.isInfoEnabled() ) { if ( getPutCnt() % 100 == 0 ) { log.info( "Put Count (port " + getTcpLateralCacheAttributes().getTcpListenerPort() + ") = " + getPutCnt() ); } } if ( log.isDebugEnabled() ) { log.debug( "handlePut> cacheName=" + element.getCacheName() + ", key=" + element.getKey() ); } getCache( element.getCacheName() ).localUpdate( element ); }