You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@turbine.apache.org by as...@apache.org on 2002/02/26 07:06:39 UTC

cvs commit: jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/behavior IXMLRPCConstants.java

asmuts      02/02/25 22:06:39

  Modified:    src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc
                        LateralXMLRPCSender.java
                        LateralXMLRPCReceiverConnection.java
               src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/behavior
                        IXMLRPCConstants.java
  Log:
  cleaned up null returns, fixed sendAndReceive
  xml-rpc works now, though the cache element is not a primitive type that a non-java program could use for this kind of text corba framework
  will do more later in method specialization and auto returns from non replying methods that should spawn threads
  it is very easy to use
  
  Revision  Changes    Path
  1.3       +13 -65    jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/LateralXMLRPCSender.java
  
  Index: LateralXMLRPCSender.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/LateralXMLRPCSender.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LateralXMLRPCSender.java	24 Feb 2002 08:20:37 -0000	1.2
  +++ LateralXMLRPCSender.java	26 Feb 2002 06:06:39 -0000	1.3
  @@ -41,7 +41,7 @@
    *
    * @author <a href="mailto:asmuts@yahoo.com">Aaron Smuts</a>
    * @created January 15, 2002
  - * @version $Id: LateralXMLRPCSender.java,v 1.2 2002/02/24 08:20:37 asmuts Exp $
  + * @version $Id: LateralXMLRPCSender.java,v 1.3 2002/02/26 06:06:39 asmuts Exp $
    */
   public class LateralXMLRPCSender implements IXMLRPCConstants
   {
  @@ -55,20 +55,8 @@
       int port = 1111;
   
       private XmlRpcClientLite xmlrpc;
  -    //private ObjectOutputStream oos;
  -    //private Socket socket;
       int counter = 0;
   
  -//    // reset the ObjectOutputStream every 70 calls
  -//    //private static final int RESET_FREQUENCY = 70;
  -//    private final static int RESET_FREQUENCY = 70;
  -//
  -//    /**
  -//     * Only block for 10 seconds before timing out on a read. TODO: make
  -//     * configurable. The default 10 it way too long.
  -//     */
  -//    private final static int timeOut = 10000;
  -//
       /**
        * Only block for 5 seconds before timing out on startup.
        */
  @@ -110,23 +98,14 @@
           try
           {
               log.debug( "Attempting connection to " + address.getHostName() + ":" + port );
  -            //socket = new Socket( address, port );
   
               xmlrpc = XMLRPCSocketOpener.openSocket( host, port, openTimeOut );
  -            //xmlrpc = new XmlRpcClientLite ( "http://" + host + ":" + port + "/RPC2" );
  -            //  have time out socket open do this for us
  -            //socket = SocketOpener.openSocket( host, port, openTimeOut );
   
               if ( xmlrpc == null )
               {
                   throw new IOException( "xmlrpc is null" );
               }
   
  -//            socket.setSoTimeout( this.timeOut );
  -//            synchronized ( this )
  -//            {
  -//                oos = new ObjectOutputStream( socket.getOutputStream() );
  -//            }
           }
           catch ( java.net.ConnectException e )
           {
  @@ -185,24 +164,11 @@
               //return;
           }
   
  -//        if ( oos != null )
  -//        {
           try
           {
               Vector params = new Vector();
               params.add( serialize( led ) );
               Object junk = xmlrpc.execute( this.HANDLERNAME + ".execute", params );
  -
  -//                oos.writeObject( led );
  -//                oos.flush();
  -//                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 )
           {
  @@ -215,7 +181,7 @@
               log.error( "Detected problem with connection: " + e );
               throw new IOException( e.getMessage() );
           }
  -//        }
  +
       }
   
   
  @@ -247,29 +213,25 @@
               //return;
           }
   
  -//        if ( oos != null )
  -//        {
           try
           {
  -//                oos.writeObject( led );
  -//                oos.flush();
   
               try
               {
  -//                    ObjectInputStream ois = new ObjectInputStream( socket.getInputStream() );
  -//                    Object obj = ois.readObject();
   
                   Vector params = new Vector();
                   // this should call another method
  -                params.add( serialize(led) );
  -                Object obj = xmlrpc.execute( this.HANDLERNAME, params );
  -                ice = ( ICacheElement ) obj;
  -                if ( ice == null )
  +                params.add( serialize( led ) );
  +                Object obj = xmlrpc.execute( IXMLRPCConstants.HANDLERNAME + ".execute", params );
  +                if ( !obj.equals( IXMLRPCConstants.NO_RESULTS ) )
                   {
  -                    //p( "ice is null" );
  -                    // TODO: coutn misses
  +                    ice = ( ICacheElement ) obj;
  +                    if ( ice == null )
  +                    {
  +                        //p( "ice is null" );
  +                        // TODO: coutn misses
  +                    }
                   }
  -
               }
               catch ( IOException ioe )
               {
  @@ -280,21 +242,7 @@
                   log.error( e );
               }
   
  -//                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;
  -//            }
  +        }
           catch ( Exception e )
           {
               log.error( "Detected problem with connection: " + e );
  @@ -452,7 +400,7 @@
       }
   
       /**
  -     * Description of the Method
  +     * To prepare elements for distribution
        *
        * @return
        * @param obj
  
  
  
  1.3       +43 -89    jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/LateralXMLRPCReceiverConnection.java
  
  Index: LateralXMLRPCReceiverConnection.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/LateralXMLRPCReceiverConnection.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- LateralXMLRPCReceiverConnection.java	24 Feb 2002 08:20:37 -0000	1.2
  +++ LateralXMLRPCReceiverConnection.java	26 Feb 2002 06:06:39 -0000	1.3
  @@ -67,6 +67,7 @@
   import org.apache.stratum.jcs.auxiliary.lateral.LateralElementDescriptor;
   
   import org.apache.stratum.jcs.auxiliary.lateral.xmlrpc.behavior.ILateralCacheXMLRPCListener;
  +import org.apache.stratum.jcs.auxiliary.lateral.xmlrpc.behavior.IXMLRPCConstants;
   
   import org.apache.commons.logging.Log;
   import org.apache.commons.logging.LogSource;
  @@ -80,28 +81,17 @@
    * @version $Id: LateralXMLRPCReceiverConnection.java,v 1.7 2002/02/15 04:33:37
    *      jtaylor Exp $
    */
  -public class LateralXMLRPCReceiverConnection implements XmlRpcHandler
  +public class LateralXMLRPCReceiverConnection implements XmlRpcHandler, IXMLRPCConstants
   {//implements Runnable
   
       private final static Log log =
           LogSource.getInstance( LateralXMLRPCReceiverConnection.class );
   
  -//    private Socket socket;
  -//    private ObjectInputStream ois;
  -
       private ILateralCacheXMLRPCListener ilcl;
  -//
  -//    private LateralElementDescriptor led;
   
       private int puts = 0;
   
  -//    /**
  -//     * Constructor for the LateralXMLRPCReceiverConnection object
  -//     *
  -//     * @param socket
  -//     * @param ilcl
  -//     */
  -    /**
  +     /**
        * Constructor for the LateralXMLRPCReceiverConnection object
        *
        * @param ilcl
  @@ -111,18 +101,6 @@
           this.ilcl = ilcl;
   
       }
  -    //        this.socket = socket;
  -//        this.led = led;
  -//
  -//        try
  -//        {
  -//            ois = new ObjectInputStream( socket.getInputStream() );
  -//        }
  -//        catch ( Exception e )
  -//        {
  -//            log.error( "Could not open ObjectInputStream to " + socket, e );
  -//        }
  -//    }
   
       /**
        * Description of the Method
  @@ -156,6 +134,7 @@
           {
               log.error( e );
           }
  +        // this should start a thread fo non gets?
           return executeImpl( led );
       }
   
  @@ -168,58 +147,53 @@
        */
       public Serializable executeImpl( LateralElementDescriptor led )
       {
  -        Serializable obj = null;
  -//        Object obj;
  +        Serializable obj = "junk return value";
   
           try
           {
  -//            while ( true )
  -//            {
  -//                obj = ois.readObject();
  -//                LateralElementDescriptor led = ( LateralElementDescriptor ) obj;
  -                if ( led == null )
  -                {
  -                    log.debug( "LateralElementDescriptor is null" );
  -                    //continue;
  -                }
  -                if ( led.requesterId == LateralCacheInfo.listenerId )
  +            if ( led == null )
  +            {
  +                log.debug( "LateralElementDescriptor is null" );
  +                //continue;
  +            }
  +            if ( led.requesterId == LateralCacheInfo.listenerId )
  +            {
  +                log.debug( "from self" );
  +            }
  +            else
  +            {
  +                if ( log.isDebugEnabled() )
                   {
  -                    log.debug( "from self" );
  +                    log.debug( "receiving LateralElementDescriptor from another, led = "
  +                         + ", led = " + led
  +                         + ", led.command = " + led.command
  +                         + ", led.ce = " + led.ce
  +                         + ", ilcl = " + ilcl );
                   }
  -                else
  +                if ( led.command == led.UPDATE )
                   {
  +                    puts++;
                       if ( log.isDebugEnabled() )
                       {
  -                        log.debug( "receiving LateralElementDescriptor from another, led = "
  -                             + ", led = " + led
  -                             + ", led.command = " + led.command
  -                             + ", led.ce = " + led.ce
  -                             + ", ilcl = " + ilcl );
  -                    }
  -                    if ( led.command == led.UPDATE )
  -                    {
  -                        puts++;
  -                        if ( log.isDebugEnabled() )
  +                        if ( puts % 100 == 0 )
                           {
  -                            if ( puts % 100 == 0 )
  -                            {
  -                                log.debug( "puts = " + puts );
  -                            }
  +                            log.debug( "puts = " + puts );
                           }
  -                        ilcl.handlePut( led.ce );
  -                    }
  -                    else
  -                        if ( led.command == led.REMOVE )
  -                    {
  -                        ilcl.handleRemove( led.ce.getCacheName(), led.ce.getKey() );
  -                    }
  -                    else
  -                        if ( led.command == led.GET )
  -                    {
  -                        obj = getAndRespond( led.ce.getCacheName(), led.ce.getKey() );
  -                        //ilcl.handleGet( led.ce.getCacheName(), led.ce.getKey() );
                       }
  +                    ilcl.handlePut( led.ce );
                   }
  +                else
  +                    if ( led.command == led.REMOVE )
  +                {
  +                    ilcl.handleRemove( led.ce.getCacheName(), led.ce.getKey() );
  +                }
  +                else
  +                    if ( led.command == led.GET )
  +                {
  +                    obj = getAndRespond( led.ce.getCacheName(), led.ce.getKey() );
  +                    //ilcl.handleGet( led.ce.getCacheName(), led.ce.getKey() );
  +                }
  +            }
   //            }
           }
           catch ( java.io.EOFException e )
  @@ -235,14 +209,6 @@
               log.error( "Unexpected exception. Closing conneciton", e );
           }
   
  -//        try
  -//        {
  -//            ois.close();
  -//        }
  -//        catch ( Exception e )
  -//        {
  -//            log.error( "Could not close connection", e );
  -//        }
           return obj;
       }
   
  @@ -265,22 +231,10 @@
               log.debug( "obj = " + obj );
           }
   
  -//        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;
  -//            }
  -//        }
  +        if ( obj == null )
  +        {
  +            obj = IXMLRPCConstants.NO_RESULTS;
  +        }
           return obj;
       }
   }
  
  
  
  1.2       +1 -0      jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/behavior/IXMLRPCConstants.java
  
  Index: IXMLRPCConstants.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/xmlrpc/behavior/IXMLRPCConstants.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- IXMLRPCConstants.java	20 Feb 2002 05:30:51 -0000	1.1
  +++ IXMLRPCConstants.java	26 Feb 2002 06:06:39 -0000	1.2
  @@ -3,5 +3,6 @@
   public interface IXMLRPCConstants {
   
       public static final String HANDLERNAME = "LATERAL_XMLRPC_CACHE";
  +    public static final String NO_RESULTS = "NO_RESULTS";
   
   }
  
  
  

--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>