asmuts      02/01/17 22:45:28

  Modified:    src/java/org/apache/stratum/jcs/access TestCacheAccess.java
               src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp
                        LateralTCPService.java LateralTCPSender.java
                        LateralTCPReceiverConnection.java
                        LateralTCPReceiver.java
                        LateralGroupCacheTCPListener.java
                        LateralCacheTCPListener.java
               src/java/org/apache/stratum/jcs/auxiliary/lateral
                        LateralElementDescriptor.java
                        LateralCacheNoWaitFacade.java LateralCache.java
               src/java/org/apache/stratum/jcs/utils/servlet/session
                        HttpServletRequestFacade.java
               src/java/org/apache/stratum/jcs/engine/control Cache.java
  Log:
  seeing if get is possible in this framework
  will try tomorrow, setting a test stage now
  
  Revision  Changes    Path
  1.7       +54 -45    
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/access/TestCacheAccess.java
  
  Index: TestCacheAccess.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/access/TestCacheAccess.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- TestCacheAccess.java      18 Jan 2002 02:11:32 -0000      1.6
  +++ TestCacheAccess.java      18 Jan 2002 06:45:27 -0000      1.7
  @@ -11,28 +11,28 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  + * notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  + * notice, this list of conditions and the following disclaimer in
  + * the documentation and/or other materials provided with the
  + * distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  + * any, must include the following acknowlegement:
  + * "This product includes software developed by the
  + * Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowlegement may appear in the software itself,
  + * if and wherever such third-party acknowlegements normally appear.
    *
    * 4. The names "The Jakarta Project", "Velocity", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact [EMAIL PROTECTED]
  + * Foundation" must not be used to endorse or promote products derived
  + * from this software without prior written permission. For written
  + * permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  + * nor may "Apache" appear in their names without prior written
  + * permission of the Apache Group.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  @@ -79,7 +79,7 @@
    *  Allows the user to run common cache commands fromt he command line for a
    *  test cache.
    *
  - *@author     asmuts
  + *@author     <a href="mailto:[EMAIL PROTECTED]";>Aaron Smuts</a>
    *@created    January 15, 2002
    */
   public class TestCacheAccess
  @@ -294,7 +294,8 @@
                               long n_start = System.currentTimeMillis();
                               try
                               {
  -                                Object obj = cache_control.getFromGroup( key, group 
);
  +                                Object obj = cache_control.getFromGroup( key,
  +                                    group );
                                   if ( show && obj != null )
                                   {
                                       p( obj.toString() );
  @@ -459,7 +460,9 @@
                               attrp.setFlags( attrp.LATERAL );
                               attrp.setFlags( attrp.REMOTE );
                               long n_start = System.currentTimeMillis();
  -                            cache_control.putInGroup( key, group, "data from putg 
----asdfasfas-asfasfas-asfas in group " + group, attrp.copy() );
  +                            cache_control.putInGroup( key,
  +                                group,
  +                                "data from putg ----asdfasfas-asfasfas-asfas in 
group " + group, attrp.copy() );
                               long n_end = System.currentTimeMillis();
                               p( "---put " + key + " in group " + group + " in " + 
String.valueOf( n_end - n_start ) + " millis ---" );
                           }
  @@ -500,7 +503,9 @@
                               long n_start = System.currentTimeMillis();
                               for ( int a = 0; a < num; a++ )
                               {
  -                                cache_control.putInGroup( "keygr" + a, group, "data 
" + a + " from putag ----asdfasfas-asfasfas-asfas in group " + group, attrp.copy() );
  +                                cache_control.putInGroup( "keygr" + a,
  +                                    group,
  +                                    "data " + a + " from putag 
----asdfasfas-asfasfas-asfas in group " + group, attrp.copy() );
                               }
                               long n_end = System.currentTimeMillis();
                               p( "---put " + num + " in group " + group + " in " + 
String.valueOf( n_end - n_start ) + " millis ---" );
  @@ -523,7 +528,8 @@
                               long n_start = System.currentTimeMillis();
                               for ( int n = 0; n < num; n++ )
                               {
  -                                cache_control.put( "key" + n, "data" + n + " put 
from ta = junk", attrp.copy() );
  +                                cache_control.put( "key" + n,
  +                                    "data" + n + " put from ta = junk", 
attrp.copy() );
                               }
                               long n_end = System.currentTimeMillis();
                               p( "---put " + num + " in " + String.valueOf( n_end - 
n_start ) + " millis ---" );
  @@ -599,24 +605,25 @@
                           if ( message.startsWith( "switch" ) )
                       {
                           String numS = message.substring( message.indexOf( " " ) + 
1, message.length() );
  -                        try {
  -                        int num = Integer.parseInt( numS.trim() );
  +                        try
  +                        {
  +                            int num = Integer.parseInt( numS.trim() );
                           }
                           catch ( Exception e )
                           {
  -                          p( "usage: switch number" );
  -                          p( "  1 == testCache1" );
  +                            p( "usage: switch number" );
  +                            p( "  1 == testCache1" );
                           }
                           if ( numS == null )
                           {
  -                          p( "usage: switch number" );
  -                          p( "  1 == testCache1" );
  +                            p( "usage: switch number" );
  +                            p( "  1 == testCache1" );
                           }
                           else
                           {
  -                             cache_control = GroupCacheAccess.getGroupAccess( 
"testCache" + numS );
  -                             p( "switched to cache = " + "testCache" + numS );
  -                             p( cache_control.toString() );
  +                            cache_control = GroupCacheAccess.getGroupAccess( 
"testCache" + numS );
  +                            p( "switched to cache = " + "testCache" + numS );
  +                            p( cache_control.toString() );
                           }
                       }
                   }
  @@ -636,6 +643,7 @@
           }
   
       }
  +
       // end main
   
   
  @@ -677,23 +685,6 @@
           p( "type 'help' for commands" );
   
       }
  -    // end help
  -
  -    /////////////////////////////////////////////
  -    /**
  -     *  Gets the attributeNames attribute of the TestCacheAccess class
  -     *
  -     *@param  groupName  Description of the Parameter
  -     */
  -    static void getAttributeNames( String groupName )
  -    {
  -        Enumeration enum = cache_control.getAttributeNames( groupName );
  -        p( "enum = " + enum );
  -        while ( enum.hasMoreElements() )
  -        {
  -            p( "=" + ( String ) enum.nextElement() );
  -        }
  -    }
   
   
       ////////////////////////////////////////
  @@ -725,6 +716,24 @@
   
           cache_control.removeLateralDirect( key );
           p( "called delete multicast for key " + key );
  +    }
  +
  +    // end help
  +
  +    /////////////////////////////////////////////
  +    /**
  +     *  Gets the attributeNames attribute of the TestCacheAccess class
  +     *
  +     *@param  groupName  Description of the Parameter
  +     */
  +    static void getAttributeNames( String groupName )
  +    {
  +        Enumeration enum = cache_control.getAttributeNames( groupName );
  +        p( "enum = " + enum );
  +        while ( enum.hasMoreElements() )
  +        {
  +            p( "=" + ( String ) enum.nextElement() );
  +        }
       }
   
   }
  
  
  
  1.4       +38 -21    
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
  
  Index: LateralTCPService.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LateralTCPService.java    15 Jan 2002 21:33:31 -0000      1.3
  +++ LateralTCPService.java    18 Jan 2002 06:45:27 -0000      1.4
  @@ -25,7 +25,7 @@
   import org.apache.stratum.jcs.utils.log.LoggerManager;
   
   /**
  - *  Description of the Class
  + *  A lateral cache service implementation.
    *
    *@author     asmuts
    *@created    January 15, 2002
  @@ -33,7 +33,7 @@
   public class LateralTCPService implements ILateralCacheService, 
ILateralCacheObserver
   {
   
  -    private static boolean debug = false;
  +    private static boolean debug = false;//true;
   
       private static Logger log = LoggerManager.getLogger( LateralTCPSender.class );
       private ILateralCacheAttributes ilca;
  @@ -55,7 +55,7 @@
           {
               if ( debug )
               {
  -                p( "creating sendered" );
  +                p( "creating sender" );
               }
               sender = new LateralTCPSender( lca );
               if ( debug )
  @@ -164,7 +164,7 @@
   
   
       /**
  -     *  Description of the Method
  +     *  Will close the connection.
        *
        *@param  cache            Description of the Parameter
        *@exception  IOException  Description of the Exception
  @@ -172,8 +172,7 @@
       public void dispose( String cache )
           throws IOException
       {
  -        //sender = null;
  -        // nothing needs to be done
  +        sender.dispose( cache );
       }
   
   
  @@ -181,13 +180,15 @@
       /**
        *  Description of the Method
        *
  -     *@param  cache            Description of the Parameter
  +     *@param  key              Description of the Parameter
        *@return                  Description of the Return Value
        *@exception  IOException  Description of the Exception
        */
  -    public Serializable get( String cache )
  +    public Serializable get( String key )
           throws IOException
       {
  +        //p( "junk get" );
  +        //return get( cattr.cacheName, key, true );
           return null;
           // nothing needs to be done
       }
  @@ -197,33 +198,41 @@
       /**
        *  Description of the Method
        *
  -     *@param  cache            Description of the Parameter
  -     *@param  att              Description of the Parameter
  +     *@param  cacheName        Description of the Parameter
  +     *@param  key              Description of the Parameter
        *@return                  Description of the Return Value
        *@exception  IOException  Description of the Exception
        */
  -    public Serializable get( String cache, Serializable att )
  +    public Serializable get( String cacheName, Serializable key )
           throws IOException
       {
  -        return null;
  +        //p( "get(cacheName,key)" );
  +        return get( cacheName, key, true );
           // nothing needs to be done
       }
   
       ///////////////////////////////////////////////////////////////
   
       /**
  -     *  Description of the Method
  +     *  An expiremental get implementation. By default it should be off.
        *
  -     *@param  cache            Description of the Parameter
  -     *@param  att              Description of the Parameter
        *@param  container        Description of the Parameter
  +     *@param  cacheName        Description of the Parameter
  +     *@param  key              Description of the Parameter
        *@return                  Description of the Return Value
        *@exception  IOException  Description of the Exception
        */
  -    public Serializable get( String cache, Serializable att, boolean container )
  +    public Serializable get( String cacheName, Serializable key, boolean container )
           throws IOException
       {
  -        return null;
  +
  +        //p( "get(cacheName,key,container)" );
  +        CacheElement ce = new CacheElement( cacheName, key, null );
  +        LateralElementDescriptor led = new LateralElementDescriptor( ce );
  +        //led.requesterId = requesterId; // later
  +        led.command = led.GET;
  +        return sender.sendAndReceive( led );
  +        //return null;
           // nothing needs to be done
       }
   
  @@ -308,7 +317,9 @@
        *@exception  IOException  Description of the Exception
        */
       public void addCacheListener( String cacheName, ICacheListener obj )
  -        throws IOException { }
  +        throws IOException
  +    {
  +    }
   
   
       /**
  @@ -320,7 +331,9 @@
        *@exception  IOException  Description of the Exception
        */
       public void addCacheListener( ICacheListener obj )
  -        throws IOException { }
  +        throws IOException
  +    {
  +    }
   
   
       /**
  @@ -331,7 +344,9 @@
        *@exception  IOException  Description of the Exception
        */
       public void removeCacheListener( String cacheName, ICacheListener obj )
  -        throws IOException { }
  +        throws IOException
  +    {
  +    }
   
   
       /**
  @@ -341,7 +356,9 @@
        *@exception  IOException  Description of the Exception
        */
       public void removeCacheListener( ICacheListener obj )
  -        throws IOException { }
  +        throws IOException
  +    {
  +    }
   
   }
   // end class
  
  
  
  1.4       +81 -5     
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java
  
  Index: LateralTCPSender.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralTCPSender.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LateralTCPSender.java     15 Jan 2002 21:33:31 -0000      1.3
  +++ LateralTCPSender.java     18 Jan 2002 06:45:27 -0000      1.4
  @@ -4,6 +4,7 @@
   import java.io.InputStream;
   import java.io.InputStreamReader;
   import java.io.IOException;
  +import java.io.ObjectInputStream;
   import java.io.ObjectOutputStream;
   import java.io.OutputStream;
   import java.io.Reader;
  @@ -35,7 +36,6 @@
   {
   
       private final static boolean debug = false;
  -    // true;
   
       private static Logger log = LoggerManager.getLogger( LateralTCPSender.class );
   
  @@ -45,6 +45,7 @@
       private InetAddress address;
       int port = 1111;
       private ObjectOutputStream oos;
  +    private Socket socket;
       int counter = 0;
   
       // reset the ObjectOutputStream every 70 calls
  @@ -88,7 +89,6 @@
   
           try
           {
  -            Socket socket;
               log.debug( "Attempting connection to " + address.getHostName() );
               socket = new Socket( address, port );
               synchronized ( this )
  @@ -134,7 +134,7 @@
   
       ///////////////////////////////////////////////////////
       /**
  -     *  Description of the Method
  +     *  Sends commands to the lateral cache listener.
        *
        *@param  led              Description of the Parameter
        *@exception  IOException  Description of the Exception
  @@ -184,6 +184,78 @@
       }
   
   
  +    ///////////////////////////////////////////////////////
  +    /**
  +     *  Sends commands to the lateral cache listener.
  +     *
  +     *@param  led              Description of the Parameter
  +     *@return                  Description of the Return Value
  +     *@exception  IOException  Description of the Exception
  +     */
  +    public Serializable sendAndReceive( LateralElementDescriptor led )
  +        throws IOException
  +    {
  +
  +        ICacheElement ice = null;
  +        if ( debug )
  +        {
  +            p( "sendAndReceive led" );
  +        }
  +
  +        if ( led == null )
  +        {
  +            return null;
  +        }
  +
  +        if ( address == null )
  +        {
  +            throw new IOException( "No remote host is set for LateralTCPSender." );
  +            //return;
  +        }
  +
  +        if ( oos != null )
  +        {
  +            try
  +            {
  +                oos.writeObject( led );
  +                oos.flush();
  +
  +                try
  +                {
  +                    ObjectInputStream ois = new ObjectInputStream( 
socket.getInputStream() );
  +                    Object obj = ois.readObject();
  +                    ice = ( ICacheElement ) obj;
  +                    if ( ice == null )
  +                    {
  +                        p( "ice is null" );
  +                    }
  +
  +                }
  +                catch ( Exception e )
  +                {
  +                    log.error( e, "Could not open ObjectInputStream to " + socket );
  +                }
  +
  +                if ( ++counter >= RESET_FREQUENCY )
  +                {
  +                    counter = 0;
  +                    // Failing to reset the object output stream every now and
  +                    // then creates a serious memory leak.
  +                    log.info( "Doing oos.reset()" );
  +                    oos.reset();
  +                }
  +            }
  +            catch ( IOException e )
  +            {
  +                oos = null;
  +                log.error( "Detected problem with connection: " + e );
  +                throw e;
  +            }
  +        }
  +        return ice;
  +    }// end sendAndReceive
  +
  +
       ///////////////////////////////////////////////
       /**
        *  Description of the Method
  @@ -263,7 +335,10 @@
   
   
       /**
  -     *  Description of the Method
  +     *  Closes connection used by all LateralTCPSenders for this lateral
  +     *  conneciton. Dispose request should come into the facade and be sent to
  +     *  all lateral cache sevices. The lateral cache service will then call this
  +     *  method.
        *
        *@param  cache            Description of the Parameter
        *@exception  IOException  Description of the Exception
  @@ -271,7 +346,8 @@
       public void dispose( String cache )
           throws IOException
       {
  -        // nothing needs to be done
  +        // WILL CLOSE CONNECTION USED BY ALL
  +        oos.close();
       }
   
   
  
  
  
  1.4       +37 -3     
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralTCPReceiverConnection.java
  
  Index: LateralTCPReceiverConnection.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralTCPReceiverConnection.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LateralTCPReceiverConnection.java 15 Jan 2002 21:33:31 -0000      1.3
  +++ LateralTCPReceiverConnection.java 18 Jan 2002 06:45:27 -0000      1.4
  @@ -1,13 +1,16 @@
   package org.apache.stratum.jcs.auxiliary.lateral.socket.tcp;
   
   import java.io.InputStream;
  +import java.io.IOException;
   import java.io.ObjectInputStream;
  +import java.io.ObjectOutputStream;
  +import java.io.Serializable;
   import java.net.Socket;
   
   import org.apache.stratum.jcs.auxiliary.lateral.LateralCacheInfo;
   import org.apache.stratum.jcs.auxiliary.lateral.LateralElementDescriptor;
   
  -import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
  +import 
org.apache.stratum.jcs.auxiliary.lateral.socket.tcp.behavior.ILateralCacheTCPListener;
   
   import org.apache.stratum.jcs.utils.log.Logger;
   import org.apache.stratum.jcs.utils.log.LoggerManager;
  @@ -34,7 +37,7 @@
       private Socket socket;
       private ObjectInputStream ois;
   
  -    private ILateralCacheListener ilcl;
  +    private ILateralCacheTCPListener ilcl;
       private final static Logger log = LoggerManager.getLogger( 
"lateral_lateralcachemanager" );
   
       private int puts = 0;
  @@ -47,7 +50,7 @@
        *@param  socket  Description of the Parameter
        *@param  ilcl    Description of the Parameter
        */
  -    public LateralTCPReceiverConnection( Socket socket, ILateralCacheListener ilcl )
  +    public LateralTCPReceiverConnection( Socket socket, ILateralCacheTCPListener 
ilcl )
       {
           this.ilcl = ilcl;
           this.socket = socket;
  @@ -118,6 +121,12 @@
                       {
                           ilcl.handleRemove( led.ce.getCacheName(), led.ce.getKey() );
                       }
  +//                    else
  +//                        if ( led.command == led.GET )
  +//                    {
  +//                        // getAndRespond( led.ce.getCacheName(), led.ce.getKey() 
);
  +//                        //ilcl.handleGet( led.ce.getCacheName(), led.ce.getKey() 
);
  +//                    }
                   }
               }
           }
  @@ -144,6 +153,31 @@
           }
       }
   
  +
  +    /**
  +     *  Send back the object if found.
  +     */
  +    private Serializable getAndRespond( String cacheName, Serializable key ) throws 
