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/20 06:31:04 UTC

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

asmuts      02/02/19 21:31:04

  Modified:    src/java/org/apache/stratum/jcs/auxiliary/lateral
                        LateralCacheManager.java LateralCacheFactory.java
                        LateralCacheAttributes.java
               src/java/org/apache/stratum/jcs/auxiliary/lateral/behavior
                        ILateralCacheAttributes.java
  Log:
  getting some code around a possbile xml-rpc lateral
  doesn't work yet
  need to convert Led to some other type for argument?
  
  lateral cache framework needs some refactoring,  the lateral caches
  are hard coded in the LateralCacheManger.  This should be more dynamic or the individual laterals should be more independent.  Also, the lateralCacheAtributes has variable for all types.  This is ugly too.
  
  The lateral cache was never the highest priority.
  
  xml-rpc familiar folk can build apon this, change the led method type to a method name, etc.
  
  Add startup testing of the webserver, make sure it is not intialized more than once, etc.
  
  Revision  Changes    Path
  1.7       +45 -4     jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheManager.java
  
  Index: LateralCacheManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- LateralCacheManager.java	16 Feb 2002 02:37:18 -0000	1.6
  +++ LateralCacheManager.java	20 Feb 2002 05:31:03 -0000	1.7
  @@ -20,12 +20,17 @@
   import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheObserver;
   import org.apache.stratum.jcs.auxiliary.lateral.behavior.ILateralCacheService;
   
  +// TODO: make these dymanically configurable
  +// refactor config class so it only has the used info for each?
   import org.apache.stratum.jcs.auxiliary.lateral.socket.tcp.LateralGroupCacheTCPListener;
   import org.apache.stratum.jcs.auxiliary.lateral.socket.tcp.LateralTCPService;
   
   import org.apache.stratum.jcs.auxiliary.lateral.socket.udp.LateralGroupCacheUDPListener;
   import org.apache.stratum.jcs.auxiliary.lateral.socket.udp.LateralUDPService;
   
  +import org.apache.stratum.jcs.auxiliary.lateral.xmlrpc.LateralGroupCacheXMLRPCListener;
  +import org.apache.stratum.jcs.auxiliary.lateral.xmlrpc.LateralXMLRPCService;
  +
   import org.apache.stratum.jcs.engine.CacheWatchRepairable;
   
   import org.apache.stratum.jcs.engine.behavior.ICache;
  @@ -61,7 +66,9 @@
       final static Map instances = new HashMap();
       // each manager instance has caches
       final Map caches = new HashMap();
  -    /** Description of the Field */
  +    /**
  +     * Description of the Field
  +     */
       protected ILateralCacheAttributes lca;
       private int clients;
   
  @@ -82,6 +89,7 @@
        * Gets the instance attribute of the LateralCacheManager class
        *
        * @return The instance value
  +     * @param lca
        */
       public static LateralCacheManager getInstance( ILateralCacheAttributes lca )
       {
  @@ -157,6 +165,12 @@
   
                   this.lateralService = new LateralTCPService( lca );
               }
  +            else if ( lca.getTransmissionType() == lca.XMLRPC )
  +            {
  +                log.debug( "Creating XMLRPC service" );
  +
  +                this.lateralService = new LateralXMLRPCService( lca );
  +            }
               else
               {
                   log.error( "Type not recognized, must zombie" );
  @@ -195,6 +209,12 @@
   
       /**
        * Adds the lateral cache listener to the underlying cache-watch service.
  +     *
  +     * @param cacheName The feature to be added to the LateralCacheListener
  +     *      attribute
  +     * @param listener The feature to be added to the LateralCacheListener
  +     *      attribute
  +     * @exception IOException
        */
       public void addLateralCacheListener( String cacheName, ILateralCacheListener listener )
           throws IOException
  @@ -209,6 +229,9 @@
        * Called to access a precreated region or construct one with defaults.
        * Since all aux cache access goes through the manager, this will never be
        * called.
  +     *
  +     * @return The {3} value
  +     * @param cacheName
        */
       public ICache getCache( String cacheName )
       {
  @@ -236,6 +259,11 @@
               {
                   addLateralCacheListener( cacheName, LateralGroupCacheTCPListener.getInstance( lca ) );
               }
  +            else
  +                if ( lca.getTransmissionType() == lca.XMLRPC )
  +            {
  +                addLateralCacheListener( cacheName, LateralGroupCacheXMLRPCListener.getInstance( lca ) );
  +            }
           }
           catch ( IOException ioe )
           {
  @@ -254,20 +282,33 @@
           return c;
       }
   
  -    /** Gets the cacheType attribute of the LateralCacheManager object */
  +    /**
  +     * Gets the cacheType attribute of the LateralCacheManager object
  +     *
  +     * @return The {3} value
  +     */
       public int getCacheType()
       {
           return LATERAL_CACHE;
       }
   
  -    /** Gets the stats attribute of the LateralCacheManager object */
  +    /**
  +     * Gets the stats attribute of the LateralCacheManager object
  +     *
  +     * @return The {3} value
  +     */
       public String getStats()
       {
           // add something here
           return "";
       }
   
  -    /** Fixes up all the caches managed by this cache manager. */
  +    /**
  +     * Fixes up all the caches managed by this cache manager.
  +     *
  +     * @param lateralService
  +     * @param lateralWatch
  +     */
       public void fixCaches( ILateralCacheService lateralService, ILateralCacheObserver lateralWatch )
       {
           log.debug( "Fixing lateral caches:" );
  
  
  
  1.6       +35 -3     jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheFactory.java
  
  Index: LateralCacheFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheFactory.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LateralCacheFactory.java	16 Feb 2002 02:37:18 -0000	1.5
  +++ LateralCacheFactory.java	20 Feb 2002 05:31:03 -0000	1.6
  @@ -35,6 +35,9 @@
       /**
        * Interface method. Allows classforname construction, making caches
        * pluggable.
  +     *
  +     * @return
  +     * @param iaca
        */
       public ICache createCache( IAuxiliaryCacheAttributes iaca )
       {
  @@ -80,12 +83,41 @@
   
           }
           else
  +            if ( lac.getTransmissionType() == lac.XMLRPC )
  +        {
  +
  +            //pars up the tcp servers and set the tcpServer value and
  +            // get the manager and then get the cache
  +            //Iterator it = lac.tcpServers.iterator();
  +            //while( it.hasNext() ) {
  +
  +            StringTokenizer it = new StringTokenizer( lac.getHttpServers(), "," );
  +            while ( it.hasMoreElements() )
  +            {
  +                //String server = (String)it.next();
  +                String server = ( String ) it.nextElement();
  +                //p( "tcp server = " +  server );
  +                lac.setHttpServer( server );
  +                LateralCacheManager lcm = LateralCacheManager.getInstance( lac );
  +                ICache ic = lcm.getCache( lac.getCacheName() );
  +                if ( ic != null )
  +                {
  +                    noWaits.add( ic );
  +                }
  +                else
  +                {
  +                    log.warn( "noWait is null" );
  +                }
  +            }
  +
  +        }
  +        else
               if ( lac.getTransmissionType() == lac.HTTP )
           {
  -            Iterator it = lac.httpServers.iterator();
  -            while ( it.hasNext() )
  +            StringTokenizer it = new StringTokenizer( lac.getHttpServers(), "," );
  +            while ( it.hasMoreElements() )
               {
  -                String server = ( String ) it.next();
  +                String server = ( String ) it.nextElement();
                   lac.setHttpServer( server );
                   LateralCacheManager lcm = LateralCacheManager.getInstance( lac );
                   ICache ic = lcm.getCache( lac.getCacheName() );
  
  
  
  1.6       +60 -3     jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheAttributes.java
  
  Index: LateralCacheAttributes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/LateralCacheAttributes.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LateralCacheAttributes.java	16 Feb 2002 02:37:18 -0000	1.5
  +++ LateralCacheAttributes.java	20 Feb 2002 05:31:03 -0000	1.6
  @@ -22,7 +22,7 @@
       String transmissionTypeName = "UDP";
       int transmissionType = UDP;
   
  -    ArrayList httpServers;
  +    String httpServers;
       // used to identify the service that this manager will be
       // operating on
       String httpServer = "";
  @@ -38,6 +38,7 @@
       // operating on
       String tcpServer = "";
       int tcpListenerPort = 1111;
  +    int httpListenerPort = 8080;
   
       private String cacheName;
       private String name;
  @@ -67,7 +68,7 @@
   
   
       /*
  -     * ////////////////////////////////////////
  +     *
        * public void setTcpServers( ArrayList val ) {
        * tcpServers = val;
        * }
  @@ -96,6 +97,26 @@
           return tcpServers;
       }
   
  +    /**
  +     * Sets the httpServers attribute of the LateralCacheAttributes object
  +     *
  +     * @param val The new httpServers value
  +     */
  +    public void setHttpServers( String val )
  +    {
  +        httpServers = val;
  +    }
  +
  +
  +    /**
  +     * Gets the httpSrvers attribute of the LateralCacheAttributes object
  +     *
  +     * @return The httpServers value
  +     */
  +    public String getHttpServers()
  +    {
  +        return httpServers;
  +    }
   
       /**
        * Sets the tcpServer attribute of the LateralCacheAttributes object
  @@ -142,6 +163,28 @@
   
   
       /**
  +     * Sets the httpListenerPort attribute of the ILateralCacheAttributes object
  +     *
  +     * @param val The new tcpListenerPort value
  +     */
  +    public void setHttpListenerPort( int val )
  +    {
  +        this.httpListenerPort = val;
  +    }
  +
  +
  +    /**
  +     * Gets the httpListenerPort attribute of the ILateralCacheAttributes object
  +     *
  +     * @return The httpListenerPort value
  +     */
  +    public int getHttpListenerPort()
  +    {
  +        return this.httpListenerPort;
  +    }
  +
  +
  +    /**
        * Sets the udpMulticastAddr attribute of the LateralCacheAttributes object
        *
        * @param val The new udpMulticastAddr value
  @@ -207,6 +250,11 @@
           {
               transmissionTypeName = "TCP";
           }
  +        else
  +            if ( val == XMLRPC )
  +        {
  +            transmissionTypeName = "XMLRPC";
  +        }
       }
   
   
  @@ -244,6 +292,11 @@
           {
               transmissionType = TCP;
           }
  +        else
  +            if ( val.equals( "XMLRPC" ) )
  +        {
  +            transmissionType = XMLRPC;
  +        }
   
       }
   
  @@ -343,7 +396,11 @@
       }
   
   
  -    /** Description of the Method */
  +    /**
  +     * Description of the Method
  +     *
  +     * @return
  +     */
       public String toString()
       {
           StringBuffer buf = new StringBuffer();
  
  
  
  1.6       +32 -0     jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/behavior/ILateralCacheAttributes.java
  
  Index: ILateralCacheAttributes.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-stratum/src/java/org/apache/stratum/jcs/auxiliary/lateral/behavior/ILateralCacheAttributes.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- ILateralCacheAttributes.java	16 Feb 2002 02:37:19 -0000	1.5
  +++ ILateralCacheAttributes.java	20 Feb 2002 05:31:03 -0000	1.6
  @@ -16,6 +16,7 @@
       final static int HTTP = 1;
       final static int UDP = 2;
       final static int TCP = 3;
  +    final static int XMLRPC = 4;
   
   
       /**
  @@ -80,6 +81,37 @@
        * @return The tcpListenerPort value
        */
       public int getTcpListenerPort();
  +
  +    /**
  +     * Sets the httpListenerPort attribute of the ILateralCacheAttributes object
  +     *
  +     * @param val The new tcpListenerPort value
  +     */
  +    public void setHttpListenerPort( int val );
  +
  +
  +    /**
  +     * Gets the httpListenerPort attribute of the ILateralCacheAttributes object
  +     *
  +     * @return The httpListenerPort value
  +     */
  +    public int getHttpListenerPort();
  +
  +    /**
  +     * Sets the httpServers attribute of the LateralCacheAttributes object
  +     *
  +     * @param val The new httpServers value
  +     */
  +    public void setHttpServers( String val );
  +
  +
  +    /**
  +     * Gets the httpSrvers attribute of the LateralCacheAttributes object
  +     *
  +     * @return The httpServers value
  +     */
  +    public String getHttpServers();
  +
   
   
       // configure udp multicast parameters
  
  
  

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