use of org.apache.geode.cache.FixedPartitionAttributes 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);
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class LuceneTestUtilities method createFixedPartitionedRegion.
public static Region createFixedPartitionedRegion(final Cache cache, String regionName, List<FixedPartitionAttributes> fpaList, int localMaxMemory) {
List<String> allPartitions = new ArrayList();
if (fpaList != null) {
for (FixedPartitionAttributes fpa : fpaList) {
allPartitions.add(fpa.getPartitionName());
}
} else {
allPartitions.add("Q1");
allPartitions.add("Q2");
}
AttributesFactory fact = new AttributesFactory();
PartitionAttributesFactory pfact = new PartitionAttributesFactory();
pfact.setTotalNumBuckets(16);
pfact.setRedundantCopies(1);
pfact.setLocalMaxMemory(localMaxMemory);
if (fpaList != null) {
for (FixedPartitionAttributes fpa : fpaList) {
pfact.addFixedPartitionAttributes(fpa);
}
}
pfact.setPartitionResolver(new MyFixedPartitionResolver(allPartitions));
fact.setPartitionAttributes(pfact.create());
Region r = cache.createRegionFactory(fact.create()).create(regionName);
assertNotNull(r);
return r;
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class LuceneTestUtilities method initDataStoreForFixedPR.
public static Region initDataStoreForFixedPR(final Cache cache) throws Exception {
List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
int vmNum = VM.getCurrentVMNum();
if (vmNum % 2 == 0) {
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1, true);
FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter2, false);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
} else {
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1, false);
FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter2, true);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
}
return createFixedPartitionedRegion(cache, REGION_NAME, fpaList, 40);
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class RegionManagementDUnitTest method createFixedPartitionRegion.
/**
* Invoked in member VMs
*/
private void createFixedPartitionRegion(final List<FixedPartitionAttributes> fixedPartitionAttributesList) {
SystemManagementService service = getSystemManagementService_tmp();
PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
partitionAttributesFactory.setRedundantCopies(2).setTotalNumBuckets(12);
for (FixedPartitionAttributes fixedPartitionAttributes : fixedPartitionAttributesList) {
partitionAttributesFactory.addFixedPartitionAttributes(fixedPartitionAttributes);
}
partitionAttributesFactory.setPartitionResolver(new SingleHopQuarterPartitionResolver());
AttributesFactory attributesFactory = new AttributesFactory();
attributesFactory.setPartitionAttributes(partitionAttributesFactory.create());
fixedPartitionedRegion = getCache_tmp().createRegion(FIXED_PR_NAME, attributesFactory.create());
assertThat(fixedPartitionedRegion).isNotNull();
RegionMXBean regionMXBean = service.getLocalRegionMBean(FIXED_PR_PATH);
RegionAttributes regionAttributes = fixedPartitionedRegion.getAttributes();
PartitionAttributesData partitionAttributesData = regionMXBean.listPartitionAttributes();
verifyPartitionData(regionAttributes, partitionAttributesData);
FixedPartitionAttributesData[] fixedPartitionAttributesData = regionMXBean.listFixedPartitionAttributes();
assertThat(fixedPartitionAttributesData).isNotNull();
assertThat(fixedPartitionAttributesData).hasSize(3);
for (int i = 0; i < fixedPartitionAttributesData.length; i++) {
// TODO: add real assertions
// LogWriterUtils.getLogWriter().info("<ExpectedString> Fixed PR Data is " +
// fixedPartitionAttributesData[i] + "</ExpectedString> ");
}
}
use of org.apache.geode.cache.FixedPartitionAttributes 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);
}
Aggregations