use of org.apache.geode.cache.DuplicatePrimaryPartitionException in project geode by apache.
the class FixedPartitioningDUnitTest method testSamePartitionName_Primary_OnTwoMembers.
/**
* Test validation : only one node should return primary for a particular partition name for a
* specific FPR at any given point of time. DuplicatePrimaryPartitionException is thrown during
* FPR creation if this condition is not met.
*/
@Test
public void testSamePartitionName_Primary_OnTwoMembers() {
IgnoredException ex = IgnoredException.addIgnoredException("DuplicatePrimaryPartitionException");
try {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1, true, 3);
List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
fpaList.add(fpa1);
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 9, new QuarterPartitionResolver(), null, false));
member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter2, true, 3);
fpaList.clear();
fpaList.add(fpa1);
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 9, new QuarterPartitionResolver(), null, false));
member3.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter2, true, 3);
fpaList.clear();
fpaList.add(fpa1);
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 9, new QuarterPartitionResolver(), null, false));
fail("DuplicatePrimaryPartitionException Expected");
} catch (Exception duplicate) {
if (!((duplicate.getCause() instanceof DuplicatePrimaryPartitionException) && (duplicate.getCause().getMessage().contains("can not be defined as primary on more than one node")))) {
Assert.fail("Expected DuplicatePrimaryPartitionException ", duplicate);
}
} finally {
ex.remove();
}
}
Aggregations