Search in sources :

Example 6 with FixedPartitionAttributesImpl

use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.

the class CacheXmlParser method startFixedPartitionAttributes.

/**
   * When a <code>fixed-partition-attributes</code> element is encountered, we create an instance of
   * FixedPartitionAttributesImpl and add it to the PartitionAttributesImpl stack.
   */
private void startFixedPartitionAttributes(Attributes atts) {
    FixedPartitionAttributesImpl fpai = new FixedPartitionAttributesImpl();
    String partitionName = atts.getValue(PARTITION_NAME);
    if (partitionName != null) {
        fpai.setPartitionName(partitionName);
    }
    String isPrimary = atts.getValue(IS_PRIMARY);
    if (isPrimary != null) {
        fpai.isPrimary(parseBoolean(isPrimary));
    }
    String numBuckets = atts.getValue(NUM_BUCKETS);
    if (numBuckets != null) {
        fpai.setNumBuckets(parseInt(numBuckets));
    }
    Object a = stack.peek();
    if (a instanceof PartitionAttributesImpl) {
        ((PartitionAttributesImpl) a).addFixedPartitionAttributes(fpai);
    }
}
Also used : FixedPartitionAttributesImpl(org.apache.geode.internal.cache.FixedPartitionAttributesImpl) PartitionAttributesImpl(org.apache.geode.internal.cache.PartitionAttributesImpl) FixedPartitionAttributesImpl(org.apache.geode.internal.cache.FixedPartitionAttributesImpl)

Example 7 with FixedPartitionAttributesImpl

use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.

the class PartitionedRegionLoadModel method makeFPRPrimaryForThisNode.

/**
   * Move all primary from other to this
   */
private void makeFPRPrimaryForThisNode() {
    List<FixedPartitionAttributesImpl> FPAs = this.partitionedRegion.getFixedPartitionAttributesImpl();
    InternalDistributedMember targetId = this.partitionedRegion.getDistributionManager().getId();
    Member target = this.members.get(targetId);
    Set<Bucket> unsuccessfulAttempts = new HashSet<Bucket>();
    for (Bucket bucket : this.buckets) {
        if (bucket != null) {
            for (FixedPartitionAttributesImpl fpa : FPAs) {
                if (fpa.hasBucket(bucket.id) && fpa.isPrimary()) {
                    Member source = bucket.primary;
                    bucket.getPrimary();
                    if (source != target) {
                        // HACK: In case we don't know who is Primary at this time
                        // we just set source as target too for stat purposes
                        InternalDistributedMember srcDM = (source == null || source == INVALID_MEMBER) ? target.getDistributedMember() : source.getDistributedMember();
                        if (logger.isDebugEnabled()) {
                            logger.debug("PRLM#movePrimariesForFPR: For Bucket#{}, moving primary from source {} to target {}", bucket.getId(), bucket.primary, target);
                        }
                        boolean successfulMove = this.operator.movePrimary(srcDM, target.getDistributedMember(), bucket.getId());
                        unsuccessfulAttempts.add(bucket);
                        // We have to move the primary otherwise there is some problem!
                        Assert.assertTrue(successfulMove, " Fixed partitioned region not able to move the primary!");
                        if (successfulMove) {
                            if (logger.isDebugEnabled()) {
                                logger.debug("PRLM#movePrimariesForFPR: For Bucket#{}, moving primary source {} to target {}", bucket.getId(), source, target);
                            }
                            bucket.setPrimary(target, bucket.getPrimaryLoad());
                        }
                    }
                }
            }
        }
    }
}
Also used : InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) FixedPartitionAttributesImpl(org.apache.geode.internal.cache.FixedPartitionAttributesImpl) HashSet(java.util.HashSet)

Example 8 with FixedPartitionAttributesImpl

use of org.apache.geode.internal.cache.FixedPartitionAttributesImpl in project geode by apache.

the class FixedPartitioningTestBase method checkFPR.

public static void checkFPR(String regionName) {
    region_FPR = (PartitionedRegion) cache.getRegion(regionName);
    PartitionedRegion colocatedRegion = (PartitionedRegion) cache.getRegion(region_FPR.getColocatedWith());
    List<FixedPartitionAttributesImpl> childFPAs = region_FPR.getFixedPartitionAttributesImpl();
    List<FixedPartitionAttributesImpl> parentFPAs = colocatedRegion.getFixedPartitionAttributesImpl();
    assertEquals(parentFPAs, childFPAs);
}
Also used : PartitionedRegion(org.apache.geode.internal.cache.PartitionedRegion) FixedPartitionAttributesImpl(org.apache.geode.internal.cache.FixedPartitionAttributesImpl)

Aggregations

FixedPartitionAttributesImpl (org.apache.geode.internal.cache.FixedPartitionAttributesImpl)8 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)4 HashSet (java.util.HashSet)2 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)2 FixedPartitionAttributes (org.apache.geode.cache.FixedPartitionAttributes)1 PartitionAttributes (org.apache.geode.cache.PartitionAttributes)1 RegionAttributes (org.apache.geode.cache.RegionAttributes)1 PartitionAttributesImpl (org.apache.geode.internal.cache.PartitionAttributesImpl)1 Bucket (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Bucket)1 Member (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Member)1 Move (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Move)1