/** * Wraps the key in a LateralElementDescriptor. * <p> * @see org.apache.commons.jcs.engine.behavior.ICacheServiceNonLocal#remove(String, Object, long) */ @Override public void remove( String cacheName, K key, long requesterId ) throws IOException { CacheElement<K, V> ce = new CacheElement<K, V>( cacheName, key, null ); LateralElementDescriptor<K, V> led = new LateralElementDescriptor<K, V>( ce ); led.requesterId = requesterId; led.command = LateralCommand.REMOVE; sender.send( led ); }
/** * Will close the connection. * <p> * @param cacheName * @throws IOException */ @Override public void dispose( String cacheName ) throws IOException { sender.dispose(); }
/** * Constructor for the LateralTCPSender object. * <p> * @param lca * @throws IOException */ public LateralTCPSender( ITCPLateralCacheAttributes lca ) throws IOException { this.socketOpenTimeOut = lca.getOpenTimeOut(); this.socketSoTimeOut = lca.getSocketTimeOut(); String p1 = lca.getTcpServer(); if ( p1 == null ) { throw new IOException( "Invalid server (null)" ); } String h2 = p1.substring( 0, p1.indexOf( ":" ) ); int po = Integer.parseInt( p1.substring( p1.indexOf( ":" ) + 1 ) ); if ( log.isDebugEnabled() ) { log.debug( "h2 = " + h2 ); log.debug( "po = " + po ); } if ( h2.length() == 0 ) { throw new IOException( "Cannot connect to invalid address [" + h2 + ":" + po + "]" ); } init( h2, po ); }
LateralTCPSender sender = new LateralTCPSender( new TCPLateralCacheAttributes() ); sender.send( led );
/** * Constructor for the LateralTCPService object * <p> * @param lca ITCPLateralCacheAttributes * @throws IOException */ public LateralTCPService( ITCPLateralCacheAttributes lca ) throws IOException { this.allowGet = lca.isAllowGet(); this.allowPut = lca.isAllowPut(); this.issueRemoveOnPut = lca.isIssueRemoveOnPut(); try { sender = new LateralTCPSender( lca ); if ( log.isInfoEnabled() ) { log.debug( "Created sender to [" + lca.getTcpServer() + "]" ); } } catch ( IOException e ) { // log.error( "Could not create sender", e ); // This gets thrown over and over in recovery mode. // The stack trace isn't useful here. log.error( "Could not create sender to [" + lca.getTcpServer() + "] -- " + e.getMessage() ); throw e; } }
Object response = sender.sendAndReceive( led ); if ( response != null )
LateralTCPSender sender = new LateralTCPSender( new TCPLateralCacheAttributes() ); sender.send( led );
/** * Constructor for the LateralTCPService object * <p> * @param lca ITCPLateralCacheAttributes * @throws IOException */ public LateralTCPService( ITCPLateralCacheAttributes lca ) throws IOException { this.allowGet = lca.isAllowGet(); this.allowPut = lca.isAllowPut(); this.issueRemoveOnPut = lca.isIssueRemoveOnPut(); try { sender = new LateralTCPSender( lca ); if ( log.isInfoEnabled() ) { log.debug( "Created sender to [" + lca.getTcpServer() + "]" ); } } catch ( IOException e ) { // log.error( "Could not create sender", e ); // This gets thrown over and over in recovery mode. // The stack trace isn't useful here. log.error( "Could not create sender to [" + lca.getTcpServer() + "] -- " + e.getMessage() ); throw e; } }
Object response = sender.sendAndReceive( led ); if ( response != null )
LateralTCPSender lur = new LateralTCPSender( lac ); led.command = LateralCommand.UPDATE; led.requesterId = 1; lur.send( led );
/** * @param cacheName * @param requesterId * @throws IOException */ @Override public void removeAll( String cacheName, long requesterId ) throws IOException { CacheElement<String, String> ce = new CacheElement<String, String>( cacheName, "ALL", null ); LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>( ce ); led.requesterId = requesterId; led.command = LateralCommand.REMOVEALL; sender.send( led ); }
/** * Return the keys in this cache. * <p> * @param cacheName the name of the cache region * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getKeySet() */ @Override @SuppressWarnings("unchecked") // Need cast from Object public Set<K> getKeySet(String cacheName) throws IOException { CacheElement<String, String> ce = new CacheElement<String, String>(cacheName, null, null); LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>(ce); // led.requesterId = requesterId; // later led.command = LateralCommand.GET_KEYSET; Object response = sender.sendAndReceive(led); if (response != null) { return (Set<K>) response; } return null; }
/** * Will close the connection. * <p> * @param cacheName * @throws IOException */ @Override public void dispose( String cacheName ) throws IOException { sender.dispose(); }
/** * Constructor for the LateralTCPSender object. * <p> * @param lca * @throws IOException */ public LateralTCPSender( ITCPLateralCacheAttributes lca ) throws IOException { this.socketOpenTimeOut = lca.getOpenTimeOut(); this.socketSoTimeOut = lca.getSocketTimeOut(); String p1 = lca.getTcpServer(); if ( p1 == null ) { throw new IOException( "Invalid server (null)" ); } String h2 = p1.substring( 0, p1.indexOf( ":" ) ); int po = Integer.parseInt( p1.substring( p1.indexOf( ":" ) + 1 ) ); if ( log.isDebugEnabled() ) { log.debug( "h2 = " + h2 ); log.debug( "po = " + po ); } if ( h2.length() == 0 ) { throw new IOException( "Cannot connect to invalid address [" + h2 + ":" + po + "]" ); } init( h2, po ); }
LateralTCPSender lur = new LateralTCPSender( lac ); led.command = LateralCommand.UPDATE; led.requesterId = 1; lur.send( led );
/** * Wraps the key in a LateralElementDescriptor. * <p> * @see org.apache.commons.jcs.engine.behavior.ICacheServiceNonLocal#remove(java.lang.String, * java.io.Serializable, long) */ @Override public void remove( String cacheName, K key, long requesterId ) throws IOException { CacheElement<K, V> ce = new CacheElement<K, V>( cacheName, key, null ); LateralElementDescriptor<K, V> led = new LateralElementDescriptor<K, V>( ce ); led.requesterId = requesterId; led.command = LateralCommand.REMOVE; sender.send( led ); }
/** * Return the keys in this cache. * <p> * @param cacheName the name of the cache region * @see org.apache.commons.jcs.auxiliary.AuxiliaryCache#getKeySet() */ @Override @SuppressWarnings("unchecked") // Need cast from Object public Set<K> getKeySet(String cacheName) throws IOException { CacheElement<String, String> ce = new CacheElement<String, String>(cacheName, null, null); LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>(ce); // led.requesterId = requesterId; // later led.command = LateralCommand.GET_KEYSET; Object response = sender.sendAndReceive(led); if (response != null) { return (Set<K>) response; } return null; }
/** * @param cacheName * @param requesterId * @throws IOException */ @Override public void removeAll( String cacheName, long requesterId ) throws IOException { CacheElement<String, String> ce = new CacheElement<String, String>( cacheName, "ALL", null ); LateralElementDescriptor<String, String> led = new LateralElementDescriptor<String, String>( ce ); led.requesterId = requesterId; led.command = LateralCommand.REMOVEALL; sender.send( led ); }
ICacheElement<K, V> response = (ICacheElement<K, V>)sender.sendAndReceive( led ); if ( response != null )