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 2005/01/13 10:12:53 UTC

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

asmuts      2005/01/13 01:12:53

  Modified:    src/java/org/apache/jcs/auxiliary/remote/server
                        RemoteCacheServer.java
               src/java/org/apache/jcs/auxiliary/remote
                        RemoteCacheNoWait.java
  Log:
  Fixed a bug that caused remote push to fail.
  
  The event queues have an isAlive and an isWorking status.  Originally isAlive meant that it hadn't died.  No isAlive means are there any threads that are running.  isWorking used to mean that there were threads working; now it means that the queue is in working order.  This terminology isn't clear and lead to a bug.  I will come up with new names.
  
  The remote server used to check to see if a queue was alive before trying to send an update to a local.  When we made the queues shutdown from inactivity, they started setting the isAlive to false.  The remote server would then think they were bad and not try to add events.  I now made the remote server check to see if the queue is working.
  
  updated to bug fix version 1.2.1
  
  Revision  Changes    Path
  1.21      +20 -11    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.20
  retrieving revision 1.21
  diff -u -r1.20 -r1.21
  --- RemoteCacheServer.java	7 Jan 2005 22:29:17 -0000	1.20
  +++ RemoteCacheServer.java	13 Jan 2005 09:12:52 -0000	1.21
  @@ -312,6 +312,11 @@
   
                       ICacheEventQueue[] qlist = getEventQList( cacheDesc, requesterId );
   
  +                    if ( log.isDebugEnabled() )
  +                    {
  +                        log.debug( "qlist.length = " + qlist.length );
  +                    }
  +
                       for ( int i = 0; i < qlist.length; i++ )
                       {
                           qlist[i].addPutEvent( item );
  @@ -337,7 +342,7 @@
               long end = System.currentTimeMillis();
               if( log.isDebugEnabled() )
               {
  -              log.debug( "put took " + String.valueOf( end - start ) + " ms." );              
  +              log.debug( "put took " + String.valueOf( end - start ) + " ms." );
               }
           }
   
  @@ -362,7 +367,7 @@
           for ( int i = 0; i < list.length; i++ )
           {
               ICacheEventQueue q = list[i];
  -            if ( q.isAlive() && q.getListenerId() != requesterId )
  +            if ( q.isWorking() && q.getListenerId() != requesterId )
               {
                   count++;
               }
  @@ -646,10 +651,14 @@
                   Map.Entry e = ( Map.Entry ) itr.next();
                   ICacheEventQueue q = ( ICacheEventQueue ) e.getValue();
   
  -                if ( !q.isAlive() )
  +                // this does not care if the q is alive (i.e. if
  +                // there are active threads; it cares if the queue
  +                // is working -- if it has not encoutnered errors
  +                // above the failure threshhold
  +                if ( !q.isWorking() )
                   {
                       itr.remove();
  -                    p1( "Cache event queue " + q + " dead and removed from cache server." );
  +                    p1( "Cache event queue " + q + " is not working and removed from cache server." );
                   }
               }
           }
  @@ -720,14 +729,14 @@
                   catch ( IOException ioe )
                   {
                   }
  -                
  -                CacheEventQueueFactory fact = new CacheEventQueueFactory();   
  -                ICacheEventQueue q = fact.createCacheEventQueue( listener, 
  -                    id, 
  -                    cacheName,                                                    
  -                    rcsa.getEventQueuePoolName(), 
  +
  +                CacheEventQueueFactory fact = new CacheEventQueueFactory();
  +                ICacheEventQueue q = fact.createCacheEventQueue( listener,
  +                    id,
  +                    cacheName,
  +                    rcsa.getEventQueuePoolName(),
                       rcsa.getEventQueueTypeFactoryCode() );
  -                
  +
                   eventQMap.put( listener, q );
   
                   if ( log.isDebugEnabled() )
  
  
  
  1.13      +18 -18    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.12
  retrieving revision 1.13
  diff -u -r1.12 -r1.13
  --- RemoteCacheNoWait.java	7 Jan 2005 22:29:17 -0000	1.12
  +++ RemoteCacheNoWait.java	13 Jan 2005 09:12:53 -0000	1.13
  @@ -63,13 +63,13 @@
       public RemoteCacheNoWait( RemoteCache cache )
       {
           this.cache = cache;
  -        CacheEventQueueFactory fact = new CacheEventQueueFactory();         
  -        this.q = fact.createCacheEventQueue( new CacheAdaptor( cache ), 
  -            RemoteCacheInfo.listenerId, 
  -            cache.getCacheName(),                                                    
  -            cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), 
  +        CacheEventQueueFactory fact = new CacheEventQueueFactory();
  +        this.q = fact.createCacheEventQueue( new CacheAdaptor( cache ),
  +            RemoteCacheInfo.listenerId,
  +            cache.getCacheName(),
  +            cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(),
               cache.getAuxiliaryCacheAttributes().getEventQueueTypeFactoryCode() );
  -        
  +
           if ( cache.getStatus() == CacheConstants.STATUS_ERROR )
           {
               q.destroy();
  @@ -204,7 +204,7 @@
        */
       public int getStatus()
       {
  -        return q.isAlive() ? cache.getStatus() : CacheConstants.STATUS_ERROR;
  +        return q.isWorking() ? cache.getStatus() : CacheConstants.STATUS_ERROR;
       }
   
       /**
  @@ -234,15 +234,15 @@
        */
       public void resetEventQ()
       {
  -        if ( q.isAlive() )
  +        if ( q.isWorking() )
           {
               q.destroy();
           }
  -        CacheEventQueueFactory fact = new CacheEventQueueFactory();         
  -        this.q = fact.createCacheEventQueue( new CacheAdaptor( cache ), 
  -            RemoteCacheInfo.listenerId, 
  -            cache.getCacheName(),                                                    
  -            cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(), 
  +        CacheEventQueueFactory fact = new CacheEventQueueFactory();
  +        this.q = fact.createCacheEventQueue( new CacheAdaptor( cache ),
  +            RemoteCacheInfo.listenerId,
  +            cache.getCacheName(),
  +            cache.getAuxiliaryCacheAttributes().getEventQueuePoolName(),
               cache.getAuxiliaryCacheAttributes().getEventQueueTypeFactoryCode() );
       }
   
  @@ -261,10 +261,10 @@
     {
       return getStatistics().toString();
     }
  -  
  +
     /*
      * (non-Javadoc)
  -   * 
  +   *
      * @see org.apache.jcs.auxiliary.AuxiliaryCache#getStatistics()
      */
     public IStats getStatistics()
  @@ -284,18 +284,18 @@
   	IStatElement[] cSEs = cStats.getStatElements();
   	List cL = Arrays.asList(cSEs);
   	elems.addAll( cL );
  -    
  +
   	// get the stats from the event queue too
   	// get as array, convert to list, add list to our outer list
   	IStats eqStats = this.q.getStatistics();
   	IStatElement[] eqSEs = eqStats.getStatElements();
   	List eqL = Arrays.asList(eqSEs);
   	elems.addAll( eqL );
  -    
  +
       // get an array and put them in the Stats object
       IStatElement[] ses = (IStatElement[]) elems.toArray( new StatElement[0] );
       stats.setStatElements( ses );
   
       return stats;
  -  }   
  +  }
   }
  
  
  

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