Search in sources :

Example 26 with FixedPartitionAttributes

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;
}
Also used : FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) FixedPartitionAttributesData(org.apache.geode.management.FixedPartitionAttributesData)

Example 27 with FixedPartitionAttributes

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));
                    }
                }
            }
        }
    }
}
Also used : FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes)

Example 28 with FixedPartitionAttributes

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);
            }
        }
    }
}
Also used : FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) RegionAttributes(org.apache.geode.cache.RegionAttributes) PartitionAttributes(org.apache.geode.cache.PartitionAttributes) FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) FixedPartitionAttributesImpl(org.apache.geode.internal.cache.FixedPartitionAttributesImpl)

Example 29 with FixedPartitionAttributes

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);
    }
}
Also used : FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) DiskWriteAttributesImpl(org.apache.geode.internal.cache.DiskWriteAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) AttributesImpl(org.xml.sax.helpers.AttributesImpl)

Example 30 with FixedPartitionAttributes

use of org.apache.geode.cache.FixedPartitionAttributes in project geode by apache.

the class FixedPartitioningTestBase method createRegionWithPartitionAttributes.

public static void createRegionWithPartitionAttributes(String regionName, List<FixedPartitionAttributes> fpaList, Integer redCopies, Integer localMaxMemory, Integer totalNumBuckets, PartitionResolver resolver, String colocatedWith, boolean isPersistence) {
    PartitionAttributesFactory paf_FPR = new PartitionAttributesFactory();
    paf_FPR.setRedundantCopies(redCopies);
    paf_FPR.setLocalMaxMemory(localMaxMemory);
    paf_FPR.setTotalNumBuckets(totalNumBuckets);
    paf_FPR.setPartitionResolver(resolver);
    paf_FPR.setColocatedWith(colocatedWith);
    if (fpaList != null) {
        for (FixedPartitionAttributes fpa : fpaList) {
            paf_FPR.addFixedPartitionAttributes(fpa);
        }
    }
    AttributesFactory af_FPR = new AttributesFactory();
    af_FPR.setPartitionAttributes(paf_FPR.create());
    if (isPersistence) {
        DiskStore ds = cache.findDiskStore("disk");
        if (ds == null) {
            ds = cache.createDiskStoreFactory().setDiskDirs(getDiskDirs()).create("disk");
        }
        af_FPR.setDataPolicy(DataPolicy.PERSISTENT_PARTITION);
        af_FPR.setDiskStoreName("disk");
    }
    region_FPR = (PartitionedRegion) cache.createRegion(regionName, af_FPR.create());
    assertNotNull(region_FPR);
}
Also used : DiskStore(org.apache.geode.cache.DiskStore) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory) FixedPartitionAttributes(org.apache.geode.cache.FixedPartitionAttributes) AttributesFactory(org.apache.geode.cache.AttributesFactory) PartitionAttributesFactory(org.apache.geode.cache.PartitionAttributesFactory)

Aggregations

FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)63 Test (org.junit.Test)46 ArrayList (java.util.ArrayList)45 DistributedTest (org.apache.geode.test.junit.categories.DistributedTest)43 FlakyTest (org.apache.geode.test.junit.categories.FlakyTest)30 IgnoredException (org.apache.geode.test.dunit.IgnoredException)16 DuplicatePrimaryPartitionException (org.apache.geode.cache.DuplicatePrimaryPartitionException)15 EntryNotFoundException (org.apache.geode.cache.EntryNotFoundException)15 PartitionNotAvailableException (org.apache.geode.cache.partition.PartitionNotAvailableException)15 PartitionAttributesFactory (org.apache.geode.cache.PartitionAttributesFactory)12 AttributesFactory (org.apache.geode.cache.AttributesFactory)7 Region (org.apache.geode.cache.Region)6 VM (org.apache.geode.test.dunit.VM)6 Cache (org.apache.geode.cache.Cache)5 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)5 SingleHopQuarterPartitionResolver (org.apache.geode.internal.cache.partitioned.fixed.SingleHopQuarterPartitionResolver)5 Host (org.apache.geode.test.dunit.Host)5 IOException (java.io.IOException)4 QuarterPartitionResolver (org.apache.geode.internal.cache.partitioned.fixed.QuarterPartitionResolver)4 HashSet (java.util.HashSet)3