Search in sources :

Example 6 with BucketProfile

use of org.apache.geode.internal.cache.BucketAdvisor.BucketProfile in project geode by apache.

the class PartitionedRegionQueryEvaluatorIntegrationTest method populateBucket2Node.

/**
   * This function populates bucket2Node region of the partition region
   * 
   * @param pr
   */
public void populateBucket2Node(PartitionedRegion pr, List nodes, int numOfBuckets) {
    assertEquals(0, pr.getRegionAdvisor().getCreatedBucketsCount());
    final RegionAdvisor ra = pr.getRegionAdvisor();
    int nodeListCnt = 0;
    Random ran = new Random();
    // Map tracking version for profile insertion purposes
    HashMap verMap = new HashMap();
    for (int i = 0; i < numOfBuckets; i++) {
        nodeListCnt = setNodeListCnt(nodeListCnt);
        for (int j = 0; j < nodeListCnt; j++) {
            BucketProfile bp = new BucketProfile();
            bp.peerMemberId = (InternalDistributedMember) nodes.get(ran.nextInt(nodes.size()));
            Integer v;
            if ((v = (Integer) verMap.get(bp.getDistributedMember())) != null) {
                bp.version = v.intValue() + 1;
                verMap.put(bp.getDistributedMember(), new Integer(bp.version));
            } else {
                verMap.put(bp.getDistributedMember(), new Integer(0));
                bp.version = 0;
            }
            bp.isHosting = true;
            if (j == 0) {
                bp.isPrimary = true;
            }
            bp.scope = Scope.DISTRIBUTED_ACK;
            boolean forceBadProfile = true;
            assertTrue(ra.getBucket(i).getBucketAdvisor().putProfile(bp, forceBadProfile));
        }
    }
}
Also used : Random(java.util.Random) RegionAdvisor(org.apache.geode.internal.cache.partitioned.RegionAdvisor) HashMap(java.util.HashMap) BucketProfile(org.apache.geode.internal.cache.BucketAdvisor.BucketProfile)

Aggregations

BucketProfile (org.apache.geode.internal.cache.BucketAdvisor.BucketProfile)6 HashMap (java.util.HashMap)3 HashSet (java.util.HashSet)2 Map (java.util.Map)2 Set (java.util.Set)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 ReplyProcessor21 (org.apache.geode.distributed.internal.ReplyProcessor21)2 BucketAdvisor (org.apache.geode.internal.cache.BucketAdvisor)2 ServerBucketProfile (org.apache.geode.internal.cache.BucketAdvisor.ServerBucketProfile)2 PartitionedRegion (org.apache.geode.internal.cache.PartitionedRegion)2 Random (java.util.Random)1 RegionAdvisor (org.apache.geode.internal.cache.partitioned.RegionAdvisor)1 LoggingThreadGroup (org.apache.geode.internal.logging.LoggingThreadGroup)1