public void run() { Cache cache = getCache(); RegionFactory rf = cache.createRegionFactory(RegionShortcut.REPLICATE); rf.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(count, EvictionAction.OVERFLOW_TO_DISK)); rf.create("region"); } });
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 testSetEvictionAttributes() throws CacheException, IOException { ClientCache c = new ClientCacheFactory().create(); Region r1 = null; try { ClientRegionFactory factory = c.createClientRegionFactory(CACHING_PROXY); r1 = factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(77)).create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(EvictionAttributes.createLRUEntryAttributes(77), ra.getEvictionAttributes()); } finally { cleanUpRegion(r1); } }
/** * Make sure a disk region and proxy play nice. */ public void testDiskProxy() throws Exception { AttributesFactory af = new AttributesFactory(); af.setDataPolicy(DataPolicy.EMPTY); af.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)); try { af.create(); fail ("expected IllegalStateException"); } catch (IllegalStateException expected) { } } /**
@Override protected RegionAttributes getRegionAttributes() { AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.DISTRIBUTED_ACK); factory.setDataPolicy(DataPolicy.REPLICATE); factory.setConcurrencyChecksEnabled(true); factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes( 5, EvictionAction.OVERFLOW_TO_DISK)); return factory.create(); }
public void testEvictionLRUEntryAttributes() throws Exception { final String rName = getUniqueName(); CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(80, EvictionAction.LOCAL_DESTROY)); cache.createRegion(rName, attrs); testXml(cache); }
@Override protected RegionAttributes getRegionAttributes(String type) { RegionAttributes ra = getCache().getRegionAttributes(type); if (ra == null) { throw new IllegalStateException("The region shortcut " + type + " has been removed."); } AttributesFactory factory = new AttributesFactory(ra); factory.setConcurrencyChecksEnabled(true); if(!ra.getDataPolicy().isEmpty()) { factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes( 5, EvictionAction.OVERFLOW_TO_DISK)); } return factory.create(); } }
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()); } };
public Object call() throws Exception { Cache cache = getCache(); AttributesFactory attr = new AttributesFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); PartitionAttributes prAttr = paf.create(); attr.setPartitionAttributes(prAttr); attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)); Region region = cache.createRegion("region1", attr.create()); return null; } };
private static void createExampleForLRUCapCon() { // DOCS: Begin docs snippet for entry evictor AttributesFactory factory = new AttributesFactory(); EvictionAttributes evAttr = EvictionAttributes.createLRUEntryAttributes(100000); factory.setEvictionAttributes(evAttr); RegionAttributes regAttr = factory.createRegionAttributes(); try { rootRegion.createSubregion("LRU_region", regAttr); } catch (CacheException e) { // handle CacheException here } // DOCS: End docs snippet for entry evictor Region aRegion = rootRegion.getSubregion("LRU_region"); hydra.Log.getLogWriter().info("Created new region " + aRegion.getFullPath() + " with region attributes " + regAttr); }
public Object call() throws Exception { AttributesFactory af = new AttributesFactory(); af.setDataPolicy(DataPolicy.HDFS_PARTITION); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setTotalNumBuckets(totalnumOfBuckets); paf.setRedundantCopies(1); //make this member an accessor. paf.setLocalMaxMemory(0); af.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(maximumEntries, EvictionAction.LOCAL_DESTROY)); af.setPartitionAttributes(paf.create()); Region r = createRootRegion(uniqueName, af.create()); assertTrue(!((PartitionedRegion) r).isDataStore()); return null; } };
@Override public void run2() { final AttributesFactory factory = new AttributesFactory(); factory.setPartitionAttributes(new PartitionAttributesFactory() .setRedundantCopies(redundantCopies).create()); factory.setEvictionAttributes(EvictionAttributes .createLRUEntryAttributes(maxEntriesForVm1, EvictionAction.LOCAL_DESTROY)); final PartitionedRegion pr = (PartitionedRegion)createRootRegion(name, factory.create()); assertNotNull(pr); } };
public void run() { Cache cache = getCache(); AttributesFactory<Integer, TestDelta> attr = new AttributesFactory<Integer, TestDelta>(); PartitionAttributesFactory<Integer, TestDelta> paf = new PartitionAttributesFactory<Integer, TestDelta>(); paf.setLocalMaxMemory(0); PartitionAttributes<Integer, TestDelta> prAttr = paf.create(); attr.setPartitionAttributes(prAttr); attr.setDataPolicy(DataPolicy.PARTITION); attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)); Region<Integer, TestDelta> region = cache.createRegion("region1", attr.create()); } };
public void run() { Cache cache = getCache(); AttributesFactory attr = new AttributesFactory(); PartitionAttributesFactory paf = new PartitionAttributesFactory(); paf.setRedundantCopies(1); paf.setRecoveryDelay(-1); paf.setStartupRecoveryDelay(-1); PartitionAttributes prAttr = paf.create(); attr.setPartitionAttributes(prAttr); attr.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(1, EvictionAction.OVERFLOW_TO_DISK)); cache.createRegion("region1", attr.create()); } };
public void run() { final AttributesFactory factory = new AttributesFactory(); factory.setEnableOffHeapMemory(isOffHeap()); factory.setPartitionAttributes(new PartitionAttributesFactory() .setRedundantCopies(redundantCopies).create()); final EvictionAttributes ea = EvictionAttributes.createLRUEntryAttributes(firstEvictionAttributes.getMaximum()+10, firstEvictionAttributes.getAction()); factory.setEvictionAttributes(ea); final Region pr = createRootRegion(name, factory.create()); assertNotNull(pr); } };
public void run2() { final AttributesFactory factory = new AttributesFactory(); factory.setEnableOffHeapMemory(isOffHeap()); factory.setPartitionAttributes(new PartitionAttributesFactory() .setRedundantCopies(redundantCopies).setTotalNumBuckets(maxBuckets) .create()); factory .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes( maxEntries, EvictionAction.LOCAL_DESTROY)); final PartitionedRegion pr = (PartitionedRegion)createRootRegion(name, factory.create()); assertNotNull(pr); } };
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); } });
@Override public Object call() throws Exception { ClientCacheFactory cf = new ClientCacheFactory() .set("log-level", getDUnitLogLevel()) .setPdxSerializer(new MyPdxSerializer()) .addPoolServer(getServerHostName(host), port) .setPoolSubscriptionEnabled(true) .setPoolPRSingleHopEnabled(false); ClientCache cache = getClientCache(cf); Region r = cache.createClientRegionFactory(ClientRegionShortcut.CACHING_PROXY_HEAP_LRU) .setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(5)) .create("clienttest"); return null; } };
/** * Tests that a capacity controller with LOCAL_DESTROY eviction action * cannot be installed into a region */ public void testCCMirrored() throws Exception { final String name = this.getUniqueName(); AttributesFactory factory = new AttributesFactory(); factory.setEvictionAttributes(EvictionAttributes.createLRUEntryAttributes(10)); factory.setDataPolicy(DataPolicy.REPLICATE); Region r = createRegion(name, factory.create()); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PRELOADED, ra.getDataPolicy()); assertEquals(new SubscriptionAttributes(InterestPolicy.ALL), ra.getSubscriptionAttributes()); r.destroyRegion(); }