use of org.apache.geode.cache.PartitionAttributesFactory 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.PartitionAttributesFactory 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.PartitionAttributesFactory 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.PartitionAttributesFactory in project geode by apache.
the class PdxGroupByPartitionedJUnitTest method createRegion.
@Override
public Region createRegion(String regionName, Class valueConstraint) {
PartitionAttributesFactory paf = new PartitionAttributesFactory();
AttributesFactory af = new AttributesFactory();
af.setPartitionAttributes(paf.create());
af.setValueConstraint(valueConstraint);
Region r1 = CacheUtils.createRegion(regionName, af.create(), false);
return r1;
}
use of org.apache.geode.cache.PartitionAttributesFactory 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());
}
Aggregations