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 PartitionedRegionStatsDUnitTest method createRegionAttributesForPR.
/**
* This private methods sets the passed attributes and returns RegionAttribute object, which is
* used in create region
*
* @param redundancy
* @param localMaxMem
*
* @return
*/
protected RegionAttributes createRegionAttributesForPR(int redundancy, int localMaxMem) {
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
// Properties globalProps = new Properties();
PartitionAttributes prAttr = paf.setRedundantCopies(redundancy).setLocalMaxMemory(localMaxMem).setTotalNumBuckets(totalNumBuckets).create();
attr.setPartitionAttributes(prAttr);
return attr.create();
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class PartitionedRegionStatsDUnitTest method testTotalNumBuckets.
@Test
public void testTotalNumBuckets() {
final Host host = Host.getHost(0);
final VM vm0 = host.getVM(0);
final VM vm1 = host.getVM(1);
SerializableRunnable createPrRegion = new SerializableRunnable("createRegion") {
public void run() {
Cache cache = getCache();
AttributesFactory attr = new AttributesFactory();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(2);
PartitionAttributes prAttr = paf.create();
attr.setPartitionAttributes(prAttr);
cache.createRegion("region1", attr.create());
}
};
vm0.invoke(createPrRegion);
vm1.invoke(createPrRegion);
SerializableRunnable putDataInRegion = new SerializableRunnable("Put some data") {
public void run() {
Cache cache = getCache();
Region region = cache.getRegion("region1");
region.put(Long.valueOf(0), "A");
region.put(Long.valueOf(1), "A");
region.put(Long.valueOf(113), "A");
region.put(Long.valueOf(226), "A");
}
};
vm0.invoke(putDataInRegion);
vm1.invoke(putDataInRegion);
int expectedBucketCount = 113;
validateTotalNumBucketsCount(vm0, expectedBucketCount);
validateTotalNumBucketsCount(vm1, expectedBucketCount);
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class LocalFunctionExecutionDUnitTest method createPR.
public static void createPR(String partitionedRegionName, Integer redundancy, Integer localMaxMemory, Integer totalNumBuckets, String colocatedWith) {
PartitionAttributesFactory paf = new PartitionAttributesFactory();
PartitionAttributes prAttr = paf.setRedundantCopies(redundancy.intValue()).setLocalMaxMemory(localMaxMemory.intValue()).setTotalNumBuckets(totalNumBuckets.intValue()).setColocatedWith(colocatedWith).create();
AttributesFactory attr = new AttributesFactory();
attr.setPartitionAttributes(prAttr);
assertNotNull(cache);
region = cache.createRegion(partitionedRegionName, attr.create());
assertNotNull(region);
LogWriterUtils.getLogWriter().info("Partitioned Region " + partitionedRegionName + " created Successfully :" + region);
}
use of org.apache.geode.cache.PartitionAttributes in project geode by apache.
the class MemberCommandsDUnitTest method createPartitionedRegion.
private void createPartitionedRegion(String regionName) {
final Cache cache = getCache();
// Create the data region
RegionFactory<String, Integer> dataRegionFactory = cache.createRegionFactory(RegionShortcut.PARTITION);
dataRegionFactory.setConcurrencyLevel(4);
EvictionAttributes ea = EvictionAttributes.createLIFOEntryAttributes(100, EvictionAction.LOCAL_DESTROY);
dataRegionFactory.setEvictionAttributes(ea);
dataRegionFactory.setEnableAsyncConflation(true);
FixedPartitionAttributes fpa = FixedPartitionAttributes.createFixedPartition("Par1", true);
PartitionAttributes pa = new PartitionAttributesFactory().setLocalMaxMemory(100).setRecoveryDelay(2).setTotalMaxMemory(200).setRedundantCopies(1).addFixedPartitionAttributes(fpa).create();
dataRegionFactory.setPartitionAttributes(pa);
dataRegionFactory.create(regionName);
}
Aggregations