commons-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From t.@apache.org
Subject svn commit: r1406523 [2/2] - in /commons/proper/jcs/trunk/src: java/org/apache/jcs/access/ java/org/apache/jcs/auxiliary/ java/org/apache/jcs/auxiliary/disk/ java/org/apache/jcs/auxiliary/disk/block/ java/org/apache/jcs/auxiliary/disk/file/ java/org/ap...
Date Wed, 07 Nov 2012 10:29:17 GMT
Modified: commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java?rev=1406523&r1=1406522&r2=1406523&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java
(original)
+++ commons/proper/jcs/trunk/src/java/org/apache/jcs/utils/threadpool/ThreadPoolManager.java
Wed Nov  7 10:29:14 2012
@@ -31,7 +31,7 @@ import java.util.concurrent.TimeUnit;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
 import org.apache.jcs.utils.props.PropertyLoader;
-import org.apache.jcs.utils.threadpool.behavior.IPoolConfiguration;
+import org.apache.jcs.utils.threadpool.PoolConfiguration.WhenBlockedPolicy;
 
 /**
  * This manages threadpools for an application using Doug Lea's Util Concurrent package.
@@ -92,18 +92,18 @@ public class ThreadPoolManager
     private static int keepAliveTime_DEFAULT = 1000 * 60 * 5;
 
     /** Default when blocked */
-    private static String whenBlockedPolicy_DEFAULT = IPoolConfiguration.POLICY_RUN;
+    private static WhenBlockedPolicy whenBlockedPolicy_DEFAULT = WhenBlockedPolicy.RUN;
 
     /** Default startup size */
     private static int startUpSize_DEFAULT = 4;
 
-    /** The deafult config, created using propety defaults if present, else those above.
*/
+    /** The default config, created using property defaults if present, else those above.
*/
     private static PoolConfiguration defaultConfig;
 
     /** This is the default value. */
     public static final String DEFAULT_PROPS_FILE_NAME = "cache.ccf";
 
-    /** Setting this after inialization will have no effect.  */
+    /** Setting this after initialization will have no effect.  */
     private static String propsFileName = null;
 
     /** the root property name */
@@ -165,21 +165,25 @@ public class ThreadPoolManager
                 queue, new MyThreadFactory());
 
         // when blocked policy
-        if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_ABORT ) )
+        switch (config.getWhenBlockedPolicy())
         {
-            pool.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
-        }
-        else if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_RUN ) )
-        {
-            pool.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
-        }
-        else if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_WAIT )
)
-        {
-            throw new RuntimeException("POLICY_WAIT no longer supported");
-        }
-        else if ( config.getWhenBlockedPolicy().equals( IPoolConfiguration.POLICY_DISCARDOLDEST
) )
-        {
-            pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
+            case ABORT:
+                pool.setRejectedExecutionHandler(new ThreadPoolExecutor.AbortPolicy());
+                break;
+
+            case RUN:
+                pool.setRejectedExecutionHandler(new ThreadPoolExecutor.CallerRunsPolicy());
+                break;
+
+            case WAIT:
+                throw new RuntimeException("POLICY_WAIT no longer supported");
+
+            case DISCARDOLDEST:
+                pool.setRejectedExecutionHandler(new ThreadPoolExecutor.DiscardOldestPolicy());
+                break;
+
+            default:
+                break;
         }
 
         pool.prestartAllCoreThreads();
@@ -188,7 +192,7 @@ public class ThreadPoolManager
     }
 
     /**
-     * Returns a configured instance of the ThreadPoolManger To specify a configuation file
or
+     * Returns a configured instance of the ThreadPoolManger To specify a configuration file
or
      * Properties object to use call the appropriate setter prior to calling getInstance.
      * <p>
      * @return The single instance of the ThreadPoolManager

Modified: commons/proper/jcs/trunk/src/test-conf/log4j.properties
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test-conf/log4j.properties?rev=1406523&r1=1406522&r2=1406523&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test-conf/log4j.properties (original)
+++ commons/proper/jcs/trunk/src/test-conf/log4j.properties Wed Nov  7 10:29:14 2012
@@ -14,7 +14,7 @@
 # KIND, either express or implied.  See the License for the
 # specific language governing permissions and limitations
 # under the License.
-log4j.rootCategory=INFO, logfile
+log4j.rootCategory=INFO, stdout
 
 log4j.category.org.apache.jcs=INFO
 log4j.category.org.apache.jcs.config=INFO

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java?rev=1406523&r1=1406522&r2=1406523&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java (original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/MockAuxiliaryCache.java Wed
Nov  7 10:29:14 2012
@@ -26,7 +26,6 @@ import java.util.Map;
 import java.util.Set;
 
 import org.apache.jcs.engine.CacheConstants;
-import org.apache.jcs.engine.behavior.ICache;
 import org.apache.jcs.engine.behavior.ICacheElement;
 import org.apache.jcs.engine.stats.behavior.IStats;
 
@@ -42,7 +41,7 @@ public class MockAuxiliaryCache<K extend
     private static final long serialVersionUID = 1L;
 
     /** Can setup the cache type */
