public void run() { Cache cache = getCache(); RegionFactory rf = cache.createRegionFactory(RegionShortcut.REPLICATE); rf.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(count, EvictionAction.OVERFLOW_TO_DISK)); rf.create("region"); } });
private Region createOverflowRegion() { RegionFactory rf = new RegionFactory(); rf.setDiskStoreName("diskStore"); rf.setEvictionAttributes(EvictionAttributes.createLIFOEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)); rf.setDataPolicy(DataPolicy.NORMAL); Region region = rf.create("region"); return region; }
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); }
public void initNoEvictRegion() { Cache cache = CacheHelper.getCache(); RegionFactory factory = ((GemFireCacheImpl) cache).createRegionFactory(RegionShortcut.LOCAL); factory.setEnableOffHeapMemory(isOffHeap()); final EvictionAttributesImpl evictionAttrs = new EvictionAttributesImpl(); evictionAttrs.setAlgorithm(EvictionAlgorithm.NONE); factory.setEvictionAttributes(evictionAttrs); noEvictRegion = factory.create("noEvictRegion"); }
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); }
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 testSetEvictionAttributes() throws CacheException, IOException { Cache c = createCache(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(LOCAL); r1 = factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(77)).create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(EvictionAttributes.createLRUEntryAttributes(77), ra.getEvictionAttributes()); } finally { cleanUpRegion(r1); } }
public void run2() throws CacheException { getCache(); // create a cache Region pr = new RegionFactory() .setPartitionAttributes( new PartitionAttributesFactory() .setRedundantCopies(redundancy) .setLocalMaxMemory(localMaxMemory) .setTotalNumBuckets(numBuckets) .create()) .setEvictionAttributes( EvictionAttributes.createLRUEntryAttributes(Integer.MAX_VALUE, EvictionAction.LOCAL_DESTROY)) .create(prPrefix); int start = pr.size(); int end = start + localMaxMemory; getLogWriter().info("start: " + start + " end: " + end); for (int i=start; i<end; i++) { pr.put(new Integer(i), "createBucket"); // create bucket first to avoid denial due to large value .. 1 Mb pr.put(new Integer(i), new byte[valBytes]); // Then fill it } } };
.setEvictionAttributes(EvictionAttributes.createLIFOEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)) .setDiskStoreName(diskStore) .create(name); .setEvictionAttributes(EvictionAttributes.createLIFOEntryAttributes(5, EvictionAction.OVERFLOW_TO_DISK)) .setDiskStoreName(diskStore) .create(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(); RegionFactory rf = new RegionFactory(); rf.setEnableOffHeapMemory(isOffHeapEnabled()); rf.setDataPolicy(DataPolicy.PARTITION); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(1); paf.setTotalNumBuckets(5); rf.setPartitionAttributes(paf.create()); rf.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1)); rf.setConcurrencyChecksEnabled(false); rf.create(name); } });
/** * This test is in here just to test to make * sure that we don't get a suspect string * with an exception during cache closure. */ public void testOverflowCacheClose() { Cache cache = getCache(); RegionFactory rf = new RegionFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); rf.setPartitionAttributes(paf.create()); rf.setDataPolicy(DataPolicy.PARTITION); rf.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(50, EvictionAction.OVERFLOW_TO_DISK)); rf.setDiskDirs(getDiskDirs()); Region region = rf.create(PR_REGION_NAME); region.get(0); cache.getDistributedSystem().disconnect(); // cache.close(); }
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(); RegionFactory rf = new RegionFactory(); rf.setEnableOffHeapMemory(isOffHeapEnabled()); rf.setDataPolicy(DataPolicy.PARTITION); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(1); paf.setTotalNumBuckets(5); paf.setLocalMaxMemory(0); rf.setPartitionAttributes(paf.create()); rf.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1)); rf.setConcurrencyChecksEnabled(false); if(allContent) { // rf.initCacheListeners(new CacheListener [] { new MyListener()}); rf.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL)); } rf.create(name); } });
private void createPartitionedRegion(String regionName) { final Cache cache = getCache(); // Create the data region RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION); dataRegionFactory.setConcurrencyLevel(4); EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY); dataRegionFactory.setEvictionAttributes(ea); dataRegionFactory.setEnableAsyncConflation(true); FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par1", true); PartitionAttributes pa = new PartitionAttributesFactory() .setLocalMaxMemory(100) .setRecoveryDelay(2) .setTotalMaxMemory(200) .setRedundantCopies(1) .addFixedPartitionAttributes(fpa) .create(); dataRegionFactory.setPartitionAttributes(pa); dataRegionFactory.create(regionName); }
public void run() { final Cache cache = getCache(); RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION); dataRegionFactory.setConcurrencyLevel(4); EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY); dataRegionFactory.setEvictionAttributes(ea); dataRegionFactory.setEnableAsyncConflation(true); FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par1", true); PartitionAttributes pa = new PartitionAttributesFactory() .setLocalMaxMemory(100) .setRecoveryDelay(2) .setTotalMaxMemory(200) .setRedundantCopies(1) .addFixedPartitionAttributes(fpa) .create(); dataRegionFactory.setPartitionAttributes(pa); dataRegionFactory.create(PR1); createLocalRegion(LOCALREGIONONMANAGER); } });
.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)) .setDiskStoreName("store") .setCacheLoader(new TestCacheLoader()) .create("overflow_replicate"); cache.createRegionFactory(RegionShortcut.PARTITION_OVERFLOW) .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)) .setDiskStoreName("store") .setCacheLoader(new TestCacheLoader())
public void run() { getSystem(server1Props); final Cache cache = getCache(); RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION); dataRegionFactory.setConcurrencyLevel(4); EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY); dataRegionFactory.setEvictionAttributes(ea); dataRegionFactory.setEnableAsyncConflation(true); FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par2", 4); PartitionAttributes pa = new PartitionAttributesFactory() .setLocalMaxMemory(150) .setRecoveryDelay(4) .setTotalMaxMemory(200) .setRedundantCopies(1) .addFixedPartitionAttributes(fpa) .create(); dataRegionFactory.setPartitionAttributes(pa); dataRegionFactory.create(PR1); createRegionsWithSubRegions(); } });
private void createPartitionedRegion(String regionName) { final Cache cache = getCache(); // Create the data region RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION); dataRegionFactory.setConcurrencyLevel(4); EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY); dataRegionFactory.setEvictionAttributes(ea); dataRegionFactory.setEnableAsyncConflation(true); FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par1", true); PartitionAttributes pa = new PartitionAttributesFactory() .setLocalMaxMemory(100) .setRecoveryDelay(2) .setTotalMaxMemory(200) .setRedundantCopies(1) .addFixedPartitionAttributes(fpa) .create(); dataRegionFactory.setPartitionAttributes(pa); dataRegionFactory.addCacheListener(new CacheListener1()); dataRegionFactory.addCacheListener(new CacheListener2()); dataRegionFactory.create(regionName); }
final EvictionAttributesImpl evictionAttrs = new EvictionAttributesImpl(); evictionAttrs.setAlgorithm(EvictionAlgorithm.NONE); regionFactory.setEvictionAttributes(evictionAttrs); final Region region = regionFactory.create("testDefaultThresholdsRegion"); TestMemoryThresholdListener listener = new TestMemoryThresholdListener();