public void testSaveLoadKeysSize() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName( "testSaveLoadKeys" ); attributes.setDiskPath( rootDirName ); attributes.setMaxKeySize( 10000 ); attributes.setBlockSizeBytes( 2000 ); testSaveLoadKeysInner(attributes); }
/** * Write out the values for debugging purposes. * <p> * @return String */ @Override public String toString() { StringBuilder str = new StringBuilder(); str.append( "\nBlockDiskAttributes " ); str.append( "\n DiskPath [" + this.getDiskPath() + "]" ); str.append( "\n MaxKeySize [" + this.getMaxKeySize() + "]" ); str.append( "\n MaxPurgatorySize [" + this.getMaxPurgatorySize() + "]" ); str.append( "\n BlockSizeBytes [" + this.getBlockSizeBytes() + "]" ); str.append( "\n KeyPersistenceIntervalSeconds [" + this.getKeyPersistenceIntervalSeconds() + "]" ); str.append( "\n DiskLimitType [" + this.getDiskLimitType() + "]" ); return str.toString(); } }
this.logCacheName = "Region [" + this.blockDiskCacheAttributes.getCacheName() + "] "; this.fileName = this.blockDiskCacheAttributes.getCacheName(); this.maxKeySize = cacheAttributes.getMaxKeySize(); this.blockDiskCache = blockDiskCache; this.diskLimitType = cacheAttributes.getDiskLimitType(); this.blockSize = cacheAttributes.getBlockSizeBytes(); File rootDirectory = cacheAttributes.getDiskPath();
@Override public BlockDiskCacheAttributes getCacheAttributes() { BlockDiskCacheAttributes ret = new BlockDiskCacheAttributes(); ret.setDiskLimitType(DiskLimitType.COUNT); return ret; }
public void testPutGetMatching_SmallWait() throws Exception { // SETUP int items = 200; String cacheName = "testPutGetMatching_SmallWait"; BlockDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName( cacheName ); cattr.setMaxKeySize( 100 ); cattr.setDiskPath( "target/test-sandbox/BlockDiskCacheUnitTest" ); BlockDiskCache<String, String> diskCache = new BlockDiskCache<String, String>( cattr ); // DO WORK for ( int i = 0; i <= items; i++ ) { diskCache.update( new CacheElement<String, String>( cacheName, i + ":key", cacheName + " data " + i ) ); } Thread.sleep( 500 ); Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching( "1.8.+" ); // VERIFY assertEquals( "Wrong number returned", 10, matchingResults.size() ); //System.out.println( "matchingResults.keySet() " + matchingResults.keySet() ); //System.out.println( "\nAFTER TEST \n" + diskCache.getStats() ); }
this.rootDirectory = cacheAttributes.getDiskPath(); if ( this.blockDiskCacheAttributes.getBlockSizeBytes() > 0 ) this.blockDiskCacheAttributes.getBlockSizeBytes() );
/** * @see org.apache.commons.jcs.engine.behavior.IRequireScheduler#setScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) */ @Override public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutor) { // add this region to the persistence thread. // TODO we might need to stagger this a bit. if ( this.blockDiskCacheAttributes.getKeyPersistenceIntervalSeconds() > 0 ) { future = scheduledExecutor.scheduleAtFixedRate( new Runnable() { @Override public void run() { keyStore.saveKeys(); } }, this.blockDiskCacheAttributes.getKeyPersistenceIntervalSeconds(), this.blockDiskCacheAttributes.getKeyPersistenceIntervalSeconds(), TimeUnit.SECONDS); } }
public void testPutGetMatching_SmallWait() throws Exception { // SETUP int items = 200; String cacheName = "testPutGetMatching_SmallWait"; BlockDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName(cacheName); cattr.setMaxKeySize(100); cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest"); BlockDiskCache<String, String> diskCache = new BlockDiskCache<String, String>(cattr); // DO WORK for (int i = 0; i <= items; i++) { diskCache.update(new CacheElement<String, String>(cacheName, i + ":key", cacheName + " data " + i)); } Thread.sleep(500); Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+"); // VERIFY assertEquals("Wrong number returned", 10, matchingResults.size()); // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() ); // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() ); }
@Override public BlockDiskCacheAttributes getCacheAttributes() { BlockDiskCacheAttributes ret = new BlockDiskCacheAttributes(); ret.setDiskLimitType(DiskLimitType.SIZE); return ret; }
this.rootDirectory = cacheAttributes.getDiskPath(); if ( this.blockDiskCacheAttributes.getBlockSizeBytes() > 0 ) this.blockDiskCacheAttributes.getBlockSizeBytes(), getElementSerializer() );
/** * @see org.apache.commons.jcs.engine.behavior.IRequireScheduler#setScheduledExecutorService(java.util.concurrent.ScheduledExecutorService) */ @Override public void setScheduledExecutorService(ScheduledExecutorService scheduledExecutor) { // add this region to the persistence thread. // TODO we might need to stagger this a bit. if ( this.blockDiskCacheAttributes.getKeyPersistenceIntervalSeconds() > 0 ) { scheduledExecutor.scheduleAtFixedRate( new Runnable() { @Override public void run() { keyStore.saveKeys(); } }, this.blockDiskCacheAttributes.getKeyPersistenceIntervalSeconds(), this.blockDiskCacheAttributes.getKeyPersistenceIntervalSeconds(), TimeUnit.SECONDS); } }
public void testPutKeysSize() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName( "testPutKeys" ); attributes.setDiskPath( rootDirName ); attributes.setMaxKeySize( 100000 ); attributes.setBlockSizeBytes( 1024 ); attributes.setDiskLimitType(DiskLimitType.SIZE); innerTestPutKeys(attributes); }
/** * Write out the values for debugging purposes. * <p> * @return String */ @Override public String toString() { StringBuilder str = new StringBuilder(); str.append( "\nBlockDiskAttributes " ); str.append( "\n DiskPath [" + this.getDiskPath() + "]" ); str.append( "\n MaxKeySize [" + this.getMaxKeySize() + "]" ); str.append( "\n MaxPurgatorySize [" + this.getMaxPurgatorySize() + "]" ); str.append( "\n BlockSizeBytes [" + this.getBlockSizeBytes() + "]" ); str.append( "\n KeyPersistenceIntervalSeconds [" + this.getKeyPersistenceIntervalSeconds() + "]" ); str.append( "\n DiskLimitType [" + this.getDiskLimitType() + "]" ); return str.toString(); } }
/** * Test the basic get matching. With no wait this will all come from purgatory. * <p> * * @throws Exception */ public void testPutGetMatching_NoWait() throws Exception { // SETUP int items = 200; String cacheName = "testPutGetMatching_NoWait"; BlockDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName(cacheName); cattr.setMaxKeySize(100); cattr.setDiskPath("target/test-sandbox/BlockDiskCacheUnitTest"); BlockDiskCache<String, String> diskCache = new BlockDiskCache<String, String>(cattr); // DO WORK for (int i = 0; i <= items; i++) { diskCache.update(new CacheElement<String, String>(cacheName, i + ":key", cacheName + " data " + i)); } Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching("1.8.+"); // VERIFY assertEquals("Wrong number returned", 10, matchingResults.size()); // System.out.println( "matchingResults.keySet() " + matchingResults.keySet() ); // System.out.println( "\nAFTER TEST \n" + diskCache.getStats() ); }
this.logCacheName = "Region [" + this.blockDiskCacheAttributes.getCacheName() + "] "; this.fileName = this.blockDiskCacheAttributes.getCacheName(); this.maxKeySize = cacheAttributes.getMaxKeySize(); this.blockDiskCache = blockDiskCache; this.diskLimitType = cacheAttributes.getDiskLimitType(); this.blockSize = cacheAttributes.getBlockSizeBytes(); File rootDirectory = cacheAttributes.getDiskPath();
@Override public BlockDiskCacheAttributes getCacheAttributes() { BlockDiskCacheAttributes ret = new BlockDiskCacheAttributes(); ret.setDiskLimitType(DiskLimitType.SIZE); return ret; }
public void testPutKeysSize() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName("testPutKeys"); attributes.setDiskPath(rootDirName); attributes.setMaxKeySize(100000); attributes.setBlockSizeBytes(1024); attributes.setDiskLimitType(DiskLimitType.SIZE); innerTestPutKeys(attributes); }
/** * Test the basic get matching. With no wait this will all come from purgatory. * <p> * @throws Exception */ public void testPutGetMatching_NoWait() throws Exception { // SETUP int items = 200; String cacheName = "testPutGetMatching_NoWait"; BlockDiskCacheAttributes cattr = getCacheAttributes(); cattr.setCacheName( cacheName ); cattr.setMaxKeySize( 100 ); cattr.setDiskPath( "target/test-sandbox/BlockDiskCacheUnitTest" ); BlockDiskCache<String, String> diskCache = new BlockDiskCache<String, String>( cattr ); // DO WORK for ( int i = 0; i <= items; i++ ) { diskCache.update( new CacheElement<String, String>( cacheName, i + ":key", cacheName + " data " + i ) ); } Map<String, ICacheElement<String, String>> matchingResults = diskCache.getMatching( "1.8.+" ); // VERIFY assertEquals( "Wrong number returned", 10, matchingResults.size() ); //System.out.println( "matchingResults.keySet() " + matchingResults.keySet() ); //System.out.println( "\nAFTER TEST \n" + diskCache.getStats() ); }
@Override public BlockDiskCacheAttributes getCacheAttributes() { BlockDiskCacheAttributes ret = new BlockDiskCacheAttributes(); ret.setDiskLimitType(DiskLimitType.COUNT); return ret; }
public void testSaveLoadKeysSize() throws Exception { // SETUP BlockDiskCacheAttributes attributes = new BlockDiskCacheAttributes(); attributes.setCacheName("testSaveLoadKeys"); attributes.setDiskPath(rootDirName); attributes.setMaxKeySize(10000); attributes.setBlockSizeBytes(2000); testSaveLoadKeysInner(attributes); }