/** * Create an <code>lru-heap-percentage</code> eviction controller, assigning * it to the enclosed <code>region-attributes</code> * @param atts */ private void startLRUHeapPercentage(Attributes atts) { final String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } // Store for later addition of ObjectSizer, if any stack.push(EvictionAttributes.createLRUHeapAttributes(null, action)); }
/** * Create an <code>lru-heap-percentage</code> eviction controller, assigning * it to the enclosed <code>region-attributes</code> * @param atts */ private void startLRUHeapPercentage(Attributes atts) { final String lruAction = atts.getValue(ACTION); EvictionAction action = EvictionAction.DEFAULT_EVICTION_ACTION; if (lruAction != null) { action = EvictionAction.parseAction(lruAction); } // Store for later addition of ObjectSizer, if any stack.push(EvictionAttributes.createLRUHeapAttributes(null, action)); }
public void run2() { System.setProperty(HeapLRUCapacityController.TOP_UP_HEAP_EVICTION_PERCENTAGE_PROPERTY, Float.toString(0)); setEvictionPercentage(heapPercentage); final Properties sp = System.getProperties(); final AttributesFactory factory = new AttributesFactory(); factory.setEnableOffHeapMemory(isOffHeap()); factory.setPartitionAttributes(new PartitionAttributesFactory() .setRedundantCopies(redundantCopies).create()); factory.setEvictionAttributes(EvictionAttributes .createLRUHeapAttributes()); final PartitionedRegion pr = (PartitionedRegion)createRootRegion(name, factory.create()); assertNotNull(pr); } };
public void testEvictionLRUHeapAttributes() throws Exception { final String rName = getUniqueName(); CacheCreation cache = new CacheCreation(); RegionAttributesCreation attrs = new RegionAttributesCreation(cache); attrs.setEvictionAttributes(EvictionAttributes .createLRUHeapAttributes(new EvictionObjectSizer(), EvictionAction.LOCAL_DESTROY)); cache.createRegion(rName, attrs); testXml(cache); }
public void createDistRegion() { final AttributesFactory factory = new AttributesFactory(); factory.setEnableOffHeapMemory(getOffHeapEnabled()); factory.setDataPolicy(DataPolicy.NORMAL); factory.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes( null, EvictionAction.LOCAL_DESTROY)); DistributedRegion distRegion = (DistributedRegion)cache.createRegion("DR1", factory.create()); assertNotNull(distRegion); }
public void run() { Cache cache = getCache(); ResourceManager manager = cache.getResourceManager(); manager.setCriticalHeapPercentage(95); manager.setEvictionHeapPercentage(90); AttributesFactory<Integer, TestDelta> attr = new AttributesFactory<Integer, TestDelta>(); attr.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes( new TestObjectSizer(), EvictionAction.OVERFLOW_TO_DISK)); attr.setDiskDirs(getMyDiskDirs()); attr.setDataPolicy(DataPolicy.REPLICATE); attr.setScope(Scope.DISTRIBUTED_ACK); attr.setDiskDirs(getMyDiskDirs()); Region region = cache.createRegion("region", attr.create()); } });
public void testLOCAL_PERSISTENT_OVERFLOW() throws CacheException { CacheCreation cache = new CacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("cpolocal", "LOCAL_PERSISTENT_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); Region r = c.getRegion("cpolocal"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); }
public void testLOCAL_OVERFLOW() throws CacheException, IOException { Cache c = new CacheFactory().create(); Region r1 = null; try { RegionFactory factory = c.createRegionFactory(LOCAL_OVERFLOW); r1 = factory.create(this.r1Name); RegionAttributes ra = r1.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } finally { cleanUpRegion(r1); } } public void testLOCAL_PERSISTENT_OVERFLOW() throws CacheException, IOException
public void testHeapLRUEviction() throws Exception { final String name = getUniqueName(); beginCacheXml(); AttributesFactory factory = new AttributesFactory(); factory.setScope(Scope.LOCAL); EvictionAttributes ev = EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK); factory.setEvictionAttributes(ev); // RegionAttributes atts = factory.create(); createRegion(name, factory.create()); finishCacheXml(getUniqueName(), getGemFireVersion()); Region r = getRootRegion().getSubregion(name); EvictionAttributes hlea = r.getAttributes().getEvictionAttributes(); assertEquals(EvictionAction.OVERFLOW_TO_DISK, hlea.getAction()); }
public void testLOCAL_OVERFLOW() throws CacheException { CacheCreation cache = new CacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("localoverflow", "LOCAL_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); Region r = c.getRegion("localoverflow"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testLOCAL_PERSISTENT_OVERFLOW() throws CacheException {
public void testREPLICATE_PERSISTENT_OVERFLOW() throws CacheException { CacheCreation cache = new CacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("preplicateoverflow", "REPLICATE_PERSISTENT_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); Region r = c.getRegion("preplicateoverflow"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy()); assertEquals(Scope.DISTRIBUTED_ACK, ra.getScope()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testREPLICATE_HEAP_LRU() throws CacheException, IOException
public void run() { Cache cache = getCache(); ResourceManager manager = cache.getResourceManager(); manager.setCriticalHeapPercentage(95); manager.setEvictionHeapPercentage(90); AttributesFactory<Integer, TestDelta> attr = new AttributesFactory<Integer, TestDelta>(); PartitionAttributesFactory<Integer, TestDelta> paf = new PartitionAttributesFactory<Integer, TestDelta>(); paf.setRedundantCopies(1); attr.setEvictionAttributes(EvictionAttributes.createLRUHeapAttributes( new TestObjectSizer(), EvictionAction.LOCAL_DESTROY)); PartitionAttributes<Integer, TestDelta> prAttr = paf.create(); attr.setPartitionAttributes(prAttr); attr.setDataPolicy(DataPolicy.PARTITION); attr.setSubscriptionAttributes(new SubscriptionAttributes(InterestPolicy.ALL)); Region<Integer, TestDelta> region = cache.createRegion("region", attr.create()); } });
public void testREPLICATE_OVERFLOW() throws CacheException { CacheCreation cache = new CacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("replicateoverflow", "REPLICATE_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); Region r = c.getRegion("replicateoverflow"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.REPLICATE, ra.getDataPolicy()); assertEquals(Scope.DISTRIBUTED_ACK, ra.getScope()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testREPLICATE_PERSISTENT_OVERFLOW() throws CacheException {
public void testLOCAL_HEAP_LRU() throws CacheException { CacheCreation cache = new CacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("locallru", "LOCAL_HEAP_LRU"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); Region r = c.getRegion("locallru"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testLOCAL_OVERFLOW() throws CacheException {
public void testPARTITION_REDUNDANT_HEAP_LRU() throws CacheException { CacheCreation cache = new CacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("rpartitionlru", "PARTITION_REDUNDANT_HEAP_LRU"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); Region r = c.getRegion("rpartitionlru"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PARTITION, ra.getDataPolicy()); assertNotNull(ra.getPartitionAttributes()); assertEquals(1, ra.getPartitionAttributes().getRedundantCopies()); assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); }
public void testPARTITION_HEAP_LRU() throws CacheException { CacheCreation cache = new CacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("partitionlru", "PARTITION_HEAP_LRU"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); Region r = c.getRegion("partitionlru"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PARTITION, ra.getDataPolicy()); assertNotNull(ra.getPartitionAttributes()); assertEquals(0, ra.getPartitionAttributes().getRedundantCopies()); assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testPARTITION_REDUNDANT_HEAP_LRU() throws CacheException {
public void testPARTITION_REDUNDANT_OVERFLOW() throws CacheException { CacheCreation cache = new CacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("rpartitionoverflow", "PARTITION_REDUNDANT_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); Region r = c.getRegion("rpartitionoverflow"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PARTITION, ra.getDataPolicy()); assertNotNull(ra.getPartitionAttributes()); assertEquals(1, ra.getPartitionAttributes().getRedundantCopies()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testPARTITION_PERSISTENT_OVERFLOW() throws CacheException {
public void testClientLOCAL_PERSISTENT_OVERFLOW() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("cpolocal", "LOCAL_PERSISTENT_OVERFLOW"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("cpolocal"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.PERSISTENT_REPLICATE, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(null, ra.getPoolName()); assertEquals(EvictionAttributes.createLRUHeapAttributes(null, EvictionAction.OVERFLOW_TO_DISK), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); }
public void testCACHING_PROXY_HEAP_LRU() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("cproxylru", "CACHING_PROXY_HEAP_LRU"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("cproxylru"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals("DEFAULT", ra.getPoolName()); assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testCACHING_PROXY_OVERFLOW() throws CacheException {
public void testClientLOCAL_HEAP_LRU() throws CacheException { ClientCacheCreation cache = new ClientCacheCreation(); RegionCreation root = (RegionCreation) cache.createRegion("locallru", "LOCAL_HEAP_LRU"); testXml(cache); GemFireCacheImpl c = (GemFireCacheImpl) getCache(); assertEquals(true, c.isClient()); Region r = c.getRegion("locallru"); assertNotNull(r); RegionAttributes ra = r.getAttributes(); assertEquals(DataPolicy.NORMAL, ra.getDataPolicy()); assertEquals(Scope.LOCAL, ra.getScope()); assertEquals(null, ra.getPoolName()); assertEquals(EvictionAttributes.createLRUHeapAttributes(), ra.getEvictionAttributes()); assertEquals(LocalRegion.DEFAULT_HEAPLRU_EVICTION_HEAP_PERCENTAGE, c.getResourceManager().getEvictionHeapPercentage()); } public void testClientLOCAL_OVERFLOW() throws CacheException {