public void testAutoCompact() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setAutoCompact(true); assertEquals(true, dsf.create("test").getAutoCompact()); dsf.setAutoCompact(false); assertEquals(false, dsf.create("test2").getAutoCompact()); }
/** * Configures the disk store factory using this disk store description. */ public void configure(DiskStoreFactory f) { f.setAllowForceCompaction(this.getAllowForceCompaction().booleanValue()); f.setAutoCompact(this.getAutoCompact().booleanValue()); f.setCompactionThreshold(this.getCompactionThreshold().intValue()); f.setDiskDirsAndSizes(this.getDiskDirs(), this.getDiskDirSizes()); f.setMaxOplogSize(this.getMaxOplogSize().longValue()); f.setQueueSize(this.getQueueSize().intValue()); f.setTimeInterval(this.getTimeInterval().longValue()); f.setWriteBufferSize(this.getWriteBufferSize().intValue()); }
private Region<?,?> createRepRegWithPersistence(String regionName, String diskStoreName, String diskDirName) { Cache cache = getCache(); File diskStoreDirFile = new File(diskDirName); diskStoreDirFile.deleteOnExit(); if (!diskStoreDirFile.exists()) { diskStoreDirFile.mkdirs(); } DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(); diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile }); diskStoreFactory.setMaxOplogSize(1); diskStoreFactory.setAllowForceCompaction(true); diskStoreFactory.setAutoCompact(false); diskStoreFactory.create(diskStoreName); /**** * Eviction Attributes */ EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK); RegionFactory regionFactory = cache.createRegionFactory(); regionFactory.setDiskStoreName(diskStoreName); regionFactory.setDiskSynchronous(true); regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); regionFactory.setEvictionAttributes(ea); return regionFactory.create(regionName); }
private Region<?,?> createParRegWithPersistence(String regionName, String diskStoreName, String diskDirName) { Cache cache = getCache(); File diskStoreDirFile = new File(diskDirName); diskStoreDirFile.deleteOnExit(); if (!diskStoreDirFile.exists()) { diskStoreDirFile.mkdirs(); } DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(); diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile }); diskStoreFactory.setMaxOplogSize(1); diskStoreFactory.setAllowForceCompaction(true); diskStoreFactory.setAutoCompact(false); diskStoreFactory.create(diskStoreName); /**** * Eviction Attributes */ EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK); RegionFactory regionFactory = cache.createRegionFactory(); regionFactory.setDiskStoreName(diskStoreName); regionFactory.setDiskSynchronous(true); regionFactory.setDataPolicy(DataPolicy.PERSISTENT_PARTITION); regionFactory.setEvictionAttributes(ea); return regionFactory.create(regionName); }
dsf.setDiskDirsAndSizes(dirs, new int[] { Integer.MAX_VALUE }); dsf.setAutoCompact(false); DiskStore ds = dsf.create(regionName); factory.setDiskStoreName(ds.getName());
.setQueueSize(1) .setMaxOplogSize(60) // does the test want 60 bytes or 60M? .setAutoCompact(false) .setTimeInterval(1000) .create("Bug40299DUnitTest")
dsf.setDiskDirsAndSizes(dirs, new int[] { Integer.MAX_VALUE }); dsf.setAutoCompact(false); DirectoryHolder.SET_DIRECTORY_SIZE_IN_BYTES_FOR_TESTING_PURPOSES = true; try {
public void run() { Cache cache = getCache(); File diskStoreDirFile = new File(diskStoreName + vm.getPid()); diskStoreDirFile.mkdirs(); DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(); diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile }); diskStoreFactory.setMaxOplogSize(1); diskStoreFactory.setAllowForceCompaction(true); diskStoreFactory.setAutoCompact(false); diskStoreFactory.create(regionName); RegionFactory regionFactory = cache.createRegionFactory(); regionFactory.setDiskStoreName(regionName); regionFactory.setDiskSynchronous(true); regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); regionFactory.setScope(Scope.DISTRIBUTED_ACK); regionFactory.create(regionName); } });
private Region<?,?> createParRegWithPersistence(String regionName, String diskStoreName, String diskDirName) { Cache cache = getCache(); File diskStoreDirFile = new File(diskDirName); if (!diskStoreDirFile.exists()) { diskStoreDirFile.mkdirs(); } DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(); diskStoreFactory.setDiskDirs(new File[] { diskStoreDirFile }); diskStoreFactory.setMaxOplogSize(1); diskStoreFactory.setAllowForceCompaction(true); diskStoreFactory.setAutoCompact(false); diskStoreFactory.create(diskStoreName); /**** * Eviction Attributes */ EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK); RegionFactory regionFactory = cache.createRegionFactory(); regionFactory.setDiskStoreName(diskStoreName); regionFactory.setDiskSynchronous(true); regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); regionFactory.setScope(Scope.DISTRIBUTED_ACK); regionFactory.setEvictionAttributes(ea); return regionFactory.create(regionName); }
public void run() { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File dir = getDiskDirForVM(vm); dir.mkdirs(); dsf.setDiskDirs(new File[] { dir }); dsf.setMaxOplogSize(1); dsf.setAllowForceCompaction(true); dsf.setAutoCompact(false); DiskStore ds = dsf.create(REGION_NAME); RegionFactory rf = cache.createRegionFactory(); rf.setDiskStoreName(ds.getName()); rf.setDiskSynchronous(true); rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); rf.setScope(Scope.DISTRIBUTED_ACK); rf.create(REGION_NAME); } };
public void run() { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File dir = getDiskDirForVM(vm0); dir.mkdirs(); dsf.setDiskDirs(new File[] {dir}); dsf.setMaxOplogSize(1); dsf.setAutoCompact(false); dsf.setAllowForceCompaction(true); dsf.setCompactionThreshold(20); DiskStore ds = dsf.create(REGION_NAME); RegionFactory rf = new RegionFactory(); rf.setDiskStoreName(ds.getName()); rf.setDiskSynchronous(true); rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); rf.setScope(Scope.DISTRIBUTED_ACK); rf.create(REGION_NAME); } };
dsf.setDiskDirsAndSizes(dirs, new int[] { Integer.MAX_VALUE }); dsf.setAutoCompact(false); DirectoryHolder.SET_DIRECTORY_SIZE_IN_BYTES_FOR_TESTING_PURPOSES = true; try {
private LocalRegion createRegion(final VM vm0) { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File dir = getDiskDirForVM(vm0); dir.mkdirs(); dsf.setDiskDirs(new File[] {dir}); dsf.setMaxOplogSize(1); //Turn of automatic compaction dsf.setAllowForceCompaction(true); dsf.setAutoCompact(false); //The compaction javadocs seem to be wrong. This //is the amount of live data in the oplog dsf.setCompactionThreshold(40); DiskStore ds = dsf.create(REGION_NAME); RegionFactory rf = new RegionFactory(); rf.setDiskStoreName(ds.getName()); rf.setDiskSynchronous(true); rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); rf.setScope(Scope.DISTRIBUTED_ACK); LocalRegion region = (LocalRegion) rf.create(REGION_NAME); return region; }
File[] dirs1 = new File[] {new File("").getAbsoluteFile()}; DiskStore ds1 = dsf.setAllowForceCompaction(true) .setAutoCompact(true) .setCompactionThreshold(100) .setMaxOplogSize(2) File[] dirs2 = new File[] {new File("").getAbsoluteFile()}; DiskStore ds2 = dsf.setAllowForceCompaction(false) .setAutoCompact(false) .setCompactionThreshold(99) .setMaxOplogSize(1)
public void testRedefiningDefaultDiskStore() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setAutoCompact(!DiskStoreFactory.DEFAULT_AUTO_COMPACT); String name = "testMissingDrfFile"; assertEquals(null, cache.findDiskStore(DiskStoreFactory.DEFAULT_DISK_STORE_NAME)); DiskStore diskStore = dsf.create(DiskStoreFactory.DEFAULT_DISK_STORE_NAME); AttributesFactory af = new AttributesFactory(); af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); Region r = cache.createRegion("r", af.create()); r.put("key", "value"); DiskStore ds = ((LocalRegion)r).getDiskStore(); assertEquals(ds, cache.findDiskStore(DiskStoreFactory.DEFAULT_DISK_STORE_NAME)); assertEquals(DiskStoreFactory.DEFAULT_DISK_STORE_NAME, ds.getName()); assertEquals(!DiskStoreFactory.DEFAULT_AUTO_COMPACT, ds.getAutoCompact()); cache.close(); // if test passed clean up files removeFiles(diskStore); }
public void testRedefineOfDefaultDiskStore() throws CacheException { CacheCreation cache = new CacheCreation(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setAutoCompact(!DiskStoreFactory.DEFAULT_AUTO_COMPACT); DiskStore ds1 = dsf.create(DiskStoreFactory.DEFAULT_DISK_STORE_NAME); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setScope(Scope.DISTRIBUTED_ACK); attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); AttributesFactory factory = new AttributesFactory(attrs); RegionAttributes ra = factory.create(); RegionCreation root; try { root = (RegionCreation)cache.createRegion("root", ra); } catch (Exception ex) { fail("Unexpected exception", ex); } testXml(cache); Cache c = getCache(); assertNotNull(c); DiskStore ds2 = c.findDiskStore(DiskStoreFactory.DEFAULT_DISK_STORE_NAME); assertNotNull(ds2); assertEquals(ds1.getAutoCompact(), ds2.getAutoCompact()); }
DiskWriteAttributes dwa = getDiskWriteAttributes(); //cache.getLogger().info("DEBUG region " + getName() + " created with old APIs dwa=" + dwa/*, new RuntimeException("STACK")*/); dsf.setAutoCompact(dwa.isRollOplogs()); dsf.setMaxOplogSize(dwa.getMaxOplogSize()); dsf.setTimeInterval(dwa.getTimeInterval());
dsf.setDiskDirsAndSizes(getDiskDirs(), getDiskDirSizes()); DiskWriteAttributes dwa = getDiskWriteAttributes(); dsf.setAutoCompact(dwa.isRollOplogs()); dsf.setMaxOplogSize(dwa.getMaxOplogSize()); dsf.setTimeInterval(dwa.getTimeInterval());
public void testNonDefaults() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); String name = "testNonDefaults"; DiskStore ds = dsf .setAutoCompact(!DiskStoreFactory.DEFAULT_AUTO_COMPACT) .setCompactionThreshold(DiskStoreFactory.DEFAULT_COMPACTION_THRESHOLD/2) .setAllowForceCompaction(!DiskStoreFactory.DEFAULT_ALLOW_FORCE_COMPACTION) .setMaxOplogSize(DiskStoreFactory.DEFAULT_MAX_OPLOG_SIZE+1) .setTimeInterval(DiskStoreFactory.DEFAULT_TIME_INTERVAL+1) .setWriteBufferSize(DiskStoreFactory.DEFAULT_WRITE_BUFFER_SIZE+1) .setQueueSize(DiskStoreFactory.DEFAULT_QUEUE_SIZE+1) .create(name); assertEquals(!DiskStoreFactory.DEFAULT_AUTO_COMPACT, ds.getAutoCompact()); assertEquals(DiskStoreFactory.DEFAULT_COMPACTION_THRESHOLD/2, ds.getCompactionThreshold()); assertEquals(!DiskStoreFactory.DEFAULT_ALLOW_FORCE_COMPACTION, ds.getAllowForceCompaction()); assertEquals(DiskStoreFactory.DEFAULT_MAX_OPLOG_SIZE+1, ds.getMaxOplogSize()); assertEquals(DiskStoreFactory.DEFAULT_TIME_INTERVAL+1, ds.getTimeInterval()); assertEquals(DiskStoreFactory.DEFAULT_WRITE_BUFFER_SIZE+1, ds.getWriteBufferSize()); assertEquals(DiskStoreFactory.DEFAULT_QUEUE_SIZE+1, ds.getQueueSize()); }
dsf.setDiskDirs(diskDirs); dsf.setMaxOplogSize(1); dsf.setAutoCompact(false); dsf.setAllowForceCompaction(true); dsf.setCompactionThreshold(20);