You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@commons.apache.org by Duncan Jones <dj...@apache.org> on 2014/11/14 12:56:56 UTC

Re: [JCS] disk persistence - same conf file, different results

Hi João,

This is probably best addressed to the Commons user mailing list. I've
BCC'd the issues list so people know where this email thread went to.
Please also prefix the Commons component into the subject line (in
this case [JCS], which I've done for you).

Duncan

On 14 November 2014 11:25, joao tiago a. m. viegas <jt...@gmail.com> wrote:
> hello,
>
> I've been testing jcs, I want a cache that allows me to save all the
> eleemnts when I shutsown gracefully, and later when I create a new instance
> of the same cache I can get those same objects I had before in the first
> encarnation of that same cache.
> I made this test and I'm actually using two identical confs, but for some
> reason I'm getting different results.
> Could you please help me understanding why?
>
> tests are:
>
> private static final String[] configs = new String[]
>> {"ObjectPersistingInMemoryAndDisk_x1.ccf",
>> "ObjectPersistingInMemoryAndDisk_x2.ccf"};
>>
> private static final String[] expecteds = new String[] {null, null};
>
> private static final String region = "OUR_REGION";
>> private static final String key="key", value="value";
>
> .....
>> .....
>
> @Test
>> public void testObjectPersistingInMemoryAndDisk_1() throws Exception{
>>
>> performObjectPersistingInMemoryAndDisk(JCS_CONFIG_DIR + configs[0],
>> expecteds[0]);
>> }
>>
>> @Test
>> public void testObjectPersistingInMemoryAndDisk_2() throws Exception{
>>
>> performObjectPersistingInMemoryAndDisk(JCS_CONFIG_DIR + configs[1],
>> expecteds[1]);
>> }
>>
>> private void performObjectPersistingInMemoryAndDisk(String configFile,
>> String expected) throws Exception{
>>
>>
>> System.out.println("-----------------------------------------------------------");
>>
>> System.out.println("testing with config file:" + configFile);
>> JCS.setConfigFilename(configFile);
>> JCS cache = JCS.getInstance(region);
>> cache.put(key, value);
>> Thread.sleep(5000);
>> Assert.assertNotNull(cache.get(key));
>> Assert.assertEquals(value, cache.get(key));
>>
>> IStats stats = cache.getStatistics().getAuxiliaryCacheStats()[0];
>>
>> cache.freeMemoryElements(Integer.parseInt(stats.getStatElements()[0].getData()));
>> Thread.sleep(5000);
>> Assert.assertNotNull(cache.get(key));
>> Assert.assertEquals(value, cache.get(key));
>> System.out.println(cache.getStats());
>> CompositeCacheManager.getInstance().shutDown();
>>
>> Thread.sleep(5000);
>>
>> JCS.setConfigFilename(configFile);
>> cache = JCS.getInstance(region);
>> Assert.assertEquals(expected, cache.get(key));
>>
>> System.out.println(cache.getStats());
>> cache.clear();
>> cache.dispose();
>> CompositeCacheManager.getInstance().shutDown();
>> }
>
>
> ...the confs are:
>
> -- ObjectPersistingInMemoryAndDisk_x1.ccf --
> # DEFAULT CACHE REGION
> jcs.default=DISK_REGION
> jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
> jcs.default.cacheattributes.MaxObjects=1000
> jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> #jcs.default.cacheattributes.DiskUsagePatternName=UPDATE
>
> jcs.region.OUR_REGION=DISK_REGION
> jcs.region.OUR_REGION.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
> jcs.region.OUR_REGION.cacheattributes.MaxObjects=1000
> jcs.region.OUR_REGION.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> jcs.region.OUR_REGION.cacheattributes.UseMemoryShrinker=true
> jcs.region.OUR_REGION.cacheattributes.MaxMemoryIdleTimeSeconds=3600
> jcs.region.OUR_REGION.cacheattributes.ShrinkerIntervalSeconds=60
> jcs.region.OUR_REGION.cacheattributes.MaxSpoolPerRun=500
> jcs.region.OUR_REGION.elementattributes=org.apache.jcs.engine.ElementAttributes
> jcs.region.OUR_REGION.elementattributes.IsEternal=false
>
> jcs.auxiliary.DISK_REGION=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
> jcs.auxiliary.DISK_REGION.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
> jcs.auxiliary.DISK_REGION.attributes.DiskPath=/tmp/jcs/cache
> jcs.auxiliary.DISK_REGION.attributes.maxKeySize=100000
>
>
> -- ObjectPersistingInMemoryAndDisk_x2.ccf --
> # DEFAULT CACHE REGION
> jcs.default=DISK_REGION
> jcs.default.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
> jcs.default.cacheattributes.MaxObjects=1000
> jcs.default.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> #jcs.default.cacheattributes.DiskUsagePatternName=UPDATE
>
> jcs.region.OUR_REGION=DISK_REGION
> jcs.region.OUR_REGION.cacheattributes=org.apache.jcs.engine.CompositeCacheAttributes
> jcs.region.OUR_REGION.cacheattributes.MaxObjects=1000
> jcs.region.OUR_REGION.cacheattributes.MemoryCacheName=org.apache.jcs.engine.memory.lru.LRUMemoryCache
> jcs.region.OUR_REGION.cacheattributes.UseMemoryShrinker=true
> jcs.region.OUR_REGION.cacheattributes.MaxMemoryIdleTimeSeconds=3600
> jcs.region.OUR_REGION.cacheattributes.ShrinkerIntervalSeconds=60
> jcs.region.OUR_REGION.cacheattributes.MaxSpoolPerRun=500
> jcs.region.OUR_REGION.elementattributes=org.apache.jcs.engine.ElementAttributes
> jcs.region.OUR_REGION.elementattributes.IsEternal=false
>
> jcs.auxiliary.DISK_REGION=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheFactory
> jcs.auxiliary.DISK_REGION.attributes=org.apache.jcs.auxiliary.disk.indexed.IndexedDiskCacheAttributes
> jcs.auxiliary.DISK_REGION.attributes.DiskPath=/tmp/jcs/cache
> jcs.auxiliary.DISK_REGION.attributes.maxKeySize=100000
>
>
>
>
> os melhores cumprimentos / best regards / Mit freundlichen Grüssen / Saludos
>
> joão tiago viegas