Search in sources :

Example 6 with Move

use of org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Move in project geode by apache.

the class PercentageMoveDirector method nextStep.

@Override
public boolean nextStep() {
    Member targetMember = model.getMember(target);
    Member sourceMember = model.getMember(source);
    if (targetMember == null) {
        throw new IllegalStateException(LocalizedStrings.PERCENTAGE_MOVE_DIRECTORY_TARGET_NOT_DATA_STORE.toLocalizedString(model.getName(), target));
    }
    if (targetMember.equals(sourceMember)) {
        throw new IllegalStateException(LocalizedStrings.PERCENTAGE_MOVE_TARGET_SAME_AS_SOURCE.toLocalizedString(model.getName(), target));
    }
    // if there is no largest bucket that we can move, we are done.
    if (orderedBuckets.isEmpty()) {
        return false;
    }
    // Take the largest bucket, and try to move that.
    Bucket bucket = orderedBuckets.last();
    float load = bucket.getLoad();
    // See if we can move this bucket to the taret node.
    if (targetMember.willAcceptBucket(bucket, sourceMember, model.enforceUniqueZones()).willAccept()) {
        if (model.moveBucket(new Move(sourceMember, targetMember, bucket))) {
            // If we had a successful move, decrement the load we should move.
            loadToMove -= load;
            // Remove all of the remaining buckets that are to big to move.
            // TODO - this could be O(log(n)), rather an O(n)
            Iterator<Bucket> itr = orderedBuckets.descendingIterator();
            while (itr.hasNext()) {
                Bucket next = itr.next();
                if (next.getLoad() > loadToMove) {
                    itr.remove();
                } else {
                    break;
                }
            }
        }
    }
    // In any case, remove the bucket from the list of buckets we'll try to move.
    orderedBuckets.remove(bucket);
    return true;
}
Also used : Bucket(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Bucket) Move(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Move) Member(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Member) InternalDistributedMember(org.apache.geode.distributed.internal.membership.InternalDistributedMember) DistributedMember(org.apache.geode.distributed.DistributedMember)

Example 7 with Move

use of org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Move in project geode by apache.

the class SatisfyRedundancyFPR method createFPRBucketsForThisNode.

public void createFPRBucketsForThisNode() {
    final Map<BucketRollup, Move> moves = new HashMap<BucketRollup, Move>();
    for (BucketRollup bucket : model.getLowRedundancyBuckets()) {
        Move move = model.findBestTargetForFPR(bucket, true);
        if (move == null && !model.enforceUniqueZones()) {
            move = model.findBestTargetForFPR(bucket, false);
        }
        if (move != null) {
            moves.put(bucket, move);
        } else {
            if (logger.isDebugEnabled()) {
                logger.debug("Skipping low redundancy bucket {} because no member will accept it", bucket);
            }
        }
    }
    // are different, there will not be any contention for lock
    for (Map.Entry<BucketRollup, Move> bucketMove : moves.entrySet()) {
        BucketRollup bucket = bucketMove.getKey();
        Move move = bucketMove.getValue();
        Member targetMember = move.getTarget();
        model.createRedundantBucket(bucket, targetMember);
    }
    model.waitForOperations();
}
Also used : HashMap(java.util.HashMap) Move(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Move) BucketRollup(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.BucketRollup) Map(java.util.Map) HashMap(java.util.HashMap) Member(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Member)

Example 8 with Move

use of org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Move in project geode by apache.

the class MovePrimaries method movePrimaries.

/**
   * Move a single primary from one member to another
   * 
   * @return if we are able to move a primary.
   */
private boolean movePrimaries() {
    Move bestMove = model.findBestPrimaryMove();
    if (bestMove == null) {
        return false;
    }
    model.movePrimary(bestMove);
    return true;
}
Also used : Move(org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Move)

Aggregations

Move (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Move)8 Member (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Member)5 InternalDistributedMember (org.apache.geode.distributed.internal.membership.InternalDistributedMember)3 Bucket (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.Bucket)3 BucketRollup (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.BucketRollup)3 DistributedMember (org.apache.geode.distributed.DistributedMember)2 HashMap (java.util.HashMap)1 Map (java.util.Map)1 Set (java.util.Set)1 FixedPartitionAttributesImpl (org.apache.geode.internal.cache.FixedPartitionAttributesImpl)1 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)1 RefusalReason (org.apache.geode.internal.cache.partitioned.rebalance.PartitionedRegionLoadModel.RefusalReason)1