Search in sources :

Example 1 with DuplicatePrimaryPartitionException

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();
    }
}
Also used : FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) ArrayList(java.util.ArrayList) IgnoredException(org.apache.geode.test.dunit.IgnoredException) DuplicatePrimaryPartitionException(org.apache.geode.cache.DuplicatePrimaryPartitionException) EntryNotFoundException(org.apache.geode.cache.EntryNotFoundException) PartitionNotAvailableException(org.apache.geode.cache.partition.PartitionNotAvailableException) DuplicatePrimaryPartitionException(org.apache.geode.cache.DuplicatePrimaryPartitionException) IgnoredException(org.apache.geode.test.dunit.IgnoredException) Test(org.junit.Test) DistributedTest(org.apache.geode.test.junit.categories.DistributedTest) FlakyTest(org.apache.geode.test.junit.categories.FlakyTest)

Aggregations

ArrayList (java.util.ArrayList)1 DuplicatePrimaryPartitionException (org.apache.geode.cache.DuplicatePrimaryPartitionException)1 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)1 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)1 PartitionNotAvailableException (org.apache.geode.cache.partition.PartitionNotAvailableException)1 IgnoredException (org.apache.geode.test.dunit.IgnoredException)1 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)1 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)1 Test (org.junit.Test)1