public void run() { diskStore1Dir1.mkdirs(); diskStore2Dir1.mkdirs(); Properties localProps = new Properties(); localProps.setProperty(DistributionConfig.NAME_NAME, vm1Name); localProps.setProperty(DistributionConfig.GROUPS_NAME, "Group1,Group2"); getSystem(localProps); Cache cache = getCache(); DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(); diskStoreFactory.setDiskDirs(new File[] { diskStore1Dir1 }); diskStoreFactory.create(diskStore1Name); diskStoreFactory.setDiskDirs(new File[] { diskStore2Dir1 }); diskStoreFactory.create(diskStore2Name); } });
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()); }
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; }
private DiskStoreImpl createDiskStore() { DiskStoreFactory dsf = cache.createDiskStoreFactory(); dsf.setDiskDirs(diskDirs); dsf.setMaxOplogSize(1); String name = "diskStore"; DiskStoreImpl ds = (DiskStoreImpl) dsf.create(name); return ds; }
public static void createCache_PDX(Integer locPort){ WANTestBase test = new WANTestBase(testName); Properties props = new Properties(); props.setProperty(DistributionConfig.MCAST_PORT_NAME, "0"); props.setProperty(DistributionConfig.LOCATORS_NAME, "localhost[" + locPort + "]"); InternalDistributedSystem ds = test.getSystem(props); CacheConfig cacheConfig = new CacheConfig(); cacheConfig.setPdxPersistent(true); cacheConfig.setPdxDiskStore("PDX_TEST"); cache = GemFireCacheImpl.create(ds, false, cacheConfig); File persistentDirectory = new File("PDX_disk_"+System.currentTimeMillis()+"_" + VM.getCurrentVMNum()); persistentDirectory.mkdir(); DiskStoreFactory dsf = cache.createDiskStoreFactory(); File [] dirs1 = new File[] {persistentDirectory}; dsf.setDiskDirs(dirs1).create("PDX_TEST"); }
public void run() { final Cache cache = getCache(); DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(); diskStoreFactory.setDiskDirs(new File[] { diskStoreDir }); final DiskStore diskStore1 = diskStoreFactory.create(diskStoreName1); assertNotNull(diskStore1); RegionFactory regionFactory = cache.createRegionFactory(RegionShortcut.REPLICATE_PERSISTENT); regionFactory.setDiskStoreName(diskStoreName1); regionFactory.setDiskSynchronous(true); regionFactory.create(region1); regionFactory.setCompressor(SnappyCompressor.getDefaultInstance()); regionFactory.create(region2); cache.close(); assertTrue(new File(diskStoreDir, "BACKUP" + diskStoreName1 + ".if").exists()); } });
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()); } };
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 run2() throws CacheException { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setEarlyAck(false); factory.setEvictionAttributes(EvictionAttributes .createLRUEntryAttributes(100, 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()); } };
protected RegionAttributes getRegionAttributes() { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_NO_ACK); 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("DiskDistributedNoAckAsyncRegionTest") .getName()); factory.setDiskSynchronous(false); factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); return factory.create(); }
protected RegionAttributes getRegionAttributes() { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_NO_ACK); File[] diskDirs = new File[1]; diskDirs[0] = new File("diskRegionDirs/" + ProcessMgr.getProcessId()); diskDirs[0].mkdirs(); factory.setDiskStoreName(getCache().createDiskStoreFactory() .setDiskDirs(diskDirs) .create("DiskDistributedNoAckSyncOverflowRegionTest") .getName()); factory.setEvictionAttributes(EvictionAttributes .createLRUMemoryAttributes(1, null, EvictionAction.OVERFLOW_TO_DISK)); factory.setDiskSynchronous(true); factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); return factory.create(); }
@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"); }
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 = 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()); } };
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"); }
@Override public void run() { getSystem(peer.getDistributedSystemConfiguration()); final Cache cache = getCache(); DiskStore diskStore = cache.findDiskStore(diskStoreName); if (diskStore == null) { final DiskStoreFactory diskStoreFactory = cache.createDiskStoreFactory(); diskStoreFactory.setDiskDirs(getDiskDirs()); diskStore = diskStoreFactory.create(diskStoreName); } final RegionFactory regionFactory = cache.createRegionFactory(); regionFactory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE); regionFactory.setDiskStoreName(diskStore.getName()); regionFactory.setScope(Scope.DISTRIBUTED_NO_ACK); regionFactory.create(regionName); } });
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(); DiskStore ds1 = dsf.setDiskDirs(getDiskDirs()) .create("ds1"); AttributesFactory attr = new AttributesFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(1); paf.setRecoveryDelay(-1); paf.setStartupRecoveryDelay(-1); paf.setLocalMaxMemory(0); PartitionAttributes prAttr = paf.create(); attr.setPartitionAttributes(prAttr); cache.createRegion("region1", attr.create()); } };