jakarta-jcs-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From asm...@apache.org
Subject svn commit: r289379 [2/2] - in /jakarta/jcs/trunk: auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/ auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/lateral/javagroups/ auxiliary-builds/jdk14/src/java/org/apache/jcs/auxiliary/l...
Date Fri, 16 Sep 2005 04:37:49 GMT
Added: jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf?rev=289379&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf (added)
+++ jakarta/jcs/trunk/src/test-conf/TestTCPLateralRemoveFilter.ccf Thu Sep 15 21:37:26 2005
@@ -0,0 +1,56 @@
+# Cache configuration for the 'TestDiskCache' test. The memory cache has a
+# a maximum of 100 objects, so objects should get pushed into the disk cache
+
+jcs.default=LTCP
+jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.default.cacheattributes.MaxObjects=10000
+jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
+
+
+##### CACHE REGIONS FOR TEST
+
+jcs.region.testTcpRegion1=LTCP
+jcs.region.testTcpRegion1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
+jcs.region.testTcpRegion1.cacheattributes.MaxObjects=10000
+jcs.region.testTcpRegion1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
+
+
+##### AUXILIARY CACHES
+
+# simple Lateral TCP auxiliary
+jcs.auxiliary.LTCP=org.apache.jcs.auxiliary.lateral.socket.tcp.LateralTCPCacheFactory
+jcs.auxiliary.LTCP.attributes=org.apache.jcs.auxiliary.lateral.socket.tcp.TCPLateralCacheAttributes
+jcs.auxiliary.LTCP.attributes.TcpServers=localhost:1111
+jcs.auxiliary.LTCP.attributes.TcpListenerPort=1110
+jcs.auxiliary.LTCP.attributes.AllowGet=false
+jcs.auxiliary.LTCP.attributes.IssueRemoveOnPut=true
+jcs.auxiliary.LTCP.attributes.FilterRemoveByHashCode=true
+
+##############################################################
+################## THREAD POOL CONFIGURATION ###################
+# Default thread pool config
+thread_pool.default.boundarySize=2000
+thread_pool.default.maximumPoolSize=150
+thread_pool.default.minimumPoolSize=4
+thread_pool.default.keepAliveTime=350000
+#RUN ABORT WAIT BLOCK DISCARDOLDEST
+thread_pool.default.whenBlockedPolicy=RUN
+thread_pool.default.startUpSize=4
+
+# Default Cache Event Queue thread pool config, used by auxiliaries
+thread_pool.cache_event_queue.useBoundary=false
+#thread_pool.cache_event_queue.boundarySize=2000
+#thread_pool.cache_event_queue.maximumPoolSize=10
+thread_pool.cache_event_queue.minimumPoolSize=5
+thread_pool.cache_event_queue.keepAliveTime=3500
+#thread_pool.cache_event_queue.whenBlockedPolicy=RUN
+thread_pool.cache_event_queue.startUpSize=5
+
+# Remote cache client thread pool config
+thread_pool.remote_cache_client.boundarySize=75
+thread_pool.remote_cache_client.maximumPoolSize=150
+thread_pool.remote_cache_client.minimumPoolSize=4
+thread_pool.remote_cache_client.keepAliveTime=350000
+thread_pool.remote_cache_client.whenBlockedPolicy=RUN
+thread_pool.remote_cache_client.startUpSize=4
+

Modified: jakarta/jcs/trunk/src/test-conf/TestUDPDiscovery.ccf
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test-conf/TestUDPDiscovery.ccf?rev=289379&r1=289378&r2=289379&view=diff
==============================================================================
Binary files - no diff available.

Modified: jakarta/jcs/trunk/src/test-conf/log4j.properties
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test-conf/log4j.properties?rev=289379&r1=289378&r2=289379&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test-conf/log4j.properties (original)
+++ jakarta/jcs/trunk/src/test-conf/log4j.properties Thu Sep 15 21:37:26 2005
@@ -6,7 +6,7 @@
 log4j.category.org.apache.jcs.engine.CacheEventQueueFactory=DEBUG
 log4j.category.org.apache.jcs.auxiliary.disk=DEBUG
 log4j.category.org.apache.jcs.auxiliary.remote=DEBUG