Exception
  +    {
  +        Serializable obj = ilcl.handleGet( cacheName, key );
  +
  +//        ObjectOutputStream oos = new ObjectOutputStream( socket.getOutputStream() 
);
  +//        if ( oos != null )
  +//        {
  +//            try
  +//            {
  +//                oos.writeObject( obj );
  +//                oos.flush();
  +//            }
  +//            catch ( IOException e )
  +//            {
  +//                oos = null;
  +//                log.error( "Detected problem with connection: " + e );
  +//                throw e;
  +//            }
  +//        }
  +        return obj;
  +    }
   
       ///////////////////////////////////////////////
       /**
  
  
  
  1.4       +3 -3      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralTCPReceiver.java
  
  Index: LateralTCPReceiver.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralTCPReceiver.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LateralTCPReceiver.java   15 Jan 2002 21:33:31 -0000      1.3
  +++ LateralTCPReceiver.java   18 Jan 2002 06:45:27 -0000      1.4
  @@ -5,7 +5,7 @@
   import java.net.Socket;
   
   import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
  -import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
  +import 
org.apache.stratum.jcs.auxiliary.lateral.socket.tcp.behavior.ILateralCacheTCPListener;
   
   import org.apache.stratum.jcs.utils.log.Logger;
   import org.apache.stratum.jcs.utils.log.LoggerManager;
  @@ -25,7 +25,7 @@
   
       private int port;
       private final static Logger log = LoggerManager.getLogger( 
"lateral_lateralcachemanager" );
  -    private ILateralCacheListener ilcl;
  +    private ILateralCacheTCPListener ilcl;
   
   
       ////////////////////////////////////////////////
  @@ -75,7 +75,7 @@
        *@param  lca   Description of the Parameter
        *@param  ilcl  Description of the Parameter
        */
  -    public LateralTCPReceiver( ILateralCacheAttributes lca, ILateralCacheListener 
ilcl )
  +    public LateralTCPReceiver( ILateralCacheAttributes lca, 
ILateralCacheTCPListener ilcl )
       {
           this.port = lca.getTcpListenerPort();
           this.ilcl = ilcl;
  
  
  
  1.4       +3 -2      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralGroupCacheTCPListener.java
  
  Index: LateralGroupCacheTCPListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralGroupCacheTCPListener.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LateralGroupCacheTCPListener.java 15 Jan 2002 21:33:31 -0000      1.3
  +++ LateralGroupCacheTCPListener.java 18 Jan 2002 06:45:27 -0000      1.4
  @@ -2,6 +2,7 @@
   
   import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
   import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
  +import 
org.apache.stratum.jcs.auxiliary.lateral.socket.tcp.behavior.ILateralCacheTCPListener;
   
   import org.apache.stratum.jcs.engine.behavior.ICompositeCacheManager;
   import org.apache.stratum.jcs.engine.behavior.ICacheType;
  @@ -10,14 +11,14 @@
   import org.apache.stratum.jcs.engine.group.GroupCacheManagerFactory;
   
   /**
  - *  Title: Description: Copyright: Copyright (c) 2001 Company:
  + *
    *
    *@author
    *@created    January 15, 2002
    *@version    1.0
    */
   
  -public class LateralGroupCacheTCPListener extends LateralCacheTCPListener 
implements ILateralCacheListener
  +public class LateralGroupCacheTCPListener extends LateralCacheTCPListener 
implements ILateralCacheTCPListener
   {
   
       ///////////////////////////////////////////
  
  
  
  1.5       +24 -3     
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralCacheTCPListener.java
  
  Index: LateralCacheTCPListener.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/socket/tcp/LateralCacheTCPListener.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LateralCacheTCPListener.java      18 Jan 2002 02:11:32 -0000      1.4
  +++ LateralCacheTCPListener.java      18 Jan 2002 06:45:27 -0000      1.5
  @@ -10,6 +10,7 @@
   
   import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheAttributes;
   import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheListener;
  +import 
org.apache.stratum.jcs.auxiliary.lateral.socket.tcp.behavior.ILateralCacheTCPListener;
   
   import org.apache.stratum.jcs.engine.behavior.ICache;
   import org.apache.stratum.jcs.engine.behavior.ICacheElement;
  @@ -33,18 +34,18 @@
    *@author     asmuts
    *@created    January 15, 2002
    */
  -public class LateralCacheTCPListener implements ILateralCacheListener, Serializable
  +public class LateralCacheTCPListener implements ILateralCacheTCPListener, 
Serializable
   {
   
       /**
        *  Description of the Field
        */
  -    protected final static boolean debug = false;
  +    protected final static boolean debug = false;//true;
   
       /**
        *  Description of the Field
        */
  -    protected final static boolean debugcmd = false;
  +    protected final static boolean debugcmd = false;//true;
   
       /**
        *  Description of the Field
  @@ -244,6 +245,26 @@
           cache.removeAll();
       }
   
  +    //////////////////////////////////////////////////
  +    /**
  +     *  Test get implementation.
  +     *
  +     *@param  cacheName        Description of the Parameter
  +     *@param  key              Description of the Parameter
  +     *@return                  Description of the Return Value
  +     *@exception  IOException  Description of the Exception
  +     */
  +    public Serializable handleGet( String cacheName, Serializable key )
  +        throws IOException
  +    {
  +        if ( debug )
  +        {
  +            log.debug( "handleGet> cacheName=" + cacheName + ", key = " + key );
  +        }
  +        getCacheManager();
  +        ICache cache = cacheMgr.getCache( cacheName );
  +        return cache.get( key, ICache.REMOTE_INVOKATION );
  +    }
   
       ///////////////////////////////////////////////////
       /**
  
  
  
  1.4       +8 -1      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralElementDescriptor.java
  
  Index: LateralElementDescriptor.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralElementDescriptor.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LateralElementDescriptor.java     15 Jan 2002 21:33:30 -0000      1.3
  +++ LateralElementDescriptor.java     18 Jan 2002 06:45:27 -0000      1.4
  @@ -33,6 +33,11 @@
       public final static int DISPOSE = 4;
   
       /**
  +     *  Command to return an object.
  +     */
  +    public final static int GET = 5;
  +
  +    /**
        *  Description of the Field
        */
       public ICacheElement ce;
  @@ -52,7 +57,9 @@
       /**
        *  Constructor for the LateralElementDescriptor object
        */
  -    public LateralElementDescriptor() { }
  +    public LateralElementDescriptor()
  +    {
  +    }
   
   
       /////////////////////////////////////
  
  
  
  1.4       +8 -2      
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java
  
  Index: LateralCacheNoWaitFacade.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- LateralCacheNoWaitFacade.java     15 Jan 2002 21:33:30 -0000      1.3
  +++ LateralCacheNoWaitFacade.java     18 Jan 2002 06:45:27 -0000      1.4
  @@ -28,8 +28,7 @@
   public class LateralCacheNoWaitFacade implements ICache
   {
   
  -    private final static boolean debug = false;
  -    //true;
  +    private final static boolean debug = false;//true;
   
       /**
        *  Description of the Field
  @@ -158,8 +157,15 @@
               try
               {
                   Object obj = noWaits[i].get( key, container );
  +                if ( debug )
  +                {
  +                    p( "obj = " + obj );
  +                }
                   if ( obj != null )
                   {
  +                    // return after first success
  +                    // could do this simultaneously
  +                    // serious blocking risk here
                       return ( Serializable ) obj;
                   }
               }
  
  
  
  1.5       +22 -12    
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCache.java
  
  Index: LateralCache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCache.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- LateralCache.java 18 Jan 2002 01:53:11 -0000      1.4
  +++ LateralCache.java 18 Jan 2002 06:45:27 -0000      1.5
  @@ -189,7 +189,6 @@
       }
       // end update
   
  -
       /**
        *  Return null. The performace costs are too great. Can implement later.
        *
  @@ -200,17 +199,14 @@
       public Serializable get( Serializable key )
           throws IOException
       {
  +        //p( "get(key)" );
  +        //return get( key, true );
           return null;
  -        //try {
  -        //} catch ( Exception e ) {
  -        //  log.debug( "didn't find element " + key + "" );
  -        //  return null;
  -        //}
       }
   
   
       /**
  -     * Returns <code>null</code>.
  +     *  Returns <code>null</code> .
        *
        *@param  key              Description of the Parameter
        *@param  container        Description of the Parameter
  @@ -221,6 +217,18 @@
           throws IOException
       {
           return null;
  +//        //p( "get(key,container)" );
  +//        Serializable obj = null;
  +//        try
  +//        {
  +//            obj = lateral.get( cacheName, key, container );
  +//        }
  +//        catch ( Exception e )
  +//        {
  +//            log.error( e );
  +//            // do something with this
  +//        }
  +//        return obj;
       }
   
   
  @@ -276,7 +284,7 @@
   
   
       /**
  -     *  Synchronously dispose the cache.
  +     *  Synchronously dispose the cache. Not sure we want this.
        *
        *@exception  IOException  Description of the Exception
        */
  @@ -284,18 +292,20 @@
           throws IOException
       {
           p( "disposing of lateral cache" );
  -        /* HELP: This section did nothing but generate compilation warnings.
  +        ///* HELP: This section did nothing but generate compilation warnings.
  +        // TODO: may limit this funcionality. It is dangerous.
  +        // asmuts -- Added functionality to help with warnings.  I'm not getting 
any.
           try
           {
  -            // Should remove cache from multicast group
  +            lateral.dispose( cattr.getCacheName() );
  +            // Should remove connection
           }
           catch ( Exception ex )
           {
               p( "couldn't dispose" );
               handleException( ex, "Failed to dispose " + cattr.getCacheName() );
  -            //remote = null;
           }
  -        */
  +        //*/
       }
   
   
  
  
  
  1.7       +38 -37    
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/servlet/session/HttpServletRequestFacade.java
  
  Index: HttpServletRequestFacade.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/utils/servlet/session/HttpServletRequestFacade.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- HttpServletRequestFacade.java     18 Jan 2002 02:22:06 -0000      1.6
  +++ HttpServletRequestFacade.java     18 Jan 2002 06:45:27 -0000      1.7
  @@ -25,12 +25,12 @@
   import org.apache.stratum.jcs.utils.servlet.session.MetaHttpSession;
   
   /**
  - * Session wrapper, to overide some methods.  Servlet 2.3 has an
  - * easier way to do this.
  + *  Session wrapper, to overide some methods. Servlet 2.3 has an easier way to
  + *  do this.
    *
  - * @author asmuts
  - * @author <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  - * @created January 15, 2002
  + *@author     <a href="mailto:[EMAIL PROTECTED]";>Aaron Smuts</a>
  + *@author     <a href="mailto:[EMAIL PROTECTED]";>Daniel Rall</a>
  + *@created    January 15, 2002
    */
   public class HttpServletRequestFacade implements HttpServletRequest
   {
  @@ -129,33 +129,31 @@
       public String getCharacterEncoding()
       {
           // FUTURE: Always delegate when we switch to servlet api 2.3
  -        return (characterEncoding != null ? characterEncoding :
  -                req.getCharacterEncoding());
  +        return ( characterEncoding != null ? characterEncoding :
  +            req.getCharacterEncoding() );
       }
   
   
       /**
  -     * Overrides the name of the character encoding used in the body of
  -     * this request.  This method must be called prior to reading request
  -     * parameters or reading input using <code>getReader()</code>.
  +     *  Overrides the name of the character encoding used in the body of this
  +     *  request. This method must be called prior to reading request parameters
  +     *  or reading input using <code>getReader()</code> . NOTE: This method will
  +     *  not modify the underlying request until Servlet API 2.3 is adopted.
        *
  -     * NOTE: This method will not modify the underlying request until
  -     * Servlet API 2.3 is adopted.
  -     *
  -     * @param enc The character encoding to be used
  -     *
  -     * @exception UnsupportedEncodingException If the specified
  -     * encoding is not supported.
  +     *@param  enc                               The character encoding to be
  +     *      used
  +     *@exception  UnsupportedEncodingException  If the specified encoding is not
  +     *      supported.
        */
  -    public void setCharacterEncoding(String enc)
  +    public void setCharacterEncoding( String enc )
           throws UnsupportedEncodingException
       {
           // FUTURE: Call req.setCharacterEncoding(enc) for servlet api 2.3
   
           // Ensure that the specified encoding is valid
           byte buffer[] = new byte[1];
  -        buffer[0] = (byte) 'a';
  -        String dummy = new String(buffer, enc);
  +        buffer[0] = ( byte ) 'a';
  +        String dummy = new String( buffer, enc );
   
           // Save the validated encoding
           this.characterEncoding = enc;
  @@ -234,8 +232,10 @@
   
   
       /**
  -     * The implementation of this method will remain somewhat
  -     * expensive until Servlet API 2.3 is adopted.
  +     *  The implementation of this method will remain somewhat expensive until
  +     *  Servlet API 2.3 is adopted.
  +     *
  +     *@return    The {3} value
        */
       public Map getParameterMap()
       {
  @@ -244,10 +244,10 @@
           Map params = new HashMap();
           Enumeration enum = req.getParameterNames();
           String name;
  -        while (enum.hasMoreElements())
  +        while ( enum.hasMoreElements() )
           {
  -            name = (String) enum.nextElement();
  -            params.put(name, req.getParameterValues(name));
  +            name = ( String ) enum.nextElement();
  +            params.put( name, req.getParameterValues( name ) );
           }
           return params;
       }
  @@ -608,9 +608,9 @@
   
   
       /**
  -     * Gets the full request URL.
  +     *  Gets the full request URL.
        *
  -     * @return A new buffer containing the reconstructed URL.
  +     *@return    A new buffer containing the reconstructed URL.
        */
       public StringBuffer getRequestURL()
       {
  @@ -620,21 +620,22 @@
           StringBuffer url = new StringBuffer();
           String scheme = req.getScheme();
           int port = req.getServerPort();
  -        if (port < 0)
  +        if ( port < 0 )
           {
               // Work around java.net.URL bug
               port = 80;
           }
   
  -        url.append(scheme);
  -        url.append("://");
  -        url.append(req.getServerName());
  -        if ((scheme.equals("http") && (port != 80))
  -            || (scheme.equals("https") && (port != 443))) {
  -            url.append(':');
  -            url.append(port);
  +        url.append( scheme );
  +        url.append( "://" );
  +        url.append( req.getServerName() );
  +        if ( ( scheme.equals( "http" ) && ( port != 80 ) )
  +             || ( scheme.equals( "https" ) && ( port != 443 ) ) )
  +        {
  +            url.append( ':' );
  +            url.append( port );
           }
  -        url.append(req.getRequestURI());
  +        url.append( req.getRequestURI() );
           return url;
       }
   
  @@ -658,7 +659,7 @@
        */
       public boolean isRequestedSessionIdValid()
       {
  -        return dst.isRequestedSessionIdValid(this);
  +        return dst.isRequestedSessionIdValid( this );
       }
   
   
  
  
  
  1.7       +38 -35    
jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java
  
  Index: Cache.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/engine/control/Cache.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- Cache.java        17 Jan 2002 22:45:52 -0000      1.6
  +++ Cache.java        18 Jan 2002 06:45:27 -0000      1.7
  @@ -11,28 +11,28 @@
    * are met:
    *
    * 1. Redistributions of source code must retain the above copyright
  - *    notice, this list of conditions and the following disclaimer.
  + * notice, this list of conditions and the following disclaimer.
    *
    * 2. Redistributions in binary form must reproduce the above copyright
  - *    notice, this list of conditions and the following disclaimer in
  - *    the documentation and/or other materials provided with the
  - *    distribution.
  + * notice, this list of conditions and the following disclaimer in
  + * the documentation and/or other materials provided with the
  + * distribution.
    *
    * 3. The end-user documentation included with the redistribution, if
  - *    any, must include the following acknowlegement:
  - *       "This product includes software developed by the
  - *        Apache Software Foundation (http://www.apache.org/)."
  - *    Alternately, this acknowlegement may appear in the software itself,
  - *    if and wherever such third-party acknowlegements normally appear.
  + * any, must include the following acknowlegement:
  + * "This product includes software developed by the
  + * Apache Software Foundation (http://www.apache.org/)."
  + * Alternately, this acknowlegement may appear in the software itself,
  + * if and wherever such third-party acknowlegements normally appear.
    *
    * 4. The names "The Jakarta Project", "Velocity", and "Apache Software
  - *    Foundation" must not be used to endorse or promote products derived
  - *    from this software without prior written permission. For written
  - *    permission, please contact [EMAIL PROTECTED]
  + * Foundation" must not be used to endorse or promote products derived
  + * from this software without prior written permission. For written
  + * permission, please contact [EMAIL PROTECTED]
    *
    * 5. Products derived from this software may not be called "Apache"
  - *    nor may "Apache" appear in their names without prior written
  - *    permission of the Apache Group.
  + * nor may "Apache" appear in their names without prior written
  + * permission of the Apache Group.
    *
    * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED
    * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
  @@ -54,7 +54,6 @@
    * <http://www.apache.org/>.
    */
   
  -
   import java.io.IOException;
   import java.io.Serializable;
   
  @@ -82,12 +81,10 @@
   import org.apache.stratum.jcs.utils.log.Logger;
   import org.apache.stratum.jcs.utils.log.LoggerManager;
   
  -
  -
   //////////////////////////////////////////////////////
   /**
  - *  This is the primary cache hub.  It control the flow of items through the
  - *  cache.  The auxiliary and memory caches are plugged in here.
  + *  This is the primary cache hub. It control the flow of items through the
  + *  cache. The auxiliary and memory caches are plugged in here.
    *
    *@author     asmuts
    *@created    January 15, 2002
  @@ -96,8 +93,9 @@
   {
   
       /**
  -     * Development debugging parameters.  Calls should be removed by the compiler.
  -     * TODO: limit and replace with a less intrusive logging at a later stage.
  +     *  Development debugging parameters. Calls should be removed by the
  +     *  compiler. TODO: limit and replace with a less intrusive logging at a
  +     *  later stage.
        */
       private final static boolean debugcmd = false;//true;
       private final static boolean debugR = false;//true;
  @@ -128,7 +126,6 @@
   
       private String source_id = "org.apache.stratum.jcs.engine.control.Cache";
   
  -
       /**
        *  need to convert to log4j
        */
  @@ -290,8 +287,8 @@
       {
           if ( debugcmd )
           {
  -            p( "updateCaches(key,val,attr) > ICache.INCLUDE_REMOTE_CACHE= " + 
ICache.INCLUDE_REMOTE_CACHE + " key = " + key  );
  -         }
  +            p( "updateCaches(key,val,attr) > ICache.INCLUDE_REMOTE_CACHE= " + 
ICache.INCLUDE_REMOTE_CACHE + " key = " + key );
  +        }
   
           updateCaches( key, val, attr, ICache.INCLUDE_REMOTE_CACHE );
   
  @@ -314,8 +311,8 @@
   
           if ( debugcmd )
           {
  -            p( "updateCaches(key,val,attr,updateRemoteCache) > updateRemoteCache= " 
+ updateRemoteCache + " key = " + key  );
  -         }
  +            p( "updateCaches(key,val,attr,updateRemoteCache) > updateRemoteCache= " 
+ updateRemoteCache + " key = " + key );
  +        }
   
           CacheElement ce = new CacheElement( cacheName, key, val );
           ce.setAttributes( attr );
  @@ -335,8 +332,8 @@
       {
           if ( debugcmd )
           {
  -            p( "update(ce) > ICache.INCLUDE_REMOTE_CACHE= " + 
ICache.INCLUDE_REMOTE_CACHE + " key = " + ce.getKey()  );
  -         }
  +            p( "update(ce) > ICache.INCLUDE_REMOTE_CACHE= " + 
ICache.INCLUDE_REMOTE_CACHE + " key = " + ce.getKey() );
  +        }
           update( ce, ICache.INCLUDE_REMOTE_CACHE );
       }
   
  @@ -352,10 +349,17 @@
       public void update( ICacheElement ce, boolean updateRemoteCache )
           throws IOException
       {
  -      updateExclude( ce, updateRemoteCache );
  +        updateExclude( ce, updateRemoteCache );
       }
   
   
  +    /**
  +     *  Description of the Method
  +     *
  +     *@param  ce                 Description of the Parameter
  +     *@param  updateRemoteCache  Description of the Parameter
  +     *@exception  IOException    Description of the Exception
  +     */
       public synchronized void updateExclude( ICacheElement ce, boolean 
updateRemoteCache )
           throws IOException
       {
  @@ -378,9 +382,11 @@
   
               if ( updateRemoteCache == ICache.INCLUDE_REMOTE_CACHE )
               {
  -              p( "updateRemoteCache is TRUE " + updateRemoteCache  );
  -            } else {
  -              p( "updateRemoteCache is FALSE " + updateRemoteCache );
  +                p( "updateRemoteCache is TRUE " + updateRemoteCache );
  +            }
  +            else
  +            {
  +                p( "updateRemoteCache is FALSE " + updateRemoteCache );
               }
           }
   
  @@ -515,7 +521,6 @@
       }
       // end spoolToDisk
   
  -
       /**
        *  Gets an item from the cache, and make it the first in the link list.
        *
  @@ -592,7 +597,6 @@
               {
                   // Item not found in memory.  Try the auxiliary caches if local.
   
  -
                   for ( int i = 0; i < auxCaches.length; i++ )
                   {
                       ICache aux = auxCaches[i];
  @@ -831,7 +835,6 @@
           return removed;
       }
       // end remove
  -
   
       /**
        *  Removes all cached items.
  
  
  

--
To unsubscribe, e-mail:   <mailto:[EMAIL PROTECTED]>
For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>

Reply via email to