commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1195241 - in /commons/proper/jcs/trunk/src: changes/ java/org/apache/jcs/auxiliary/lateral/ java/org/apache/jcs/auxiliary/lateral/socket/tcp/
Date Sun, 30 Oct 2011 20:47:20 GMT
Author: tv
Date: Sun Oct 30 20:47:19 2011
New Revision: 1195241

URL: http://svn.apache.org/viewvc?rev=1195241&view=rev
Log:
Ensure shutdown of LateralCacheMonitor. Fixes JCS-69

Modified:
    commons/proper/jcs/trunk/src/changes/changes.xml
    commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java
    commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java
    commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
    commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
    commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java

Modified: commons/proper/jcs/trunk/src/changes/changes.xml
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/changes/changes.xml?rev=1195241&r1=1195240&r2=1195241&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/changes/changes.xml (original)
+++ commons/proper/jcs/trunk/src/changes/changes.xml Sun Oct 30 20:47:19 2011
@@ -20,6 +20,9 @@
 	</properties>
 	<body>
 		<release version="2.0" date="unreleased" description="JDK 1.5 based major release">
+            <action dev="tv" type="fix" issue="JCS-69" due-to="Michael Stevens">
+                Ensure shutdown of LateralCacheMonitor
+            </action>
             <action dev="tv" type="fix" issue="JCS-11" due-to="Peter Schwarz">
                 Add method for programmatic configuration to JCS
             </action>

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java?rev=1195241&r1=1195240&r2=1195241&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheMonitor.java
Sun Oct 30 20:47:19 2011
@@ -45,6 +45,11 @@ public class LateralCacheMonitor
      */
     private boolean alright = true;
 
+    /**
+     * shutdown flag
+     */
+    private boolean shutdown = false;
+
     /** code for eror */
     private final static int ERROR = 1;
 
@@ -102,6 +107,18 @@ public class LateralCacheMonitor
     }
 
     /**
+     * Notifies the cache monitor that the service shall shut down
+     */
+    public void notifyShutdown()
+    {
+        synchronized ( this )
+        {
+            this.shutdown = true;
+            notify();
+        }
+    }
+
+    /**
      * Main processing method for the LateralCacheMonitor object
      */
     public void run()
@@ -148,6 +165,16 @@ public class LateralCacheMonitor
                 // will need to test not just check status
             }
 
+            // check for requested shutdown
+            synchronized ( this )
+            {
+                if (shutdown)
+                {
+                    log.info( "Shutting down cache monitor" );
+                    return;
+                }
+            }
+
             // The "alright" flag must be false here.
             // Simply presume we can fix all the errors until proven otherwise.
             synchronized ( this )
@@ -185,7 +212,7 @@ public class LateralCacheMonitor
                         // there
                         // is not a cache yet.
                         // if this is error driven mode, mark as bad,
-                        // otherwise we will come back around argain.
+                        // otherwise we will come back around again.
                         if ( mode == ERROR )
                         {
                             bad();
@@ -247,7 +274,7 @@ public class LateralCacheMonitor
     }
 
     /**
-     * Sets the "alright" flag to false in a critial section.
+     * Sets the "alright" flag to false in a critical section.
      */
     private void bad()
     {

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java?rev=1195241&r1=1195240&r2=1195241&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/LateralCacheRestore.java
Sun Oct 30 20:47:19 2011
@@ -55,7 +55,7 @@ public class LateralCacheRestore
     }
 
     /**
-     * Returns true iff the connection to the lateral host for the corresponding cache manager
can
+     * Returns true if the connection to the lateral host for the corresponding cache manager
can
      * be successfully re-established.
      * <p>
      * @return whether or not the cache can be fixed.

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java?rev=1195241&r1=1195240&r2=1195241&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheFactory.java
Sun Oct 30 20:47:19 2011
@@ -94,6 +94,13 @@ public class LateralTCPCacheFactory
                 lacC.setTcpServer( server );
                 LateralTCPCacheManager lcm = LateralTCPCacheManager.getInstance( lacC, cacheMgr,
cacheEventLogger,
                                                                                  elementSerializer
);
+
+                // register for shutdown notification
+                if (cacheMgr instanceof IShutdownObservable )
+                {
+                    ( (IShutdownObservable) cacheMgr ).registerShutdownObserver( lcm );
+                }
+
                 ICache ic = lcm.getCache( lacC.getCacheName() );
                 if ( ic != null )
                 {

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java?rev=1195241&r1=1195240&r2=1195241&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPCacheManager.java
Sun Oct 30 20:47:19 2011
@@ -343,7 +343,7 @@ public class LateralTCPCacheManager
      */
     public void shutdown()
     {
-        // TODO revist this.
+        // TODO revisit this.
         // the name here doesn't matter.
         try
         {
@@ -353,5 +353,11 @@ public class LateralTCPCacheManager
         {
             log.error( "Problem disposing of service", e );
         }
+
+        // shut down monitor
+        if (monitor != null)
+        {
+            monitor.notifyShutdown();
+        }
     }
 }

Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java?rev=1195241&r1=1195240&r2=1195241&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/auxiliary/lateral/socket/tcp/LateralTCPService.java
Sun Oct 30 20:47:19 2011
@@ -287,6 +287,7 @@ public class LateralTCPService
      *         data in cache matching the pattern.
      * @throws IOException
      */
+    @SuppressWarnings("unchecked")
     public Map<Serializable, ICacheElement> getMatching( String cacheName, String pattern,
long requesterId )
         throws IOException
     {



Mime
View raw message