use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testEvictionLRUEntryAttributes.
@Test
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);
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testDefaultRecoveryDelayAttributes.
/**
* Tests that a region created with a named attributes set programmatically for recovery-delay has
* the correct attributes.
*/
@Test
public void testDefaultRecoveryDelayAttributes() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1);
paf.setTotalMaxMemory(500);
paf.setLocalMaxMemory(100);
attrs.setPartitionAttributes(paf.create());
cache.createRegion("parRoot", attrs);
Region r = cache.getRegion("parRoot");
assertEquals(r.getAttributes().getPartitionAttributes().getRedundantCopies(), 1);
assertEquals(r.getAttributes().getPartitionAttributes().getLocalMaxMemory(), 100);
assertEquals(r.getAttributes().getPartitionAttributes().getTotalMaxMemory(), 500);
assertEquals(-1, r.getAttributes().getPartitionAttributes().getRecoveryDelay());
assertEquals(0, r.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region region = c.getRegion("parRoot");
assertNotNull(region);
RegionAttributes regionAttrs = region.getAttributes();
PartitionAttributes pa = regionAttrs.getPartitionAttributes();
assertEquals(pa.getRedundantCopies(), 1);
assertEquals(pa.getLocalMaxMemory(), 100);
assertEquals(pa.getTotalMaxMemory(), 500);
assertEquals(-1, r.getAttributes().getPartitionAttributes().getRecoveryDelay());
assertEquals(0, r.getAttributes().getPartitionAttributes().getStartupRecoveryDelay());
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testFixedPartitioning_colocation_WithAttributes.
@Test
public void testFixedPartitioning_colocation_WithAttributes() throws Exception {
CacheCreation cache = new CacheCreation();
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition("Q1");
FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition("Q2", true);
FixedPartitionAttributes fpa3 = FixedPartitionAttributes.createFixedPartition("Q3", 3);
FixedPartitionAttributes fpa4 = FixedPartitionAttributes.createFixedPartition("Q4", false, 3);
List<FixedPartitionAttributes> fpattrsList = new ArrayList<FixedPartitionAttributes>();
fpattrsList.add(fpa1);
fpattrsList.add(fpa2);
fpattrsList.add(fpa3);
fpattrsList.add(fpa4);
QuarterPartitionResolver resolver = new QuarterPartitionResolver();
Region customerRegion = null;
Region orderRegion = null;
{
RegionAttributesCreation attrs = new RegionAttributesCreation();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1).setPartitionResolver(resolver).addFixedPartitionAttributes(fpa1).addFixedPartitionAttributes(fpa2).addFixedPartitionAttributes(fpa3).addFixedPartitionAttributes(fpa4);
attrs.setPartitionAttributes(paf.create());
cache.createRegion("Customer", attrs);
}
customerRegion = cache.getRegion("Customer");
validateAttributes(customerRegion, fpattrsList, resolver, false);
try {
RegionAttributesCreation attrs = new RegionAttributesCreation();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1).setPartitionResolver(resolver).addFixedPartitionAttributes(fpa1).addFixedPartitionAttributes(fpa2).addFixedPartitionAttributes(fpa3).addFixedPartitionAttributes(fpa4).setColocatedWith("Customer");
attrs.setPartitionAttributes(paf.create());
cache.createRegion("Order", attrs);
orderRegion = cache.getRegion("Order");
validateAttributes(orderRegion, fpattrsList, resolver, true);
} catch (Exception illegal) {
// TODO: clean this expected exception up
if (!((illegal instanceof IllegalStateException) && (illegal.getMessage().contains("can not be specified in PartitionAttributesFactory")))) {
Assert.fail("Expected IllegalStateException ", illegal);
}
RegionAttributesCreation attrs = new RegionAttributesCreation();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1).setPartitionResolver(resolver).setColocatedWith("Customer");
attrs.setPartitionAttributes(paf.create());
cache.createRegion("Order", attrs);
orderRegion = cache.getRegion("Order");
validateAttributes(orderRegion, fpattrsList, resolver, true);
}
testXml(cache);
Cache c = getCache();
assertNotNull(c);
customerRegion = c.getRegion("Customer");
assertNotNull(customerRegion);
validateAttributes(customerRegion, fpattrsList, resolver, false);
orderRegion = c.getRegion("Order");
assertNotNull(orderRegion);
validateAttributes(orderRegion, fpattrsList, resolver, true);
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testRegisteringNamedRegionAttributes.
/**
* Tests that named region attributes are registered when the cache is created.
*/
@Test
public void testRegisteringNamedRegionAttributes() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs;
String id1 = "id1";
attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setMirrorType(MirrorType.KEYS);
cache.setRegionAttributes(id1, attrs);
String id2 = "id2";
attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_NO_ACK);
attrs.setMirrorType(MirrorType.KEYS_VALUES);
attrs.setConcurrencyLevel(15);
cache.setRegionAttributes(id2, attrs);
String id3 = "id3";
attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.LOCAL);
attrs.setValueConstraint(Integer.class);
cache.setRegionAttributes(id3, attrs);
testXml(cache);
}
use of org.apache.geode.internal.cache.xmlcache.RegionAttributesCreation in project geode by apache.
the class CacheXml66DUnitTest method testDiskStoreFactory.
@Test
public void testDiskStoreFactory() throws Exception {
CacheCreation cache = new CacheCreation();
DiskStoreFactory dsf = cache.createDiskStoreFactory();
dsf.setDiskDirs(new File[] { new File("non_exist_dir") });
DiskStore ds1 = dsf.create(getUniqueName());
dsf.setDiskDirs(new File[] { new File(".") });
ds1 = dsf.create(getUniqueName());
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setScope(Scope.DISTRIBUTED_ACK);
attrs.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
attrs.setDiskStoreName(getUniqueName());
AttributesFactory factory = new AttributesFactory(attrs);
RegionAttributes ra = factory.create();
RegionCreation root = (RegionCreation) cache.createRegion("root", ra);
factory = new AttributesFactory();
factory.setDiskStoreName(getUniqueName());
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
ra = factory.create();
RegionCreation root2 = (RegionCreation) cache.createRegion("root2", ra);
factory = new AttributesFactory();
factory.setDiskStoreName(null);
factory.setScope(Scope.DISTRIBUTED_ACK);
factory.setDataPolicy(DataPolicy.PERSISTENT_REPLICATE);
ra = factory.create();
RegionCreation root3 = (RegionCreation) cache.createRegion("root3", ra);
testXml(cache);
}
Aggregations