use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class PartitionRegionConfigValidator method validateFixedPartitionAttributesAgainstRedundantCopies.
/**
* Validate that for the given partition, number if secondaries are never exceed redundant copies
* defined Validate that the num-buckets defined for a partition are same across all datastores
*/
private void validateFixedPartitionAttributesAgainstRedundantCopies() {
for (FixedPartitionAttributesImpl fpa : this.pr.getFixedPartitionAttributesImpl()) {
List<FixedPartitionAttributesImpl> allSameFPAs = this.pr.getRegionAdvisor().adviseSameFPAs(fpa);
allSameFPAs.add(fpa);
if (!allSameFPAs.isEmpty()) {
int numSecondaries = 0;
for (FixedPartitionAttributes otherfpa : allSameFPAs) {
if (fpa.getNumBuckets() != otherfpa.getNumBuckets()) {
Object[] prms = new Object[] { this.pr.getName(), fpa.getPartitionName(), fpa.getNumBuckets(), otherfpa.getNumBuckets() };
throw new IllegalStateException(LocalizedStrings.PartitionedRegionConfigValidator_FOR_REGION_0_FOR_PARTITION_1_NUM_BUCKETS_ARE_NOT_SAME_ACROSS_NODES.toString(prms));
}
if (!otherfpa.isPrimary()) {
if (++numSecondaries > (this.pr.getRedundantCopies())) {
Object[] prms = new Object[] { this.pr.getName(), numSecondaries, fpa.getPartitionName(), this.pr.getRedundantCopies() };
throw new IllegalStateException(LocalizedStrings.PartitionedRegionConfigValidator_FOR_REGION_0_NUMBER_OF_SECONDARY_PARTITIONS_1_OF_A_PARTITION_2_SHOULD_NEVER_EXCEED_NUMBER_OF_REDUNDANT_COPIES_3.toString(prms));
}
}
}
}
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class RegionMBeanCompositeDataFactory method getFixedPartitionAttributesData.
public static FixedPartitionAttributesData[] getFixedPartitionAttributesData(PartitionAttributes partAttrs) {
FixedPartitionAttributesData[] fixedPartitionAttributesTable = new FixedPartitionAttributesData[partAttrs.getFixedPartitionAttributes().size()];
Iterator<FixedPartitionAttributes> it = partAttrs.getFixedPartitionAttributes().iterator();
int j = 0;
while (it.hasNext()) {
FixedPartitionAttributes fa = it.next();
FixedPartitionAttributesData data = new FixedPartitionAttributesData(fa.getPartitionName(), fa.isPrimary(), fa.getNumBuckets());
fixedPartitionAttributesTable[j] = data;
j++;
}
return fixedPartitionAttributesTable;
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class CacheXml66DUnitTest method validateAttributes.
private void validateAttributes(Region region, List<FixedPartitionAttributes> fpattrsList, QuarterPartitionResolver resolver, boolean isColocated) {
RegionAttributes regionAttrs = region.getAttributes();
PartitionAttributes pa = regionAttrs.getPartitionAttributes();
assertEquals(pa.getRedundantCopies(), 1);
assertNotNull(pa.getPartitionResolver().getClass());
assertEquals(pa.getPartitionResolver(), resolver);
List<FixedPartitionAttributesImpl> fixedPartitionsList = pa.getFixedPartitionAttributes();
if (isColocated) {
assertNull(fixedPartitionsList);
assertNotNull(pa.getColocatedWith());
} else {
assertNull(pa.getColocatedWith());
assertEquals(fixedPartitionsList.size(), 4);
assertEquals(fixedPartitionsList.containsAll(fpattrsList), true);
for (FixedPartitionAttributes fpa : fixedPartitionsList) {
if (fpa.getPartitionName().equals("Q1")) {
assertEquals(fpa.getNumBuckets(), 1);
assertEquals(fpa.isPrimary(), false);
}
if (fpa.getPartitionName().equals("Q2")) {
assertEquals(fpa.getNumBuckets(), 1);
assertEquals(fpa.isPrimary(), true);
}
if (fpa.getPartitionName().equals("Q3")) {
assertEquals(fpa.getNumBuckets(), 3);
assertEquals(fpa.isPrimary(), false);
}
if (fpa.getPartitionName().equals("Q4")) {
assertEquals(fpa.getNumBuckets(), 3);
assertEquals(fpa.isPrimary(), false);
}
}
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class CacheXmlGenerator method generateFixedPartitionAttributes.
/**
* Generate XML for FixedPartitionAttribute element in PartitionedRegion Attributes
*/
private void generateFixedPartitionAttributes(String kind, List<FixedPartitionAttributes> allStaticAttrs) throws SAXException {
for (FixedPartitionAttributes attr : allStaticAttrs) {
AttributesImpl sAtts = new AttributesImpl();
sAtts.addAttribute("", "", PARTITION_NAME, "", attr.getPartitionName());
sAtts.addAttribute("", "", IS_PRIMARY, "", String.valueOf(attr.isPrimary()));
sAtts.addAttribute("", "", NUM_BUCKETS, "", String.valueOf(attr.getNumBuckets()));
handler.startElement("", kind, kind, sAtts);
handler.endElement("", kind, kind);
}
}
use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.
the class PartitionedRegionHelper method getAllAvailablePartitions.
private static Set<String> getAllAvailablePartitions(PartitionedRegion region) {
Set<String> partitionSet = new HashSet<String>();
List<FixedPartitionAttributesImpl> localFPAs = region.getFixedPartitionAttributesImpl();
if (localFPAs != null) {
for (FixedPartitionAttributesImpl fpa : localFPAs) {
partitionSet.add(fpa.getPartitionName());
}
}
List<FixedPartitionAttributesImpl> remoteFPAs = region.getRegionAdvisor().adviseAllFixedPartitionAttributes();
for (FixedPartitionAttributes fpa : remoteFPAs) {
partitionSet.add(fpa.getPartitionName());
}
return Collections.unmodifiableSet(partitionSet);
}
Aggregations