use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method testFixedPartitionAttributes_Accessor.
/**
* This test validates that FixedPartitionAttributes cannot be defined for accessor nodes
*/
@Test
public void testFixedPartitionAttributes_Accessor() {
try {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1, true, 3);
FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter2, false, 3);
List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
fpaList.add(fpa1);
fpaList.add(fpa2);
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 0, 3, new QuarterPartitionResolver(), null, false));
fail("IllegalStateException Expected");
} catch (Exception illegal) {
if (!((illegal.getCause() instanceof IllegalStateException) && (illegal.getCause().getMessage().contains("can not be defined for accessor")))) {
Assert.fail("Expected IllegalStateException ", illegal);
}
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method testPut_FixedPartitionResolver_PartitionResolver.
/**
* This tests validate that datastore member tries the put on itself as well as other datastores
* as per primary FixedPartitionAttributes defined on datastores. Here No Resolver is provided
* through attributes. Some keys implement FixedPartitionResolver and some implements
* PartitionResolver. IllegalStateException is expected.
*/
@Test
public void testPut_FixedPartitionResolver_PartitionResolver() {
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, 12, null, 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, 12, null, null, false));
member3.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter3, true, 3);
fpaList.clear();
fpaList.add(fpa1);
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 12, null, null, false));
member4.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter4, true, 3);
fpaList.clear();
fpaList.add(fpa1);
member4.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 12, null, null, false));
try {
member1.invoke(() -> FixedPartitioningTestBase.putThroughDataStore_FixedPartitionResolver_PartitionResolver("Quarter"));
fail("IllegalStateException expected");
} catch (Exception ex) {
if (!((ex.getCause() instanceof IllegalStateException))) {
Assert.fail("Expected IllegalStateException ", ex);
}
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method test_Bug46619_Put_ValidateDataOnMember_PrimarySecondary_Datastore_CacheClosed.
@Test
public void test_Bug46619_Put_ValidateDataOnMember_PrimarySecondary_Datastore_CacheClosed() {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember_DisableMovePrimary());
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1, true, 3);
FixedPartitionAttributes fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter2, false, 3);
List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
fpaList.add(fpa1);
fpaList.add(fpa2);
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 1, 40, 12, new QuarterPartitionResolver(), null, false));
member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember_DisableMovePrimary());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter2, true, 3);
fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter3, false, 3);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 1, 40, 12, new QuarterPartitionResolver(), null, false));
member3.invoke(() -> FixedPartitioningTestBase.createCacheOnMember_DisableMovePrimary());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter3, true, 3);
fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter4, false, 3);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 1, 40, 12, new QuarterPartitionResolver(), null, false));
member4.invoke(() -> FixedPartitioningTestBase.createCacheOnMember_DisableMovePrimary());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter4, true, 3);
fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter1, false, 3);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
member4.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 1, 40, 12, new QuarterPartitionResolver(), null, false));
member1.invoke(() -> FixedPartitioningTestBase.putThroughDataStore("Quarter"));
member1.invoke(() -> FixedPartitioningTestBase.checkPrimarySecondaryData(Quarter1, false));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimarySecondaryData(Quarter2, false));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimarySecondaryData(Quarter3, false));
member4.invoke(() -> FixedPartitioningTestBase.checkPrimarySecondaryData(Quarter4, false));
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 3));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 3));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 3));
member4.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 3));
member4.invoke(() -> FixedPartitioningTestBase.closeCache());
member2.invoke(() -> FixedPartitioningTestBase.closeCache());
Wait.pause(1000);
member3.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarterAfterCacheClosed(6, 6));
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarterAfterCacheClosed(6, 6));
member1.invoke(() -> FixedPartitioningTestBase.putHAData("Quarter"));
member4.invoke(() -> FixedPartitioningTestBase.createCacheOnMember_DisableMovePrimary());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter4, true, 3);
fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter1, false, 3);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
member4.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 1, 40, 12, new QuarterPartitionResolver(), null, false));
member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember_DisableMovePrimary());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter2, true, 3);
fpa2 = FixedPartitionAttributes.createFixedPartition(Quarter3, false, 3);
fpaList.clear();
fpaList.add(fpa1);
fpaList.add(fpa2);
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 1, 40, 12, new QuarterPartitionResolver(), null, false));
Wait.pause(1000);
member1.invoke(() -> FixedPartitioningTestBase.checkPrimarySecondaryData(Quarter1, true));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimarySecondaryData(Quarter2, true));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimarySecondaryData(Quarter3, true));
member4.invoke(() -> FixedPartitioningTestBase.checkPrimarySecondaryData(Quarter4, true));
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 6));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 0));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 6));
member4.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 0));
member4.invoke(() -> FixedPartitioningTestBase.doRebalance());
Wait.pause(2000);
member1.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 3));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 3));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 3));
member4.invoke(() -> FixedPartitioningTestBase.checkPrimaryBucketsForQuarter(6, 3));
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method testPut_NoResolver.
/**
* This tests validate that datastore member tries the put on itself as well as other datastores
* as per primary FixedPartitionAttributes defined on datastores. But No resolver is provided. So
* IllegalStateException in expected
*/
@Test
public void testPut_NoResolver() {
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, 12, null, 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, 12, null, null, false));
member3.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter3, true, 3);
fpaList.clear();
fpaList.add(fpa1);
member3.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 12, null, null, false));
member4.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter4, true, 3);
fpaList.clear();
fpaList.add(fpa1);
member4.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 12, null, null, false));
try {
member1.invoke(() -> FixedPartitioningTestBase.putThroughDataStore_NoResolver("Quarter"));
fail("IllegalStateException expected");
} catch (Exception ex) {
if (!((ex.getCause() instanceof IllegalStateException))) {
Assert.fail("Expected IllegalStateException ", ex);
}
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method testPut_ValidateDataOnMember_OnlyPrimary_Accessor.
/**
* This tests validate that accessor member does the put on datastores as per primary
* FixedPartitionAttributes defined on datastores
*/
@Test
public void testPut_ValidateDataOnMember_OnlyPrimary_Accessor() {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", null, 0, 0, 12, new QuarterPartitionResolver(), null, false));
member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
FixedPartitionAttributes fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter1, true, 3);
List<FixedPartitionAttributes> fpaList = new ArrayList<FixedPartitionAttributes>();
fpaList.add(fpa1);
member2.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 12, 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, 12, new QuarterPartitionResolver(), null, false));
member4.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
fpa1 = FixedPartitionAttributes.createFixedPartition(Quarter3, true, 3);
fpaList.clear();
fpaList.add(fpa1);
member4.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", fpaList, 0, 40, 12, new QuarterPartitionResolver(), null, false));
member1.invoke(() -> FixedPartitioningTestBase.putThorughAccessor("Quarter"));
member2.invoke(() -> FixedPartitioningTestBase.checkPrimaryData(Quarter1));
member3.invoke(() -> FixedPartitioningTestBase.checkPrimaryData(Quarter2));
member4.invoke(() -> FixedPartitioningTestBase.checkPrimaryData(Quarter3));
}
Aggregations