public void testForceRoll() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); String name = "testForceRoll"; DiskStore ds = dsf.create(name); ds.forceRoll(); }
public void testFlush() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); String name = "testFlush"; DiskStore ds = dsf.create(name); ds.flush(); }
protected static void setDiskStoreForGateway(Cache cache, String gatewayId, GatewayQueueAttributes queueAttributes) { // user is responsible to specify different diskstore or overflow dir // for gateways running on the same host or file system File overflowDirectory = new File(gatewayId+"_disk_"+System.currentTimeMillis()); overflowDirectory.mkdir(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File[] dirs1 = new File[] {overflowDirectory}; queueAttributes.setDiskStoreName(dsf.setDiskDirs(dirs1).create(gatewayId).getName()); }
protected DiskStore createDiskStore(Cache cache, String diskStoreName, String dirName) { // maxOplogSize==1m File dir = new File(dirName); dir.mkdirs(); DiskStore ds = cache.findDiskStore(diskStoreName); if(ds == null) { ds = cache.createDiskStoreFactory() .setDiskDirs(new File[] {dir}).setMaxOplogSize(maxOplogSize).create(diskStoreName); } return ds; }
public void testForceCompaction() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setAllowForceCompaction(true); String name = "testForceCompaction"; DiskStore ds = dsf.create(name); assertEquals(false, ds.forceCompaction()); }
public void run() { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setAllowForceCompaction(true); String name = "testForceCompaction_" + vm.getPid(); DiskStore ds = dsf.create(name); ManagementService service = getManagementService(); DiskStoreMXBean bean = service.getLocalDiskStoreMBean(name); assertNotNull(bean); assertEquals(false, bean.forceCompaction()); } };
public void testTimeInterval() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); try { dsf.setTimeInterval(-1); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } dsf.setTimeInterval(1); assertEquals(dsf.create("test").getTimeInterval(), 1); }
public void testDestroyWithClosedRegion() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); String name = "testDestroy"; DiskStore ds = dsf.create(name); Region region = cache.createRegionFactory(RegionShortcut.LOCAL_PERSISTENT) .setDiskStoreName("testDestroy") .create("region"); region.close(); //This should now work ds.destroy(); }
public void testQueueSize() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); try { dsf.setQueueSize(-1); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } dsf.setQueueSize(1); assertEquals(1, dsf.create("test").getQueueSize(), 1); }
public void run() { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); String name = "testForceRoll_" + vm.getPid(); DiskStore ds = dsf.create(name); ManagementService service = getManagementService(); DiskStoreMXBean bean = service.getLocalDiskStoreMBean(name); assertNotNull(bean); bean.forceRoll(); } };
protected RegionAttributes getDiskRegionAttributes() { AttributesFactory factory = new AttributesFactory(getRegionAttributes()); File[] diskDirs = new File[1]; diskDirs[0] = new File("diskRegionDirs/" + ProcessMgr.getProcessId()); diskDirs[0].mkdirs(); factory.setDiskStoreName(getCache().createDiskStoreFactory() .setDiskDirs(diskDirs) .setTimeInterval(1000) .setQueueSize(0) .create("TXRestrictionsTest") .getName()); factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); return factory.create(); }
public void run2() throws CacheException { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_NO_ACK); factory.setEvictionAttributes(EvictionAttributes .createLRUMemoryAttributes(2, null, EvictionAction.OVERFLOW_TO_DISK)); File d = new File("DiskRegions" + ProcessMgr.getProcessId()); d.mkdirs(); DiskStoreFactory dsf = getCache().createDiskStoreFactory(); dsf.setDiskDirs(new File[]{d}); DiskStore ds = dsf.create(name); factory.setDiskStoreName(ds.getName()); createRegion(name, factory.create()); } };
public void run() { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); String name = "testFlush_" + vm.getPid(); DiskStore ds = dsf.create(name); ManagementService service = getManagementService(); DiskStoreMXBean bean = service.getLocalDiskStoreMBean(name); assertNotNull(bean); bean.flush(); } };
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()); }
private Region createRegion(String regionName) { if(cache.findDiskStore("store") == null) { cache.createDiskStoreFactory() .setMaxOplogSize(1) .setDiskDirs(dirs) .create("store"); } Region region = cache.createRegionFactory() .setDiskStoreName("store") .setDataPolicy(DataPolicy.PERSISTENT_REPLICATE).create(regionName); return region; }
public void testAllowForceCompaction() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setAllowForceCompaction(true); assertEquals(true, dsf.create("test").getAllowForceCompaction()); dsf.setAllowForceCompaction(false); assertEquals(false, dsf.create("test2").getAllowForceCompaction()); }
@Override public void run() { Cache cache = getCache(new CacheFactory().set("log-level", getDUnitLogLevel())); cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create("fooStore"); cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create("barStore"); getRegionFactory(cache).setDiskStoreName("fooStore").create("fooRegion"); getRegionFactory(cache).setDiskStoreName("barStore").create("barRegion"); }
/** * Creates a region and assigns a compressor. * @param name the region name. * @param dataPolicy the type of peer. * @param compressor a compressor. * @return the newly created region. */ private Region<String,String> createRegion(String name,DataPolicy dataPolicy,Compressor compressor,String diskStoreName) { getCache().createDiskStoreFactory().create(diskStoreName); return getCache().<String,String>createRegionFactory().setDataPolicy(dataPolicy).setDiskStoreName(diskStoreName).setCloningEnabled(true).setCompressor(compressor).create(name); }
public void reset() { CacheFactory cf = new CacheFactory() .set("mcast-port", "0") .set("log-level", "error") .setPdxSerializer(new MyPdxSerializer()) .setPdxPersistent(true); cache = cf.create(); ds = cache.createDiskStoreFactory().setMaxOplogSize(1).create("snapshotTest"); }
public void run() { cache = getCache(); DiskStore ds = cache.findDiskStore(diskStoreName); if(ds == null) { ds = cache.createDiskStoreFactory() .setDiskDirs(getDiskDirs()).create(diskStoreName); } AttributesFactory af = new AttributesFactory(); af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); af.setDiskStoreName(diskStoreName); cache.createRegion(regionName, af.create()); } };