use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class TXJUnitTest method testPutAllSupported.
/**
* make sure that we throw an UnsupportedOperationInTransactionException
*
* @throws Exception
*/
@Test
public void testPutAllSupported() throws Exception {
TXManagerImpl ctm = this.cache.getTxManager();
AttributesFactory af = new AttributesFactory();
Region r = this.cache.createRegion("dRegion", af.create());
PartitionAttributes pa = new PartitionAttributesFactory().setRedundantCopies(0).setTotalNumBuckets(1).create();
af.setPartitionAttributes(pa);
Region pr = this.cache.createRegion("prRegion", af.create());
Map map = new HashMap();
map.put("stuff", "junk");
map.put("stuff2", "junk2");
ctm.begin();
pr.putAll(map);
r.putAll(map);
TXStateProxy tx = ctm.internalSuspend();
assertTrue(!pr.containsKey("stuff"));
assertTrue(!r.containsKey("stuff"));
ctm.internalResume(tx);
ctm.commit();
assertTrue(pr.containsKey("stuff"));
assertTrue(r.containsKey("stuff"));
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class TXJUnitTest method testDestroyRegionNotSupported.
/**
* make sure that we throw an UnsupportedOperationInTransactionException
*
* @throws Exception
*/
@Test
public void testDestroyRegionNotSupported() throws Exception {
CacheTransactionManager ctm = this.cache.getCacheTransactionManager();
AttributesFactory af = new AttributesFactory();
Region r = this.cache.createRegion("dRegion", af.create());
PartitionAttributes pa = new PartitionAttributesFactory().setRedundantCopies(0).setTotalNumBuckets(1).create();
af.setPartitionAttributes(pa);
Region pr = this.cache.createRegion("prRegion", af.create());
List list = new ArrayList();
list.add("stuff");
list.add("stuff2");
ctm.begin();
try {
pr.destroyRegion();
fail("Should have thrown UnsupportedOperationInTransactionException during destroyRegion");
} catch (UnsupportedOperationInTransactionException ee) {
// expected
}
try {
pr.localDestroyRegion();
fail("Should have thrown UnsupportedOperationInTransactionException during localDestroyRegion");
} catch (UnsupportedOperationInTransactionException ee) {
// expected
}
try {
r.destroyRegion();
fail("Should have thrown UnsupportedOperationInTransactionException during destroyRegion");
} catch (UnsupportedOperationInTransactionException ee) {
// expected
}
try {
r.localDestroyRegion();
fail("Should have thrown UnsupportedOperationInTransactionException during localDestroyRegion");
} catch (UnsupportedOperationInTransactionException ee) {
// expected
}
assertTrue(!pr.isDestroyed());
assertTrue(!r.isDestroyed());
ctm.commit();
// now we aren't in tx so these shouldn't throw
pr.destroyRegion();
r.destroyRegion();
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class TXJUnitTest method testInvalidateRegionNotSupported.
/**
* make sure that we throw an UnsupportedOperationInTransactionException
*
* @throws Exception
*/
@Test
public void testInvalidateRegionNotSupported() throws Exception {
CacheTransactionManager ctm = this.cache.getCacheTransactionManager();
AttributesFactory af = new AttributesFactory();
Region r = this.cache.createRegion("dRegion", af.create());
PartitionAttributes pa = new PartitionAttributesFactory().setRedundantCopies(0).setTotalNumBuckets(1).create();
af.setPartitionAttributes(pa);
Region pr = this.cache.createRegion("prRegion", af.create());
ctm.begin();
try {
pr.invalidateRegion();
fail("Should have thrown UnsupportedOperationInTransactionException during invalidateRegion");
} catch (UnsupportedOperationInTransactionException ee) {
// expected
}
try {
pr.localInvalidateRegion();
fail("Should have thrown UnsupportedOperationInTransactionException during localInvalidateRegion");
} catch (UnsupportedOperationInTransactionException ee) {
// expected
}
try {
r.invalidateRegion();
fail("Should have thrown UnsupportedOperationInTransactionException during invalidateRegion");
} catch (UnsupportedOperationInTransactionException ee) {
// expected
}
try {
r.localInvalidateRegion();
fail("Should have thrown UnsupportedOperationInTransactionException during localInvalidateRegion");
} catch (UnsupportedOperationInTransactionException ee) {
// expected
}
ctm.commit();
// now we aren't in tx so these shouldn't throw
pr.invalidateRegion();
r.invalidateRegion();
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class PdxOrderByJUnitTest method configurePR.
private Region configurePR() {
AttributesFactory factory = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
// factory.setDataPolicy(DataPolicy.PARTITION);
PartitionAttributes prAttr = paf.setTotalNumBuckets(20).setRedundantCopies(0).create();
factory.setPartitionAttributes(prAttr);
return createRegion(this.regionName, this.rootRegionName, factory.create());
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class CacheXml66DUnitTest method testPartitionedRegionAttributesForMemLruWithMaxMem.
@Test
public void testPartitionedRegionAttributesForMemLruWithMaxMem() throws Exception {
final int redundantCopies = 1;
final int maxMem = 25;
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation(cache);
attrs.setStatisticsEnabled(true);
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(redundantCopies);
paf.setTotalMaxMemory(500);
paf.setLocalMaxMemory(100);
AttributesFactory fac = new AttributesFactory(attrs);
fac.setEvictionAttributes(EvictionAttributes.createLRUMemoryAttributes(maxMem, null, EvictionAction.LOCAL_DESTROY));
fac.setPartitionAttributes(paf.create());
cache.createRegion("parRoot", fac.create());
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region region = c.getRegion("parRoot");
assertNotNull(region);
RegionAttributes regionAttrs = region.getAttributes();
PartitionAttributes pa = regionAttrs.getPartitionAttributes();
EvictionAttributes ea = regionAttrs.getEvictionAttributes();
assertEquals(pa.getRedundantCopies(), 1);
assertEquals(pa.getLocalMaxMemory(), 100);
assertEquals(pa.getTotalMaxMemory(), 500);
assertEquals(ea.getAlgorithm(), EvictionAlgorithm.LRU_MEMORY);
assertEquals(ea.getAction(), EvictionAction.LOCAL_DESTROY);
assertNotSame(ea.getMaximum(), maxMem);
assertEquals(ea.getMaximum(), pa.getLocalMaxMemory());
}
Aggregations