jakarta-jcs-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Youngho Cho" <youn...@nannet.co.kr>
Subject Re: IndexedDiskCache insert, remove and reinsert question
Date Thu, 06 Nov 2008 23:28:44 GMT
Hello Nial,

Thanks for your comment and if you feel uncomportable from my long mail I apolozy for this.

But your comment didn't help.


The reason why I set MaxObjects=0 is that
I would like to test IndexedDiskCache only.

I bollowed the test configure from
http://svn.apache.org/viewvc/jakarta/jcs/trunk/src/test-conf/TestDiskCacheNoMemory.ccf?revision=536904&view=markup


As I understanding 

the MaxObjects property is controlled by Memory cache how may item can have.
http://jakarta.apache.org/jcs/RegionProperties.html

and at the IndexedDiskCache the similar property for the controll amount item to handle
is that maxKeySize which I set maxKeySize=1000000
http://jakarta.apache.org/jcs/IndexedDiskCacheProperties.html

For the test,
If I put whole item into Memory cache by setting MaxObjects=100000 
than the test is PASS.

But it is Memory cache usage Not IndexedDiskCache.

Probably I have some miss configure or mis understand for my test.
I don't know the reason, But I have to understand and solve this problem.


Sorry for long email again,

Thanks,
Youngho


----- Original Message ----- 
From: "Niall Gallagher" <niall@switchfire.com>
To: "JCS Users List" <jcs-users@jakarta.apache.org>
Sent: Thursday, November 06, 2008 10:32 PM
Subject: Re: IndexedDiskCache insert, remove and reinsert question