-    public int cacheType = ICache.DISK_CACHE;
+    public CacheType cacheType = CacheType.DISK_CACHE;
 
     /** Can setup status */
     public int status = CacheConstants.STATUS_ALIVE;
@@ -184,7 +183,7 @@ public class MockAuxiliaryCache<K extend
     /**
      * @return cacheType
      */
-    public int getCacheType()
+    public CacheType getCacheType()
     {
         return cacheType;
     }

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/MockLateralCache.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/MockLateralCache.java?rev=1406523&r1=1406522&r2=1406523&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/MockLateralCache.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/MockLateralCache.java
Wed Nov  7 10:29:14 2012
@@ -121,18 +121,4 @@ public class MockLateralCache<K extends 
     {
         return null;
     }
-
-    /** @return String */
-    @Override
-    public String getCacheName()
-    {
-        return super.getCacheName();
-    }
-
-    /** @return type */
-    @Override
-    public int getCacheType()
-    {
-        return super.getCacheType();
-    }
 }

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheClient.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheClient.java?rev=1406523&r1=1406522&r2=1406523&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheClient.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/auxiliary/remote/MockRemoteCacheClient.java
Wed Nov  7 10:29:14 2012
@@ -81,7 +81,7 @@ public class MockRemoteCacheClient<K ext
      * (non-Javadoc)
      * @see org.apache.jcs.auxiliary.remote.behavior.IRemoteCacheClient#fixCache(org.apache.jcs.auxiliary.remote.behavior.ICacheServiceNonLocal)
      */
-    @SuppressWarnings("unchecked")
+    @SuppressWarnings("unchecked") // Don't know how to do this properly
     public void fixCache( ICacheServiceNonLocal<?, ?> remote )
     {
         fixed = (ICacheServiceNonLocal<K, V>)remote;
@@ -235,9 +235,9 @@ public class MockRemoteCacheClient<K ext
     }
 
     /** @return 0 */
-    public int getCacheType()
+    public CacheType getCacheType()
     {
-        return 0;
+        return CacheType.REMOTE_CACHE;
     }
 
     /**

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java?rev=1406523&r1=1406522&r2=1406523&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheDiskUsageUnitTest.java
Wed Nov  7 10:29:14 2012
@@ -37,6 +37,7 @@ import org.apache.jcs.engine.CacheElemen
 import org.apache.jcs.engine.CompositeCacheAttributes;
 import org.apache.jcs.engine.ElementAttributes;
 import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICacheType.CacheType;
 import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
 import org.apache.jcs.engine.behavior.IElementAttributes;
 import org.apache.jcs.engine.behavior.IElementSerializer;
@@ -101,7 +102,7 @@ public class CompositeCacheDiskUsageUnit
         CompositeCache<String, String> cache = new CompositeCache<String, String>(
"testSpoolAllowed", cattr, attr );
 
         MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+        mock.cacheType = CacheType.DISK_CACHE;
 
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
@@ -132,7 +133,7 @@ public class CompositeCacheDiskUsageUnit
         CompositeCache<String, String> cache = new CompositeCache<String, String>(
"testSpoolAllowed", cattr, attr );
 
         MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+        mock.cacheType = CacheType.DISK_CACHE;
 
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
@@ -167,7 +168,7 @@ public class CompositeCacheDiskUsageUnit
         CompositeCache<String, String> cache = new CompositeCache<String, String>(
"testSpoolAllowed", cattr, attr );
 
         MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+        mock.cacheType = CacheType.DISK_CACHE;
 
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
@@ -204,7 +205,7 @@ public class CompositeCacheDiskUsageUnit
         CompositeCache<String, String> cache = new CompositeCache<String, String>(
"testSpoolAllowed", cattr, attr );
 
         MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+        mock.cacheType = CacheType.DISK_CACHE;
 
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
@@ -241,7 +242,7 @@ public class CompositeCacheDiskUsageUnit
         CompositeCache<String, String> cache = new CompositeCache<String, String>(
"testSpoolAllowed", cattr, attr );
 
         MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+        mock.cacheType = CacheType.DISK_CACHE;
 
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock };
@@ -276,10 +277,10 @@ public class CompositeCacheDiskUsageUnit
         CompositeCache<String, String> cache = new CompositeCache<String, String>(
"testSpoolAllowed", cattr, attr );
 
         MockAuxCache<String, String> mock = new MockAuxCache<String, String>();
-        mock.cacheType = AuxiliaryCache.DISK_CACHE;
+        mock.cacheType = CacheType.DISK_CACHE;
 
         MockAuxCache<String, String> mockLateral = new MockAuxCache<String, String>();
-        mockLateral.cacheType = AuxiliaryCache.LATERAL_CACHE;
+        mockLateral.cacheType = CacheType.LATERAL_CACHE;
 
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, String>[] auxArray = new AuxiliaryCache[] { mock, mockLateral
};
@@ -316,7 +317,7 @@ public class CompositeCacheDiskUsageUnit
         public int updateCount = 0;
 
         /** The type that should be returned from getCacheType. */
