use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method testDelete_WithoutPut.
/**
* This test validate that a delete operation on empty region will throw EntryNotFoundException
*/
@Test
public void testDelete_WithoutPut() {
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, 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, 12, new QuarterPartitionResolver(), 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, new QuarterPartitionResolver(), 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, new QuarterPartitionResolver(), null, false));
try {
member1.invoke(() -> FixedPartitioningTestBase.deleteOperation("Quarter"));
fail("EntryNotFoundException expected");
} catch (Exception ex) {
if (!((ex.getCause() instanceof EntryNotFoundException))) {
Assert.fail("Expected EntryNotFoundException ", ex);
}
}
member1.invoke(() -> FixedPartitioningTestBase.putThroughDataStore("Quarter"));
member1.invoke(() -> FixedPartitioningTestBase.getThroughDataStore("Quarter"));
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method test_DataStoreWithoutPartition_DataStoreWithPartition.
/**
* This test validates that if one datastore has the fixed partition attributes defined then other
* datastore should also have the fixed partition attributes defined
*/
@Test
public void test_DataStoreWithoutPartition_DataStoreWithPartition() {
IgnoredException expected = IgnoredException.addIgnoredException("IllegalStateException");
try {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", null, 1, 40, 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, 1, 40, 12, new QuarterPartitionResolver(), null, false));
} catch (Exception ex) {
if (!((ex.getCause() instanceof IllegalStateException))) {
Assert.fail("Expected IllegalStateException ", ex);
}
} finally {
expected.remove();
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method testPut_ValidateDataOnMember_PrimarySecondary_Datastore.
/**
* This tests validate that datastore member does the put on itself as well as other datastores as
* per primary and secondary FixedPartitionAttributes defined on datastores.
*/
// GEODE-1704
@Category(FlakyTest.class)
@Test
public void testPut_ValidateDataOnMember_PrimarySecondary_Datastore() {
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, 1, 40, 12, new QuarterPartitionResolver(), null, false));
member2.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
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());
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());
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));
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class FixedPartitioningDUnitTest method testPut_PartitionNotAvailableException.
/**
* This test validates that if the required partition is not available at the time of entry
* operation then PartitionNotAvailabelException is thrown
*/
@Test
public void testPut_PartitionNotAvailableException() {
try {
member1.invoke(() -> FixedPartitioningTestBase.createCacheOnMember());
member1.invoke(() -> FixedPartitioningTestBase.createRegionWithPartitionAttributes("Quarter", null, 1, 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, 1, 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, 1, 40, 12, new QuarterPartitionResolver(), null, false));
member1.invoke(() -> FixedPartitioningTestBase.putThorughAccessor("Quarter"));
fail("PartitionNotAvailableException Expected");
} catch (Exception ex) {
if (!((ex.getCause() instanceof PartitionNotAvailableException))) {
Assert.fail("Expected PartitionNotAvailableException ", ex);
}
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class QueryDataDUnitTest method testRegionsLocalDataSet.
@Test
public void testRegionsLocalDataSet() throws Exception {
String partitionedRegionName = this.testName.getMethodName() + "_PARTITIONED_REGION";
String[] values1 = new String[] { "val1", "val2", "val3" };
String[] values2 = new String[] { "val4", "val5", "val6" };
this.memberVMs[0].invoke(this.testName.getMethodName() + " Create Region", () -> {
PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
partitionAttributesFactory.setRedundantCopies(2).setTotalNumBuckets(12);
List<FixedPartitionAttributes> fixedPartitionAttributesList = createFixedPartitionList(1);
for (FixedPartitionAttributes fixedPartitionAttributes : fixedPartitionAttributesList) {
partitionAttributesFactory.addFixedPartitionAttributes(fixedPartitionAttributes);
}
partitionAttributesFactory.setPartitionResolver(new SingleHopQuarterPartitionResolver());
RegionFactory regionFactory = this.managementTestRule.getCache().createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(partitionAttributesFactory.create());
Region region = regionFactory.create(partitionedRegionName);
for (int i = 0; i < values1.length; i++) {
region.put(getDate(2013, 1, i + 5), values1[i]);
}
});
this.memberVMs[1].invoke(this.testName.getMethodName() + " Create Region", () -> {
PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
partitionAttributesFactory.setRedundantCopies(2).setTotalNumBuckets(12);
List<FixedPartitionAttributes> fixedPartitionAttributesList = createFixedPartitionList(2);
for (FixedPartitionAttributes fixedPartitionAttributes : fixedPartitionAttributesList) {
partitionAttributesFactory.addFixedPartitionAttributes(fixedPartitionAttributes);
}
partitionAttributesFactory.setPartitionResolver(new SingleHopQuarterPartitionResolver());
RegionFactory regionFactory = this.managementTestRule.getCache().createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(partitionAttributesFactory.create());
Region region = regionFactory.create(partitionedRegionName);
for (int i = 0; i < values2.length; i++) {
region.put(getDate(2013, 5, i + 5), values2[i]);
}
});
this.memberVMs[2].invoke(this.testName.getMethodName() + " Create Region", () -> {
PartitionAttributesFactory partitionAttributesFactory = new PartitionAttributesFactory();
partitionAttributesFactory.setRedundantCopies(2).setTotalNumBuckets(12);
List<FixedPartitionAttributes> fixedPartitionAttributesList = createFixedPartitionList(3);
fixedPartitionAttributesList.forEach(partitionAttributesFactory::addFixedPartitionAttributes);
partitionAttributesFactory.setPartitionResolver(new SingleHopQuarterPartitionResolver());
RegionFactory regionFactory = this.managementTestRule.getCache().createRegionFactory(RegionShortcut.PARTITION).setPartitionAttributes(partitionAttributesFactory.create());
regionFactory.create(partitionedRegionName);
});
List<String> member1RealData = this.memberVMs[0].invoke(() -> getLocalDataSet(partitionedRegionName));
List<String> member2RealData = this.memberVMs[1].invoke(() -> getLocalDataSet(partitionedRegionName));
List<String> member3RealData = this.memberVMs[2].invoke(() -> getLocalDataSet(partitionedRegionName));
this.managerVM.invoke(this.testName.getMethodName(), () -> {
DistributedSystemMXBean distributedSystemMXBean = this.managementTestRule.getSystemManagementService().getDistributedSystemMXBean();
DistributedRegionMXBean distributedRegionMXBean = awaitDistributedRegionMXBean("/" + partitionedRegionName, 3);
String alias = "Waiting for all entries to get reflected at managing node";
int expectedEntryCount = values1.length + values2.length;
await(alias).until(() -> assertThat(distributedRegionMXBean.getSystemRegionEntryCount()).isEqualTo(expectedEntryCount));
String query = "Select * from /" + partitionedRegionName;
String member1Result = distributedSystemMXBean.queryData(query, member1.getId(), 0);
verifyJsonIsValid(member1Result);
String member2Result = distributedSystemMXBean.queryData(query, member2.getId(), 0);
verifyJsonIsValid(member2Result);
String member3Result = distributedSystemMXBean.queryData(query, member3.getId(), 0);
verifyJsonIsValid(member3Result);
for (String val : member1RealData) {
assertThat(member1Result).contains(val);
}
for (String val : member2RealData) {
assertThat(member2Result).contains(val);
}
assertThat(member3Result).contains("No Data Found");
});
}
Aggregations