> Hi,
> 
> At first glance- why have you set MaxObjects=0 everywhere? This
> configures the cache to not store any objects. Aside from that your test
> case is too long to send to a mailing list. Don't wrap your calls to the
> JCS API in helper methods in a test case. Everyone on this mailing list
> will be familiar with the standard JCS API, and won't have time to learn
> how the various layers of indirection in your test case work. Keep it
> simple. Anyway I'd guess the problem is with your MaxObjects setting.
> 
> Kind regards,
> Niall
> 
> -----Original Message-----
> From: Youngho Cho <youngho@nannet.co.kr>
> Reply-to: "JCS Users List" <jcs-users@jakarta.apache.org>
> To: JCS Users List <jcs-users@jakarta.apache.org>
> Subject: IndexedDiskCache insert, remove and reinsert question
> Date: Thu, 6 Nov 2008 10:29:38 +0900
> 
> 
> Hello,
> 
> I tested some objects put into IndexedDiskCache and remove and reinsert test like following.
> But I can not pass the test.
> 
> Is there something wrong in cache.ccf file ?
> How can I pass the test ?
> 
> 
> 
> Thanks,
> 
> Youngho
> 
> 
> 
> 1. test cache.ccf
> 
> # DEFAULT CACHE REGION
> jcs.default=DC
> jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
> jcs.default.cacheattributes.MaxObjects=0
> jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> jcs.default.cacheattributes.DiskUsagePatternName=UPDATE
> jcs.default.elementattributes=org.apache.jcs.engine.ElementAttributes
> jcs.default.elementattributes.IsEternal=false
> 
> 
> # SYSTEM GROUP ID CACHE
> jcs.system.groupIdCache=DC
> jcs.system.groupIdCache.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
> jcs.system.groupIdCache.cacheattributes.MaxObjects=0
> jcs.system.groupIdCache.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> 
> 
> # AVAILABLE AUXILIARY CACHES
> jcs.auxiliary.DC=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
> jcs.auxiliary.DC.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
> jcs.auxiliary.DC.attributes.DiskPath=d:/tmp
> jcs.auxiliary.DC.attributes.maxKeySize=1000000
> jcs.auxiliary.DC.attributes.MaxPurgatorySize=100
> jcs.auxiliary.DC.attributes.OptimizeOnShutdown=false
> 
> # PRE-DEFINED CACHE REGIONS
> jcs.region.testCache1=DC
> jcs.region.testCache1.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
> jcs.region.testCache1.cacheattributes.MaxObjects=0
> jcs.region.testCache1.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> 
> jcs.region.testCache1.elementattributes=org.apache.jcs.engine.ElementAttributes
> jcs.region.testCache1.elementattributes.IsEternal=false
> jcs.region.testCache1.elementattributes.MaxLifeSeconds=0
> jcs.region.testCache1.elementattributes.IsSpool=true
> jcs.region.testCache1.elementattributes.IsLateral=true
> jcs.region.testCache1.elementattributes.IsRemote=true
> 
> 
> 
> 2. test class
> 
> //
> // JCSTest .java
> //
> 
> import java.io.File;
> 
> import junit.framework.TestCase;
> 
> import org.apache.jcs.JCS;
> import org.apache.jcs.access.exception.CacheException;
> import org.apache.jcs.engine.CompositeCacheAttributes;
> import org.apache.jcs.engine.behavior.ICompositeCacheAttributes;
> import org.apache.jcs.utils.struct.LRUMap;
> 
> public class JCSTest extends TestCase  
> {
> 
>    protected static int MAX_NUM = 100000;
> 
>    protected JCS jcs = null;
> 
>    protected void setUp() throws Exception
>    {
>        File file = new File("d:/tmp");
>        if(file.exists())
>        {
>            File[] files = file.listFiles();
>            for(int i=0; i < files.length; i++)
>            {
>                files[i].delete();
>            }
>        }
>        JCS.setConfigFilename( "/TestJCS.ccf" );
>        jcs = JCS.getInstance("testCache1");        
>    }
> 
> 
>    protected void tearDown()
>        throws Exception
>    {
>        jcs.dispose();
>    }
> 
>    protected void insert(int key) throws CacheException 
>    {
>        Object obj = getCachedObject(key);
>        jcs.put(new Integer(key), obj);
>    }
>    
>    protected void insertMany(int maxNum) throws CacheException 
>    {
>        for (int i = 0; i < maxNum; i++) 
>        {
>            insert(i);            
>            if ((i % 20000) == 0) 
>            {
>                try
>                {
>                    Thread.sleep(20000);
>                }
>                catch(Exception e)
>                {
>                    //
>                }
>            }            
>        }
>    }
>    
>    protected Object get(int key) 
>    {
>        return jcs.get(new Integer(key));
>    }
>    
>    protected void getMany(int maxNum) 
>    {
>        for (int i = 0; i < maxNum; i++) 
>        {
>            assertNotNull(getCachedObject(i).toString(), get(i)); 
>        }
>    }
>    
>    protected void testMany(int maxNum) throws Exception
>    {
>        for (int i = 0; i < maxNum; i++) 
>        {
>            final MockCache obj = (MockCache)get(i);
>            assertNotNull(getCachedObject(i).toString(), obj);             
>            assertEquals(getCachedObject(i).getValue(), obj.getValue());             
  
>            // remove
>            jcs.remove(new Integer(i));
>            assertNull("[" + i  +"] should be removed" , get(i));
>            
>            // reinsert again
>            insert(i);
>                
>            final MockCache obj1 = (MockCache)get(i);
>            // retest
>            assertEquals(getCachedObject(i).getValue(), obj.getValue(), obj1.getValue());
>        }
>    }
> 
>    protected void printStats() 
>    {
>        System.out.println(jcs.getStats());
>    }
> 
>    public void testJCS() throws Exception
>    {
>            long start = System.currentTimeMillis();
>            insertMany(MAX_NUM);       
>            System.out.println(" ");
>            System.out.println("[DONE] : insert takes " + (System.currentTimeMillis()
- start ) + "msec ");            
>            
>            start = System.currentTimeMillis();            
>            getMany(MAX_NUM);
>            System.out.println(" ");
>            System.out.println("[DONE] : get takes " + (System.currentTimeMillis() - start
) + "msec ");
>            
>            start = System.currentTimeMillis();   
>            testMany(MAX_NUM);
>            System.out.println(" ");
>            System.out.println("[DONE] : test takes " + (System.currentTimeMillis() -
start) + "msec ");
>            
>            printStats();      
>    }
>    
>    protected static MockCache getCachedObject(int i) 
>    {
>        return new MockCache(Integer.toString(i),
>                "some string [" + Integer.toString(i) + "]");
>    }
> }
> 
> //
> // MockCache.java
> //
> import java.io.Serializable;
> 
> public class MockCache implements Serializable
> {
> 
>    private String key = null;
>    private String value = null;
>    
>    /**
>     *
>     */
>    public MockCache()
>    {
>    }
>    
>    /**
>     *
>     */
>    public MockCache(String key, String value)
>    {
>        this.key = key;
>        this.value = value;
>    }    
>    
>    public String getValue()
>    {
>        return this.value;
>    }
>    
>    public String toString()
>    {
>        return "{[" + this.key + "] " + this.value + "}";
>    }
> }
> 
>
Mime
View raw message