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));
}
}
}
Aggregations