You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jcs-dev@jakarta.apache.org by as...@apache.org on 2003/11/06 18:58:51 UTC

cvs commit: jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary AuxiliaryCache.java

asmuts      2003/11/06 09:58:51

  Modified:    src/java/org/apache/jcs/auxiliary/remote RemoteUtils.java
                        RemoteCacheNoWaitFacade.java RemoteCacheNoWait.java
                        RemoteCacheManager.java RemoteCache.java
               src/java/org/apache/jcs/auxiliary/remote/server
                        RemoteCacheServerFactory.java
                        RemoteCacheServer.java
               src/java/org/apache/jcs/auxiliary/lateral
                        LateralCacheNoWaitFacade.java
               src/java/org/apache/jcs/auxiliary/remote/behavior
                        IRemoteCacheService.java
               src/java/org/apache/jcs/engine/behavior
                        ICacheServiceAdmin.java
               src/java/org/apache/jcs/engine/control CompositeCache.java
               src/java/org/apache/jcs/auxiliary AuxiliaryCache.java
  Log:
  Adding stats back to remote cache.  It's necessary in order to probe a server.  May need to add it to all managers.
  
  Added an IOException to the auxilary interface for getting group keys.
  
  May need some further cleaning.
  
  Revision  Changes    Path
  1.3       +2 -0      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java
  
  Index: RemoteUtils.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteUtils.java,v
  retrieving revision 1.2
  retrieving revision 1.3
  diff -u -r1.2 -r1.3
  --- RemoteUtils.java	22 Aug 2003 11:57:15 -0000	1.2
  +++ RemoteUtils.java	6 Nov 2003 17:58:51 -0000	1.3
  @@ -117,6 +117,8 @@
           }
           catch ( Exception ex )
           {
  +
  +            log.debug( "Error loading remote properties = " + ex.getMessage() );
               // ignore;
           }
           finally
  
  
  
  1.6       +1 -0      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java
  
  Index: RemoteCacheNoWaitFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWaitFacade.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- RemoteCacheNoWaitFacade.java	22 Aug 2003 11:57:15 -0000	1.5
  +++ RemoteCacheNoWaitFacade.java	6 Nov 2003 17:58:51 -0000	1.6
  @@ -187,6 +187,7 @@
        * Gets the set of keys of objects currently in the group
        */
       public Set getGroupKeys(String group)
  +         throws IOException
       {
           HashSet allKeys = new HashSet();
           for ( int i = 0; i < noWaits.length; i++ )
  
  
  
  1.8       +1 -0      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java
  
  Index: RemoteCacheNoWait.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheNoWait.java,v
  retrieving revision 1.7
  retrieving revision 1.8
  diff -u -r1.7 -r1.8
  --- RemoteCacheNoWait.java	22 Aug 2003 11:57:15 -0000	1.7
  +++ RemoteCacheNoWait.java	6 Nov 2003 17:58:51 -0000	1.8
  @@ -147,6 +147,7 @@
       }
   
       public Set getGroupKeys(String groupName)
  +         throws IOException
       {
           return cache.getGroupKeys(groupName);
       }
  
  
  
  1.7       +22 -0     jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java
  
  Index: RemoteCacheManager.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCacheManager.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- RemoteCacheManager.java	22 Aug 2003 11:57:15 -0000	1.6
  +++ RemoteCacheManager.java	6 Nov 2003 17:58:51 -0000	1.7
  @@ -325,6 +325,28 @@
           }
       }
   
  +    /**
  +     * Gets the stats attribute of the RemoteCacheManager object
  +     *
  +     * @return The stats value
  +     */
  +    public String getStats()
  +    {
  +        StringBuffer stats = new StringBuffer();
  +        Iterator allCaches = caches.values().iterator();
  +        while ( allCaches.hasNext() )
  +        {
  +            ICache c = ( ICache ) allCaches.next();
  +            if ( c != null )
  +            {
  +                //need to add getStats to ICache
  +                //stats.append( "<br>&nbsp;&nbsp;&nbsp;" + c.getStats() );
  +                stats.append( c.getCacheName() );
  +            }
  +        }
  +        return stats.toString();
  +    }
  +
       /** Description of the Method */
       public void release()
       {
  
  
  
  1.9       +10 -1     jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java
  
  Index: RemoteCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/RemoteCache.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- RemoteCache.java	22 Aug 2003 11:57:15 -0000	1.8
  +++ RemoteCache.java	6 Nov 2003 17:58:51 -0000	1.9
  @@ -214,7 +214,7 @@
           }
       }
   
  -    public Set getGroupKeys(String groupName)
  +    public Set getGroupKeys(String groupName) throws java.rmi.RemoteException
       {
           return remote.getGroupKeys(cacheName, groupName);
       }
  @@ -334,6 +334,15 @@
           return remote instanceof IZombie ? CacheConstants.STATUS_ERROR : CacheConstants.STATUS_ALIVE;
       }
   
  +    /**
  +     * Gets the stats attribute of the RemoteCache object
  +     *
  +     * @return The stats value
  +     */
  +    public String getStats()
  +    {
  +        return "cacheName = " + cacheName;
  +    }
   
       /**
        * Returns the current cache size.
  
  
  
  1.5       +46 -1     jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java
  
  Index: RemoteCacheServerFactory.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServerFactory.java,v
  retrieving revision 1.4
  retrieving revision 1.5
  diff -u -r1.4 -r1.5
  --- RemoteCacheServerFactory.java	22 Aug 2003 11:57:17 -0000	1.4
  +++ RemoteCacheServerFactory.java	6 Nov 2003 17:58:51 -0000	1.5
  @@ -66,6 +66,7 @@
   
   import org.apache.jcs.auxiliary.remote.RemoteUtils;
   import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheConstants;
  +import org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheServiceAdmin;
   
   import org.apache.jcs.engine.behavior.ICacheServiceAdmin;
   
  @@ -232,7 +233,7 @@
       public static void main( String[] args )
           throws Exception
       {
  -        Properties prop = args.length > 0 ? RemoteUtils.loadProps( args[0] ) : new Properties();
  +        Properties prop = args.length > 0 ? RemoteUtils.loadProps( args[args.length -1] ) : new Properties();
   
           // shutdown
           if ( args.length > 0 && args[0].toLowerCase().indexOf( "-shutdown" ) != -1 )
  @@ -261,6 +262,50 @@
               log.debug( "done." );
               System.exit( 0 );
           }
  +
  +        // STATS
  +        if ( args.length > 0 && args[0].toLowerCase().indexOf( "-stats" ) != -1 )
  +        {
  +
  +            log.debug( "getting cache stats" );
  +
  +            try
  +            {
  +
  +                int port = Registry.REGISTRY_PORT;
  +
  +                if ( args.length > 1 )
  +                {
  +                    port = Integer.parseInt( args[1] );
  +                }
  +
  +                String serviceName = prop.getProperty( REMOTE_CACHE_SERVICE_NAME, REMOTE_CACHE_SERVICE_VAL ).trim();
  +                String registry = "//:" + port + "/" + serviceName;
  +                log.debug( "looking up server " + registry );
  +                Object obj = Naming.lookup( registry );
  +                log.debug( "server found" );
  +
  +                log.debug( "obj = " + obj );
  +                IRemoteCacheServiceAdmin admin = ( IRemoteCacheServiceAdmin ) obj;
  +
  +                try
  +                {
  +                    log.debug( admin.getStats() );
  +                }
  +                catch ( Exception es )
  +                {
  +                    log.error( es );
  +                }
  +
  +            }
  +            catch ( Exception ex )
  +            {
  +                log.error( ex );
  +            }
  +            log.debug( "done." );
  +            System.exit( 0 );
  +        }
  +
   
           // startup.
           int port;
  
  
  
  1.13      +12 -1     jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java
  
  Index: RemoteCacheServer.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/server/RemoteCacheServer.java,v
  retrieving revision 1.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RemoteCacheServer.java	22 Aug 2003 11:57:17 -0000	1.12
  +++ RemoteCacheServer.java	6 Nov 2003 17:58:51 -0000	1.13
  @@ -179,7 +179,7 @@
   
           if ( prop == null )
           {
  -            hub.configure( "/remote.cache.properties" );
  +            hub.configure( "/remote.cache.ccf" );
           }
           else
           {
  @@ -909,6 +909,17 @@
           return ( byte ) ( id & 0xff );
       }
   
  +    /**
  +     * Gets the stats attribute of the RemoteCacheServer object
  +     *
  +     * @return The stats value
  +     */
  +    public String getStats()
  +        throws IOException
  +    {
  +        //return cacheManager.getStats();
  +        return "temp";
  +    }
   
       /** Description of the Method */
       private static void p1( String s )
  
  
  
  1.6       +7 -1      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java
  
  Index: LateralCacheNoWaitFacade.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheNoWaitFacade.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- LateralCacheNoWaitFacade.java	22 Aug 2003 11:57:15 -0000	1.5
  +++ LateralCacheNoWaitFacade.java	6 Nov 2003 17:58:51 -0000	1.6
  @@ -155,7 +155,13 @@
               AuxiliaryCache aux = noWaits[i];
               if ( aux != null )
               {
  -                allKeys.addAll(aux.getGroupKeys(group));
  +                try {
  +                    allKeys.addAll(aux.getGroupKeys(group));
  +                }
  +                catch ( IOException e )
  +                {
  +                    // ignore
  +                }
               }
           }
           return allKeys;
  
  
  
  1.7       +2 -1      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java
  
  Index: IRemoteCacheService.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/remote/behavior/IRemoteCacheService.java,v
  retrieving revision 1.6
  retrieving revision 1.7
  diff -u -r1.6 -r1.7
  --- IRemoteCacheService.java	22 Aug 2003 11:57:19 -0000	1.6
  +++ IRemoteCacheService.java	6 Nov 2003 17:58:51 -0000	1.7
  @@ -88,5 +88,6 @@
       public void removeAll( String cacheName, byte requesterId )
           throws IOException;
   
  -    public Set getGroupKeys(String cacheName, String groupName);
  +    public Set getGroupKeys(String cacheName, String groupName)
  +        throws java.rmi.RemoteException;
   }
  
  
  
  1.4       +8 -0      jakarta-turbine-jcs/src/java/org/apache/jcs/engine/behavior/ICacheServiceAdmin.java
  
  Index: ICacheServiceAdmin.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/behavior/ICacheServiceAdmin.java,v
  retrieving revision 1.3
  retrieving revision 1.4
  diff -u -r1.3 -r1.4
  --- ICacheServiceAdmin.java	22 Aug 2003 11:57:17 -0000	1.3
  +++ ICacheServiceAdmin.java	6 Nov 2003 17:58:51 -0000	1.4
  @@ -65,6 +65,14 @@
   public interface ICacheServiceAdmin
   {
   
  +    /**
  +     * Gets the stats attribute of the ICacheServiceAdmin object
  +     *
  +     * @return The stats value
  +     */
  +    public String getStats()
  +        throws IOException;
  +
       /** Description of the Method */
       public void shutdown()
           throws IOException;
  
  
  
  1.9       +8 -2      jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/CompositeCache.java
  
  Index: CompositeCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/engine/control/CompositeCache.java,v
  retrieving revision 1.8
  retrieving revision 1.9
  diff -u -r1.8 -r1.9
  --- CompositeCache.java	22 Aug 2003 11:57:18 -0000	1.8
  +++ CompositeCache.java	6 Nov 2003 17:58:51 -0000	1.9
  @@ -676,7 +676,13 @@
               AuxiliaryCache aux = auxCaches[i];
               if ( aux != null )
               {
  -                allKeys.addAll(aux.getGroupKeys(group));
  +                try {
  +                    allKeys.addAll(aux.getGroupKeys(group));
  +                }
  +                catch ( IOException e )
  +                {
  +                    //ignore
  +                }
               }
           }
           return allKeys;
  
  
  
  1.6       +2 -2      jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java
  
  Index: AuxiliaryCache.java
  ===================================================================
  RCS file: /home/cvs/jakarta-turbine-jcs/src/java/org/apache/jcs/auxiliary/AuxiliaryCache.java,v
  retrieving revision 1.5
  retrieving revision 1.6
  diff -u -r1.5 -r1.6
  --- AuxiliaryCache.java	22 Aug 2003 11:57:16 -0000	1.5
  +++ AuxiliaryCache.java	6 Nov 2003 17:58:51 -0000	1.6
  @@ -101,5 +101,5 @@
       /**
        * Gets the set of keys of objects currently in the group
        */
  -    public Set getGroupKeys(String group);
  +    public Set getGroupKeys(String group) throws IOException;;
   }
  
  
  

---------------------------------------------------------------------
To unsubscribe, e-mail: turbine-jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: turbine-jcs-dev-help@jakarta.apache.org