use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class RegionManagementDUnitTest method testFixedPRRegionMBean.
/**
* Tests all Region MBean related Management APIs
* <p>
* a) Notification propagated to member MBean while a region is created
* <p>
* b) Creates and check a Fixed Partitioned Region
*/
@Test
public void testFixedPRRegionMBean() throws Exception {
createMembersAndThenManagers_tmp();
// Adding notification listener for remote cache memberVMs
// TODO: why?
addMemberNotificationListener(this.managerVM, 3);
int primaryIndex = 0;
for (VM memberVM : this.memberVMs) {
List<FixedPartitionAttributes> fixedPartitionAttributesList = createFixedPartitionList(primaryIndex + 1);
memberVM.invoke(() -> createFixedPartitionRegion(fixedPartitionAttributesList));
primaryIndex++;
}
verifyRemoteFixedPartitionRegion(this.managerVM);
for (VM memberVM : this.memberVMs) {
closeRegion(memberVM, FIXED_PR_PATH);
}
verifyMemberNotifications(this.managerVM, FIXED_PR_PATH, 3);
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class CacheXml66DUnitTest method testFixedPartitioning.
/**
* Tests that a partitioned region is created with FixedPartitionAttributes set programatically
* and correct cache.xml is generated with the same FixedPartitionAttributes
*/
@Test
public void testFixedPartitioning() throws Exception {
CacheCreation cache = new CacheCreation();
RegionAttributesCreation attrs = new RegionAttributesCreation();
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();
PartitionAttributesFactory paf = new PartitionAttributesFactory();
paf.setRedundantCopies(1).setPartitionResolver(resolver).addFixedPartitionAttributes(fpa1).addFixedPartitionAttributes(fpa2).addFixedPartitionAttributes(fpa3).addFixedPartitionAttributes(fpa4);
attrs.setPartitionAttributes(paf.create());
cache.createRegion("Quarter", attrs);
Region r = cache.getRegion("Quarter");
validateAttributes(r, fpattrsList, resolver, false);
testXml(cache);
Cache c = getCache();
assertNotNull(c);
Region region = c.getRegion("Quarter");
assertNotNull(region);
validateAttributes(region, fpattrsList, resolver, false);
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningWithColocationAndPersistenceDUnitTest method testColocation_FPRs_ChildUsingAttributesOfParent_HA.
/**
* This tests validates that Customer-Order-shipment colocation with failover scenario,
*/
@Test
public void testColocation_FPRs_ChildUsingAttributesOfParent_HA() {
try {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
member3.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition("10", true, 5);
FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition("30", false, 5);
FixedPartitionAttributes fpa3 = FixedPartitionAttributes.createFixedPartition("40", false, 5);
List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
fpaList.add(fpa1);
fpaList.add(fpa2);
fpaList.add(fpa3);
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 2, 50, 20, new CustomerFixedPartitionResolver(), null, false));
fpa1 = FixedPartitionAttributes.createFixedPartition("20", true, 5);
fpa2 = FixedPartitionAttributes.createFixedPartition("30", false, 5);
fpa3 = FixedPartitionAttributes.createFixedPartition("40", false, 5);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
fpaList.add(fpa3);
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 2, 50, 20, new CustomerFixedPartitionResolver(), null, false));
fpa1 = FixedPartitionAttributes.createFixedPartition("30", true, 5);
fpa2 = FixedPartitionAttributes.createFixedPartition("40", true, 5);
fpa3 = FixedPartitionAttributes.createFixedPartition("10", false, 5);
FixedPartitionAttributes fpa4 = FixedPartitionAttributes.createFixedPartition("20", false, 5);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
fpaList.add(fpa3);
fpaList.add(fpa4);
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 2, 50, 20, new CustomerFixedPartitionResolver(), null, false));
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Customer", false));
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Customer", false));
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Customer", false));
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Shipment", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Order", false));
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Shipment", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Order", false));
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Shipment", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Order", false));
member1.invoke(() -> FixedPartitioningTestBase.checkFPR("Order"));
member1.invoke(() -> FixedPartitioningTestBase.checkFPR("Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.checkFPR("Order"));
member2.invoke(() -> FixedPartitioningTestBase.checkFPR("Shipment"));
member3.invoke(() -> FixedPartitioningTestBase.checkFPR("Order"));
member3.invoke(() -> FixedPartitioningTestBase.checkFPR("Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.putCustomerPartitionedRegion("Customer"));
member1.invoke(() -> FixedPartitioningTestBase.putOrderPartitionedRegion("Order"));
member1.invoke(() -> FixedPartitioningTestBase.putShipmentPartitionedRegion("Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.validateAfterPutPartitionedRegion("Customer", "Order", "Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(15, 5, "Customer", "Order", "Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(15, 5, "Customer", "Order", "Shipment"));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(20, 10, "Customer", "Order", "Shipment"));
member3.invoke(() -> FixedPartitioningTestBase.closeCache());
Wait.pause(4000);
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocationAfterCacheClosed(15, 5, "Customer", "Order", "Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocationAfterCacheClosed(15, 5, "Customer", "Order", "Shipment"));
member3.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition("30", true, 5);
fpa2 = FixedPartitionAttributes.createFixedPartition("10", false, 5);
fpa3 = FixedPartitionAttributes.createFixedPartition("20", false, 5);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
fpaList.add(fpa3);
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 2, 50, 20, new CustomerFixedPartitionResolver(), null, false));
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Customer", false));
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Shipment", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Order", false));
Wait.pause(4000);
member1.invoke(() -> FixedPartitioningTestBase.validateAfterPutPartitionedRegion("Customer", "Order", "Shipment"));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(15, 5, "Customer", "Order", "Shipment"));
member4.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition("40", true, 5);
fpa2 = FixedPartitionAttributes.createFixedPartition("10", false, 5);
fpa3 = FixedPartitionAttributes.createFixedPartition("20", false, 5);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
fpaList.add(fpa3);
member4.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 2, 50, 20, new CustomerFixedPartitionResolver(), null, false));
member4.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Customer", false));
member4.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Shipment", null, 2, 50, 20, new CustomerFixedPartitionResolver(), "Order", false));
Wait.pause(4000);
member1.invoke(() -> FixedPartitioningTestBase.validateAfterPutPartitionedRegion("Customer", "Order", "Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(15, 5, "Customer", "Order", "Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(15, 5, "Customer", "Order", "Shipment"));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(15, 5, "Customer", "Order", "Shipment"));
member4.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(15, 5, "Customer", "Order", "Shipment"));
} catch (Exception e) {
Assert.fail("Unexpected Exception ", e);
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningWithColocationAndPersistenceDUnitTest method testColocation_FPR_Persistence_Colocation_OneMemberAlive.
/**
* Tests validate the behavior of FPR with persistence and with colocation when one member is kept
* alive and other members goes down and come up
*/
@Test
public void testColocation_FPR_Persistence_Colocation_OneMemberAlive() {
try {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition("10", true, 5);
FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition("20", false, 5);
List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
fpaList.add(fpa1);
fpaList.add(fpa2);
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 1, 50, 20, new CustomerFixedPartitionResolver(), null, true));
fpa1 = FixedPartitionAttributes.createFixedPartition("20", true, 5);
fpa2 = FixedPartitionAttributes.createFixedPartition("10", false, 5);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 1, 50, 20, new CustomerFixedPartitionResolver(), null, true));
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", null, 1, 50, 20, new CustomerFixedPartitionResolver(), "Customer", false));
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", null, 1, 50, 20, new CustomerFixedPartitionResolver(), "Customer", false));
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Shipment", null, 1, 50, 20, new CustomerFixedPartitionResolver(), "Order", false));
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Shipment", null, 1, 50, 20, new CustomerFixedPartitionResolver(), "Order", false));
member1.invoke(() -> FixedPartitioningTestBase.checkFPR("Order"));
member1.invoke(() -> FixedPartitioningTestBase.checkFPR("Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.checkFPR("Order"));
member2.invoke(() -> FixedPartitioningTestBase.checkFPR("Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.putCustomerPartitionedRegion_Persistence1("Customer"));
member1.invoke(() -> FixedPartitioningTestBase.putOrderPartitionedRegion_Persistence1("Order"));
member1.invoke(() -> FixedPartitioningTestBase.putShipmentPartitionedRegion_Persistence1("Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.validateAfterPutPartitionedRegion("Customer", "Order", "Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(10, 5, "Customer", "Order", "Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(10, 5, "Customer", "Order", "Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.closeCache());
member1.invoke(() -> FixedPartitioningTestBase.putCustomerPartitionedRegion_Persistence2("Customer"));
member1.invoke(() -> FixedPartitioningTestBase.putOrderPartitionedRegion_Persistence2("Order"));
member1.invoke(() -> FixedPartitioningTestBase.putShipmentPartitionedRegion_Persistence2("Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.validateAfterPutPartitionedRegion("Customer", "Order", "Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(10, 10, "Customer", "Order", "Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition("20", true, 5);
fpa2 = FixedPartitionAttributes.createFixedPartition("10", false, 5);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
AsyncInvocation[] async = new AsyncInvocation[2];
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 1, 50, 20, new CustomerFixedPartitionResolver(), null, true));
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", null, 1, 50, 20, new CustomerFixedPartitionResolver(), "Customer", false));
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Shipment", null, 1, 50, 20, new CustomerFixedPartitionResolver(), "Order", false));
Wait.pause(4000);
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(10, 5, "Customer", "Order", "Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForColocation(10, 5, "Customer", "Order", "Shipment"));
member1.invoke(() -> FixedPartitioningTestBase.validateAfterPutPartitionedRegion("Customer", "Order", "Shipment"));
member2.invoke(() -> FixedPartitioningTestBase.validateAfterPutPartitionedRegion("Customer", "Order", "Shipment"));
} catch (Exception e) {
Assert.fail("Unexpected Exception ", e);
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningWithColocationAndPersistenceDUnitTest method testColocation_WithFPROnChildRegion.
/**
* This tests validates that in colocation of FPRs child region cannot specify
* FixedPartitionAttributes
*
*/
@Test
public void testColocation_WithFPROnChildRegion() {
try {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition("Customer100", true, 2);
List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
fpaList.add(fpa1);
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Customer", fpaList, 0, 40, 8, null, null, false));
fpa1 = FixedPartitionAttributes.createFixedPartition("Order100", true, 2);
fpaList.clear();
fpaList.add(fpa1);
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Order", fpaList, 0, 40, 8, null, "Customer", false));
fail("IllegalStateException expected");
} catch (Exception illegal) {
if (!((illegal.getCause() instanceof IllegalStateException) && (illegal.getCause().getMessage().contains("not be specified in PartitionAttributesFactory if colocated-with is specified")))) {
Assert.fail("Expected IllegalStateException ", illegal);
}
}
}
Aggregations