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 2008/08/29 20:05:22 UTC
svn commit: r690353 - in /jakarta/jcs/trunk:
src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
xdocs/changes.xml
Author: asmuts
Date: Fri Aug 29 11:05:21 2008
New Revision: 690353
URL: http://svn.apache.org/viewvc?rev=690353&view=rev
Log:
https://issues.apache.org/jira/browse/JCS-32
Moved shutdown hook to composite cache manager from indexed disk cache.
Modified:
jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
jakarta/jcs/trunk/xdocs/changes.xml
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java?rev=690353&r1=690352&r2=690353&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/auxiliary/disk/indexed/IndexedDiskCache.java Fri Aug 29 11:05:21 2008
@@ -236,8 +236,6 @@
// Kick off a real time optimization, in case we didn't do a final optimization.
doOptimizeRealTime();
}
- ShutdownHook shutdownHook = new ShutdownHook();
- Runtime.getRuntime().addShutdownHook( shutdownHook );
}
/**
@@ -569,7 +567,7 @@
/**
* @param key
- * @param object
+ * @param object
* @return ICacheElement or null
* @see AbstractDiskCache#doGet
*/
@@ -1694,26 +1692,4 @@
doOptimizeRealTime();
}
}
-
- /**
- * Called on shutdown. This gives use a chance to store the keys and to optimize even if the
- * cache manager's shutdown method was not called.
- */
- class ShutdownHook
- extends Thread
- {
- /**
- * This will persist the keys on shutdown.
- * <p>
- * @see java.lang.Thread#run()
- */
- public void run()
- {
- if ( alive )
- {
- log.warn( logCacheName + "Disk cache not shutdown properly, shutting down now." );
- doDispose();
- }
- }
- }
}
Modified: jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java?rev=690353&r1=690352&r2=690353&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java (original)
+++ jakarta/jcs/trunk/src/java/org/apache/jcs/engine/control/CompositeCacheManager.java Fri Aug 29 11:05:21 2008
@@ -103,9 +103,12 @@
/** Should we use system property substitutions. */
private static final boolean DEFAULT_USE_SYSTEM_PROPERTIES = true;
- /** Those waiting for notification of a shutdown. */
+ /** Those waiting for notification of a shutdown. */
private Set shutdownObservers = new HashSet();
+ /** Indicates whether shutdown has been called. */
+ private boolean isShutdown = false;
+
/**
* Gets the CacheHub instance. For backward compatibility, if this creates the instance it will
* attempt to configure it with the default configuration. If you want to configure from your
@@ -185,6 +188,13 @@
return new CompositeCacheManager();
}
+ /** CreAtes a shutdown hook */
+ protected CompositeCacheManager()
+ {
+ ShutdownHook shutdownHook = new ShutdownHook();
+ Runtime.getRuntime().addShutdownHook( shutdownHook );
+ }
+
/**
* Configure with default properties file
*/
@@ -470,10 +480,12 @@
*/
public void shutDown()
{
+ isShutdown = true;
+
// notify any observers
synchronized ( shutdownObservers )
{
- // We don't need to worry about lcoking the set.
+ // We don't need to worry about locking the set.
// since this is a shutdown command, nor do we need
// to queue these up.
Iterator it = shutdownObservers.iterator();
@@ -607,7 +619,6 @@
return (AuxiliaryCacheAttributes) auxiliaryAttributeRegistry.get( name );
}
-
/**
* Gets stats for debugging. This calls gets statistics and then puts all the results in a
* string. This returns data for all regions.
@@ -683,4 +694,26 @@
shutdownObservers.remove( observer );
}
}
+
+ /**
+ * Called on shutdown. This gives use a chance to store the keys and to optimize even if the
+ * cache manager's shutdown method was not called manually.
+ */
+ class ShutdownHook
+ extends Thread
+ {
+ /**
+ * This will persist the keys on shutdown.
+ * <p>
+ * @see java.lang.Thread#run()
+ */
+ public void run()
+ {
+ if ( !isShutdown )
+ {
+ log.info( "Shutdown hook activated. Shutdown was not called. Shutting down JCS." );
+ shutDown();
+ }
+ }
+ }
}
Modified: jakarta/jcs/trunk/xdocs/changes.xml
URL: http://svn.apache.org/viewvc/jakarta/jcs/trunk/xdocs/changes.xml?rev=690353&r1=690352&r2=690353&view=diff
==============================================================================
--- jakarta/jcs/trunk/xdocs/changes.xml (original)
+++ jakarta/jcs/trunk/xdocs/changes.xml Fri Aug 29 11:05:21 2008
@@ -44,11 +44,11 @@
<action dev="asmuts" type="fix" issue="JCS-32" due-to="Andy">Moved
shutdown hook from disk cache to composite cache manager.</action>
</release>
- <release version="1.3.1.0" date="in SVN">
- <action dev="asmuts" type="update"> Added getMultiple() method to
+ <release version="1.3.1.0" date="2008-04-11" description="tempbuild">
+ <action dev="asmuts" type="update" due-to="Chris Fairbanks"> Added getMultiple() method to
ICache</action>
</release>
- <release version="1.3" date="2007-06-05">
+ <release version="1.3" date="2007-06-05" description="First formal release">
<action dev="tv" type="update"> Updated/added license headers in all
files.</action>
</release>
---------------------------------------------------------------------
To unsubscribe, e-mail: jcs-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: jcs-dev-help@jakarta.apache.org