-        public int cacheType = AuxiliaryCache.DISK_CACHE;
+        public CacheType cacheType = CacheType.DISK_CACHE;
 
         /** Resets counters and catchers. */
         public void reset()
@@ -431,7 +432,7 @@ public class CompositeCacheDiskUsageUnit
          * @see org.apache.jcs.engine.behavior.ICacheType#getCacheType()
          * @return cacheType
          */
-        public int getCacheType()
+        public CacheType getCacheType()
         {
             return cacheType;
         }

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java?rev=1406523&r1=1406522&r2=1406523&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/engine/control/CompositeCacheUnitTest.java
Wed Nov  7 10:29:14 2012
@@ -29,8 +29,8 @@ import org.apache.jcs.auxiliary.MockAuxi
 import org.apache.jcs.engine.CacheElement;
 import org.apache.jcs.engine.CompositeCacheAttributes;
 import org.apache.jcs.engine.ElementAttributes;
-import org.apache.jcs.engine.behavior.ICache;
 import org.apache.jcs.engine.behavior.ICacheElement;
+import org.apache.jcs.engine.behavior.ICacheType.CacheType;
 import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
 import org.apache.jcs.engine.behavior.IElementAttributes;
 import org.apache.jcs.engine.memory.MockMemoryCache;
@@ -63,7 +63,7 @@ public class CompositeCacheUnitTest
         CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>(
cacheName, cattr, attr );
 
         MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String,
Integer>();
-        diskMock.cacheType = ICache.DISK_CACHE;
+        diskMock.cacheType = CacheType.DISK_CACHE;
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
         cache.setAuxCaches( aux );
@@ -103,7 +103,7 @@ public class CompositeCacheUnitTest
         CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>(
cacheName, cattr, attr );
 
         MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String,
Integer>();
-        diskMock.cacheType = ICache.REMOTE_CACHE;
+        diskMock.cacheType = CacheType.REMOTE_CACHE;
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
         cache.setAuxCaches( aux );
@@ -146,7 +146,7 @@ public class CompositeCacheUnitTest
         CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>(
cacheName, cattr, attr );
 
         MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String,
Integer>();
-        diskMock.cacheType = ICache.DISK_CACHE;
+        diskMock.cacheType = CacheType.DISK_CACHE;
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
         cache.setAuxCaches( aux );
@@ -197,7 +197,7 @@ public class CompositeCacheUnitTest
         CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>(
cacheName, cattr, attr );
 
         MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String,
Integer>();
-        diskMock.cacheType = ICache.DISK_CACHE;
+        diskMock.cacheType = CacheType.DISK_CACHE;
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
         cache.setAuxCaches( aux );
@@ -230,7 +230,7 @@ public class CompositeCacheUnitTest
         CompositeCache<String, Integer> cache = new CompositeCache<String, Integer>(
cacheName, cattr, attr );
 
         MockAuxiliaryCache<String, Integer> diskMock = new MockAuxiliaryCache<String,
Integer>();
-        diskMock.cacheType = ICache.REMOTE_CACHE;
+        diskMock.cacheType = CacheType.REMOTE_CACHE;
         @SuppressWarnings("unchecked")
         AuxiliaryCache<String, Integer>[] aux = new AuxiliaryCache[] { diskMock };
         cache.setAuxCaches( aux );

Modified: commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java
URL: http://svn.apache.org/viewvc/commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java?rev=1406523&r1=1406522&r2=1406523&view=diff
==============================================================================
--- commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java
(original)
+++ commons/proper/jcs/trunk/src/test/org/apache/jcs/utils/threadpool/ThreadPoolManagerUnitTest.java
Wed Nov  7 10:29:14 2012
@@ -25,6 +25,7 @@ import java.util.concurrent.ThreadPoolEx
 import junit.framework.TestCase;
 
 import org.apache.jcs.utils.props.PropertyLoader;
+import org.apache.jcs.utils.threadpool.PoolConfiguration.WhenBlockedPolicy;
 
 /**
  * Verify that the manager can create pools as intended by the default and
@@ -157,8 +158,7 @@ public class ThreadPoolManagerUnitTest
 
         PoolConfiguration config = mgr.loadConfig( "thread_pool.waittest" );
 
-        assertEquals( "Policy is wrong.", PoolConfiguration.POLICY_WAIT, config.getWhenBlockedPolicy()
);
-
+        assertEquals( "Policy is wrong.", WhenBlockedPolicy.WAIT, config.getWhenBlockedPolicy()
);
     }
 
     /**



Mime
View raw message