-log4j.category.org.apache.jcs.auxiliary.lateral=INFO
+log4j.category.org.apache.jcs.auxiliary.lateral=DEBUG
 log4j.category.org.apache.jcs.utils.threadpool=INFO
 
 log4j.appender.stdout=org.apache.log4j.ConsoleAppender

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java?rev=289379&r1=289378&r2=289379&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java
(original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPConcurrentRandom.java
Thu Sep 15 21:37:26 2005
@@ -61,11 +61,14 @@
         JCS cache = JCS.getInstance( region );
         
         
-        ILateralCacheAttributes lattr2 = new LateralCacheAttributes();
+        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
         lattr2.setTcpListenerPort( 1102 );
         lattr2.setTransmissionTypeName( "TCP" );
         lattr2.setTcpServer( "localhost:1102" );
 
+        // this service will put and remove using the lateral to
+        // the cache instance above
+        // the cache thinks it is different since the listenerid is different        
         LateralTCPService service = new LateralTCPService( lattr2 );
         service.setListenerId( 123456 );
 

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java?rev=289379&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java
(added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPFilterRemoveHashCode.java
Thu Sep 15 21:37:26 2005
@@ -0,0 +1,175 @@
+package org.apache.jcs.auxiliary.lateral.socket.tcp;
+
+import java.io.Serializable;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.behavior.ICacheElement;
+
+/**
+ * @author asmuts
+ */
+public class TestLateralTCPFilterRemoveHashCode
+    extends TestCase
+{
+
+    //private static boolean isSysOut = false;
+
+    private static boolean isSysOut = true;
+
+    /**
+     * Constructor for the TestDiskCache object.
+     * 
+     * @param testName
+     */
+    public TestLateralTCPFilterRemoveHashCode( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestTCPLateralRemoveFilter.ccf" );
+    }
+
+    /**
+     * 
+     * @throws Exception
+     */
+    public void test()
+        throws Exception
+    {
+        this.runTestForRegion( "region1", 1, 200, 1 );
+    }
+
+    /**
+     * This tests issues tons of puts. It also check to see that a key that was
+     * put in was removed by the clients remove command.
+     * 
+     * @param region
+     *            Name of the region to access
+     * @param range
+     * @param numOps
+     * @param testNum
+     * 
+     * @exception Exception
+     *                If an error occurs
+     */
+    public void runTestForRegion( String region, int range, int numOps, int testNum )
+        throws Exception
+    {
+
+        boolean show = true;//false;
+
+        JCS cache = JCS.getInstance( region );
+
+        Thread.sleep( 100 );
+
+        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
+        lattr2.setTcpListenerPort( 1102 );
+        lattr2.setTransmissionTypeName( "TCP" );
+        lattr2.setTcpServer( "localhost:1110" );
+        lattr2.setIssueRemoveOnPut( true );
+        // should still try to remove
+        lattr2.setAllowPut( false );
+
+        // this service will put and remove using the lateral to
+        // the cache instance above
+        // the cache thinks it is different since the listenerid is different
+        LateralTCPService service = new LateralTCPService( lattr2 );
+        service.setListenerId( 123456 );
+
+        String keyToBeRemovedOnPut = "test1";
+
+        String keyToNotBeRemovedOnPut = "test2";
+
+        Serializable dataToPassHashCodeCompare = new Serializable()
+        {
+            public int hashCode()
+            {
+                return 1;
+            }
+        };
+        //String dataToPassHashCodeCompare = "this should be the same and not
+        // get removed.";
+        //p( "dataToPassHashCodeCompare hashcode = " + +
+        // dataToPassHashCodeCompare.hashCode() );
+
+        cache.put( keyToBeRemovedOnPut, "this should get removed." );
+        ICacheElement element1 = new CacheElement( region, keyToBeRemovedOnPut, region
+            + ":data-this shouldn't get there" );
+        service.update( element1 );
+
+        cache.put( keyToNotBeRemovedOnPut, dataToPassHashCodeCompare );
+        ICacheElement element2 = new CacheElement( region, keyToNotBeRemovedOnPut, dataToPassHashCodeCompare
);
+        service.update( element2 );
+
+        /*
+         * try { for ( int i = 1; i < numOps; i++ ) { Random ran = new Random( i );
+         * int n = ran.nextInt( 4 ); int kn = ran.nextInt( range ); String key =
+         * "key" + kn;
+         * 
+         * ICacheElement element = new CacheElement( region, key, region +
+         * ":data" + i + " junk asdfffffffadfasdfasf " + kn + ":" + n );
+         * service.update( element ); if ( show ) { p( "put " + key ); }
+         * 
+         * if ( i % 100 == 0 ) { System.out.println( cache.getStats() ); }
+         *  } p( "Finished cycle of " + numOps ); } catch ( Exception e ) { p(
+         * e.toString() ); e.printStackTrace( System.out ); throw e; }
+         */
+
+        JCS jcs = JCS.getInstance( region );
+        String key = "testKey" + testNum;
+        String data = "testData" + testNum;
+        jcs.put( key, data );
+        String value = (String) jcs.get( key );
+        assertEquals( "Couldn't put normally.", data, value );
+
+        // make sure the items we can find are in the correct region.
+        for ( int i = 1; i < numOps; i++ )
+        {
+            String keyL = "key" + i;
+            String dataL = (String) jcs.get( keyL );
+            if ( dataL != null )
+            {
+                assertTrue( "Incorrect region detected.", dataL.startsWith( region ) );
+            }
+
+        }
+
+        Thread.sleep( 200 );
+
+        Object testObj1 = cache.get( keyToBeRemovedOnPut );
+        p( "test object1 = " + testObj1 );
+        assertNull( "The test object should have been remvoed by a put.", testObj1 );
+
+        Object testObj2 = cache.get( keyToNotBeRemovedOnPut );
+        p( "test object2 = " + testObj2 + " hashCode = " );
+        if ( testObj2 != null )
+        {
+            p( "test2 hashcode = " + +testObj2.hashCode() );
+        }
+        assertNotNull( "This should not have been removed, since the hascode were the same.",
testObj2 );
+
+    }
+
+    public static void p( String s )
+    {
+        if ( isSysOut )
+        {
+            System.out.println( s );
+        }
+        else
+        {
+            //if ( log.isInfoEnabled() )
+            //{
+            //    log.info( s );
+            //}
+        }
+    }
+}

Added: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPIssueRemoveOnPut.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPIssueRemoveOnPut.java?rev=289379&view=auto
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPIssueRemoveOnPut.java
(added)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestLateralTCPIssueRemoveOnPut.java
Thu Sep 15 21:37:26 2005
@@ -0,0 +1,167 @@
+package org.apache.jcs.auxiliary.lateral.socket.tcp;
+
+import java.util.Random;
+
+import junit.framework.TestCase;
+
+import org.apache.jcs.JCS;
+import org.apache.jcs.engine.CacheElement;
+import org.apache.jcs.engine.behavior.ICacheElement;
+
+/**
+ * @author asmuts
+ */
+public class TestLateralTCPIssueRemoveOnPut
+    extends TestCase
+{
+
+    //private static boolean isSysOut = false;
+
+    private static boolean isSysOut = true;
+
+    /**
+     * Constructor for the TestDiskCache object.
+     * 
+     * @param testName
+     */
+    public TestLateralTCPIssueRemoveOnPut( String testName )
+    {
+        super( testName );
+    }
+
+    /**
+     * Test setup
+     */
+    public void setUp()
+    {
+        JCS.setConfigFilename( "/TestTCPLateralIssueRemoveCache.ccf" );
+    }
+
+    /**
+     * 
+     * @throws Exception
+     */
+    public void test()
+        throws Exception
+    {
+        this.runTestForRegion( "region1", 1, 200, 1 );
+    }
+
+    /**
+     * This tests issues tons of puts. It also check to see that a key that was
+     * put in was removed by the clients remove command.
+     * 
+     * @param region
+     *            Name of the region to access
+     * @param range
+     * @param numOps
+     * @param testNum
+     * 
+     * @exception Exception
+     *                If an error occurs
+     */
+    public void runTestForRegion( String region, int range, int numOps, int testNum )
+        throws Exception
+    {
+
+        boolean show = true;//false;
+
+        JCS cache = JCS.getInstance( region );
+
+        Thread.sleep( 100 );
+
+        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
+        lattr2.setTcpListenerPort( 1102 );
+        lattr2.setTransmissionTypeName( "TCP" );
+        lattr2.setTcpServer( "localhost:1110" );
+        lattr2.setIssueRemoveOnPut( true );
+        // should still try to remove
+        lattr2.setAllowPut( false );
+
+        // this service will put and remove using the lateral to
+        // the cache instance above
+        // the cache thinks it is different since the listenerid is different
+        LateralTCPService service = new LateralTCPService( lattr2 );
+        service.setListenerId( 123456 );
+
+        String keyToBeRemovedOnPut = "test1";
+        cache.put( keyToBeRemovedOnPut, "this should get remvoed" );
+
+        ICacheElement element1 = new CacheElement( region, keyToBeRemovedOnPut, region
+            + ":data-this shouldn't get there" );
+        service.update( element1 );
+
+        try
+        {
+            for ( int i = 1; i < numOps; i++ )
+            {
+                Random ran = new Random( i );
+                int n = ran.nextInt( 4 );
+                int kn = ran.nextInt( range );
+                String key = "key" + kn;
+
+                ICacheElement element = new CacheElement( region, key, region + ":data" +
i
+                    + " junk asdfffffffadfasdfasf " + kn + ":" + n );
+                service.update( element );
+                if ( show )
+                {
+                    p( "put " + key );
+                }
+
+                if ( i % 100 == 0 )
+                {
+                    System.out.println( cache.getStats() );
+                }
+
+            }
+            p( "Finished cycle of " + numOps );
+        }
+        catch ( Exception e )
+        {
+            p( e.toString() );
+            e.printStackTrace( System.out );
+            throw e;
+        }
+
+        JCS jcs = JCS.getInstance( region );
+        String key = "testKey" + testNum;
+        String data = "testData" + testNum;
+        jcs.put( key, data );
+        String value = (String) jcs.get( key );
+        assertEquals( "Couldn't put normally.", data, value );
+
+        // make sure the items we can find are in the correct region.
+        for ( int i = 1; i < numOps; i++ )
+        {
+            String keyL = "key" + i;
+            String dataL = (String) jcs.get( keyL );
+            if ( dataL != null )
+            {
+                assertTrue( "Incorrect region detected.", dataL.startsWith( region ) );
+            }
+
+        }
+
+        Thread.sleep( 200 );
+        
+        Object testObj = cache.get( keyToBeRemovedOnPut );
+        p( "test object = " + testObj );
+        assertNull( "The test object should have been remvoed by a put.", testObj );
+
+    }
+
+    public static void p( String s )
+    {
+        if ( isSysOut )
+        {
+            System.out.println( s );
+        }
+        else
+        {
+            //if ( log.isInfoEnabled() )
+            //{
+            //    log.info( s );
+            //}
+        }
+    }
+}

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java?rev=289379&r1=289378&r2=289379&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java
(original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/TestTCPLateral.java
Thu Sep 15 21:37:26 2005
@@ -43,7 +43,7 @@
 
         JCS jcs = JCS.getInstance( "test" );
 
-        LateralCacheAttributes lac = new LateralCacheAttributes();
+        TCPLateralCacheAttributes lac = new TCPLateralCacheAttributes();
         lac.setTransmissionType( LateralCacheAttributes.TCP );
         lac.setTcpServer( "localhost" + ":" + 8111 );
         lac.setTcpListenerPort( 8111 );
@@ -77,7 +77,7 @@
     public void testReceive()
         throws Exception
     {
-        ILateralCacheAttributes lattr = new LateralCacheAttributes();
+        TCPLateralCacheAttributes lattr = new TCPLateralCacheAttributes();
         lattr.setTcpListenerPort( 1101 );
         lattr.setTransmissionTypeName( "TCP" );
         CompositeCacheManagerMockImpl cacheMgr = new CompositeCacheManagerMockImpl();
@@ -95,7 +95,7 @@
         LateralTCPListener listener = (LateralTCPListener) LateralTCPListener.getInstance(
lattr, cacheMgr );
 
         
-        ILateralCacheAttributes lattr2 = new LateralCacheAttributes();
+        TCPLateralCacheAttributes lattr2 = new TCPLateralCacheAttributes();
         lattr2.setTcpListenerPort( 1102 );
         lattr2.setTransmissionTypeName( "TCP" );
         lattr2.setTcpServer( "localhost:1101" );

Modified: jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java
URL: http://svn.apache.org/viewcvs/jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java?rev=289379&r1=289378&r2=289379&view=diff
==============================================================================
--- jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java
(original)
+++ jakarta/jcs/trunk/src/test/org/apache/jcs/auxiliary/lateral/socket/tcp/discovery/TestUDPDiscovery.java
Thu Sep 15 21:37:26 2005
@@ -9,6 +9,7 @@
 import org.apache.jcs.auxiliary.lateral.LateralCacheAttributes;
 import org.apache.jcs.auxiliary.lateral.LateralCacheNoWait;
 import org.apache.jcs.auxiliary.lateral.LateralCacheNoWaitFacade;
+import org.apache.jcs.auxiliary.lateral.socket.tcp.TCPLateralCacheAttributes;
 import org.apache.jcs.engine.behavior.ICompositeCacheManager;
 import org.apache.jcs.engine.control.CompositeCacheManager;
 
@@ -57,7 +58,7 @@
         throws Exception
     {
         // create the attributes for the service
-        LateralCacheAttributes lac = new LateralCacheAttributes();
+        TCPLateralCacheAttributes lac = new TCPLateralCacheAttributes();
         lac.setTransmissionType( LateralCacheAttributes.TCP );
         lac.setTcpServer( "localhost" + ":" + 1111 );
 
@@ -153,7 +154,7 @@
         LateralCacheNoWaitFacade lcnwf = new LateralCacheNoWaitFacade( (LateralCacheNoWait[])
noWaits
             .toArray( new LateralCacheNoWait[0] ), "testCache1" );
 
-        LateralCacheAttributes lac = new LateralCacheAttributes();
+        TCPLateralCacheAttributes lac = new TCPLateralCacheAttributes();
         lac.setTransmissionType( LateralCacheAttributes.TCP );
         lac.setTcpServer( "localhost" + ":" + 1111 );
 



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


Mime
View raw message