Search in sources :

Example 1 with DumpB2NResponse

use of org.apache.geode.internal.cache.partitioned.DumpB2NRegion.DumpB2NResponse in project geode by apache.

the class PartitionedRegion method getBucketOwnersForValidation.

/**
   * Test Method: Fetch the given bucket's meta-data from each member hosting buckets
   * 
   * @param bucketId the identity of the bucket
   * @return list of arrays, each array element containing a {@link DistributedMember} and a
   *         {@link Boolean} the boolean denotes if the member is hosting the bucket and believes it
   *         is the primary
   * @throws ForceReattemptException if the caller should reattempt this request
   */
public List getBucketOwnersForValidation(int bucketId) throws ForceReattemptException {
    // bucketid 1 => "vm A", false | "vm B", false | "vm C", true | "vm D", false
    // bucketid 2 => List< Tuple(MemberId mem, Boolean isPrimary) >
    // remotely fetch each VM's bucket meta-data (versus looking at the bucket
    // advisor's data
    RuntimeException rte = null;
    List remoteInfos = null;
    for (int i = 0; i < 3; i++) {
        rte = null;
        DumpB2NResponse response = DumpB2NRegion.send(getRegionAdvisor().adviseDataStore(), this, bucketId, true);
        try {
            remoteInfos = new LinkedList(response.waitForPrimaryInfos());
        } catch (TimeoutException e) {
            rte = e;
            logger.info("DumpB2NRegion failed to get PR {}, bucket id {}'s info due to {}, retrying...", this.getFullPath(), bucketId, e.getMessage());
        }
    }
    if (rte != null) {
        logger.info("DumpB2NRegion retried 3 times", rte);
        throw rte;
    }
    // Include current VM in the status...
    if (getRegionAdvisor().getBucket(bucketId).isHosting()) {
        if (getRegionAdvisor().isPrimaryForBucket(bucketId)) {
            remoteInfos.add(new Object[] { getSystem().getDM().getId(), Boolean.TRUE, "" });
        } else {
            remoteInfos.add(new Object[] { getSystem().getDM().getId(), Boolean.FALSE, "" });
        }
    }
    return remoteInfos;
}
Also used : VersionedObjectList(org.apache.geode.internal.cache.tier.sockets.VersionedObjectList) CopyOnWriteArrayList(java.util.concurrent.CopyOnWriteArrayList) LinkedList(java.util.LinkedList) ArrayList(java.util.ArrayList) List(java.util.List) DumpB2NResponse(org.apache.geode.internal.cache.partitioned.DumpB2NRegion.DumpB2NResponse) LinkedList(java.util.LinkedList) TimeoutException(org.apache.geode.cache.TimeoutException)

Aggregations

ArrayList (java.util.ArrayList)1 LinkedList (java.util.LinkedList)1 List (java.util.List)1 CopyOnWriteArrayList (java.util.concurrent.CopyOnWriteArrayList)1 TimeoutException (org.apache.geode.cache.TimeoutException)1 DumpB2NResponse (org.apache.geode.internal.cache.partitioned.DumpB2NRegion.DumpB2NResponse)1 VersionedObjectList (org.apache.geode.internal.cache.tier.sockets.VersionedObjectList)1