public void setUp() throws Exception { store = new File("store-" + Math.abs(new Random().nextInt())); store.mkdir(); snaps = new File("snapshots-" + Math.abs(new Random().nextInt())); snaps.mkdir(); rgen = new RegionGenerator(); CacheFactory cf = new CacheFactory() .set("mcast-port", "0") .set("log-level", "error"); cache = cf.create(); ds = cache.createDiskStoreFactory() .setMaxOplogSize(1) .setDiskDirs(new File[] { store }) .create("snapshotTest"); }
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; }
/** * test Illegal max oplog size */ public void testMaxOplogSize() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); try { dsf.setMaxOplogSize(-1); fail("expected IllegalArgumentException"); } catch (IllegalArgumentException e) { } dsf.setMaxOplogSize(1); assertEquals(1, dsf.create("test").getMaxOplogSize()); }
private DiskStoreImpl createDiskStore() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setDiskDirs(diskDirs); dsf.setMaxOplogSize(1); String name = "diskStore"; DiskStoreImpl ds = (DiskStoreImpl) dsf.create(name); return ds; }
/** * 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 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 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); } });
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 cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File dir = getDiskDirForVM(vm); dir.mkdirs(); dsf.setDiskDirs(new File[] {dir}); dsf.setMaxOplogSize(1); 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); } };
public void run() { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File dir = getDiskDirForVM(vm); dir.mkdirs(); dsf.setDiskDirs(new File[] {dir}); dsf.setMaxOplogSize(1); DiskStore ds = dsf.create(REGION_NAME); RegionFactory rf = new RegionFactory(); rf.setDiskStoreName(ds.getName()); rf.setDiskSynchronous(diskSynchronous); 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.setQueueSize(100); dsf.setTimeInterval(1000); DiskStore ds = dsf.create(REGION_NAME); RegionFactory rf = new RegionFactory(); rf.setDiskStoreName(ds.getName()); rf.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); rf.setScope(Scope.DISTRIBUTED_ACK); rf.setDiskSynchronous(false); rf.create(REGION_NAME); } };
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); } };
private void setUpGem(File diskdir) { CacheFactory cf = new CacheFactory() .set("mcast-port", "0"); cache = cf.create(); ds = cache.createDiskStoreFactory() .setDiskDirs(new File[] { diskdir }) .setMaxOplogSize(SIZE / 16 / 1024 / 1024) .create("store1"); region = cache .<Long, Object>createRegionFactory(RegionShortcut.LOCAL_PERSISTENT) .setDiskStoreName(ds.getName()) .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)) .create("test"); }
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); } };
/** * @param persist added this param to fix bug 37439 */ protected Region createParentRegion(String name, boolean persist) throws CacheException { final AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.REPLICATE); File d = new File("DynamicRegionData" + ProcessMgr.getProcessId()); factory.setDiskStoreName(getCache().createDiskStoreFactory() .setDiskDirs(new File[] {d}) .setMaxOplogSize(OPLOG_SIZE) .create("DynamicRegionDUnitTest") .getName()); if (persist) { factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); } factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(100, EvictionAction.OVERFLOW_TO_DISK)); final Region r = createRootRegion(name, factory.create()); return r; }
public void run() { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setDiskDirs(getDiskDirs(getUniqueName())); dsf.setMaxOplogSize(1); DiskStore ds = dsf.create(getUniqueName()); RegionFactory rf = new RegionFactory(); rf.setDiskStoreName(ds.getName()); rf.setDiskSynchronous(true); rf.setDataPolicy(DataPolicy.REPLICATE); rf.setEvictionAttributes(EvictionAttributes.createLIFOEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)); rf.create("region3"); } };
public void run() { Cache cache = getCache(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setDiskDirs(getDiskDirs(getUniqueName())); dsf.setMaxOplogSize(1); DiskStore ds = dsf.create(getUniqueName()); RegionFactory rf = new RegionFactory(); rf.setDiskStoreName(ds.getName()); rf.setDiskSynchronous(true); rf.setDataPolicy(getDataPolicy()); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(0); rf.setPartitionAttributes(paf.create()); rf.create("region1"); dsf = cache.createDiskStoreFactory(); dsf.setDiskDirs(getDiskDirs(getUniqueName()+2)); dsf.setMaxOplogSize(1); ds = dsf.create(getUniqueName()+2); rf.setDiskStoreName(getUniqueName()+2); rf.create("region2"); } };
public Object call() throws Exception { //Make sure the type registry is persistent CacheFactory cf = new CacheFactory(); cf.setPdxPersistent(true); cf.setPdxDiskStore("store1"); Cache cache = getCache(cf); cache.createDiskStoreFactory() .setMaxOplogSize(1) .setDiskDirs(getDiskDirs()) .create("store1"); AttributesFactory af = new AttributesFactory(); af.setScope(Scope.DISTRIBUTED_ACK); af.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); af.setDiskStoreName("store1"); createRootRegion("testSimplePdx", af.create()); return null; } };
@Override public Object call() throws Exception { CacheFactory cf = new CacheFactory() .setPdxSerializer(new MyPdxSerializer()) .setPdxPersistent(true); Cache cache = getCache(cf); DiskStore ds = cache.createDiskStoreFactory() .setMaxOplogSize(1) .setDiskDirs(getDiskDirs()) .create("snapshotTest"); RegionGenerator rgen = new RegionGenerator(); for (final RegionType rt : RegionType.values()) { for (final SerializationType st : SerializationType.values()) { rgen.createRegion(cache, ds.getName(), rt, "test-" + rt.name() + "-" + st.name()); } } return null; } };