Search in sources :

Example 1 with SizeEntry

use of org.apache.geode.internal.cache.PartitionedRegion.SizeEntry in project geode by apache.

the class PartitionedRegionDataStore method getSizeLocallyForPrimary.

private Map<Integer, SizeEntry> getSizeLocallyForPrimary(Collection<Integer> bucketIds, boolean estimate) {
    Map<Integer, SizeEntry> mySizeMap;
    if (this.localBucket2RegionMap.isEmpty()) {
        return Collections.emptyMap();
    }
    mySizeMap = new HashMap<Integer, SizeEntry>(this.localBucket2RegionMap.size());
    BucketRegion r = null;
    for (Integer bucketId : bucketIds) {
        try {
            r = getInitializedBucketForId(null, bucketId);
            mySizeMap.put(bucketId, new SizeEntry(estimate ? r.sizeEstimate() : r.size(), r.getBucketAdvisor().isPrimary()));
        // if (getLogWriter().fineEnabled() && r.getBucketAdvisor().isPrimary()) {
        // r.verifyTombstoneCount();
        // }
        } catch (PrimaryBucketException skip) {
            // this bucket will be retried in PartitionedRegion.getSizeForHDFS() fixes bug 49033
            continue;
        } catch (ForceReattemptException skip) {
            continue;
        } catch (RegionDestroyedException skip) {
            continue;
        }
    }
    // while
    return mySizeMap;
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) SizeEntry(org.apache.geode.internal.cache.PartitionedRegion.SizeEntry)

Example 2 with SizeEntry

use of org.apache.geode.internal.cache.PartitionedRegion.SizeEntry in project geode by apache.

the class SizeMessage method operateOnPartitionedRegion.

@Override
protected boolean operateOnPartitionedRegion(DistributionManager dm, PartitionedRegion r, long startTime) throws CacheException, ForceReattemptException {
    Map<Integer, SizeEntry> sizes;
    if (r != null) {
        PartitionedRegionDataStore ds = r.getDataStore();
        if (ds != null) {
            // datastore exists
            if (this.bucketIds != null) {
                if (estimate) {
                    sizes = ds.getSizeEstimateLocallyForBuckets(this.bucketIds);
                } else {
                    sizes = ds.getSizeLocallyForBuckets(this.bucketIds);
                }
            } else {
                if (estimate) {
                    sizes = ds.getSizeEstimateForLocalPrimaryBuckets();
                } else {
                    sizes = ds.getSizeForLocalBuckets();
                }
            }
            r.getPrStats().endPartitionMessagesProcessing(startTime);
            SizeReplyMessage.send(getSender(), getProcessorId(), dm, sizes);
        } else // datastore exists
        {
            logger.warn(LocalizedMessage.create(LocalizedStrings.SizeMessage_SIZEMESSAGE_DATA_STORE_NOT_CONFIGURED_FOR_THIS_MEMBER));
            ReplyMessage.send(getSender(), getProcessorId(), new ReplyException(new ForceReattemptException(LocalizedStrings.SizeMessage_0_1_NO_DATASTORE_HERE_2.toLocalizedString())), dm, r.isInternalRegion());
        }
    } else {
        logger.warn(LocalizedMessage.create(LocalizedStrings.SizeMessage_SIZEMESSAGE_REGION_NOT_FOUND_FOR_THIS_MEMBER, regionId));
        ReplyMessage.send(getSender(), getProcessorId(), new ReplyException(new ForceReattemptException(LocalizedStrings.SizeMessage_0_COULD_NOT_FIND_PARTITIONED_REGION_WITH_ID_1.toLocalizedString(new Object[] { dm.getDistributionManagerId(), Integer.valueOf(regionId) }))), dm, r != null && r.isInternalRegion());
    }
    // response
    return false;
}
Also used : ForceReattemptException(org.apache.geode.internal.cache.ForceReattemptException) PartitionedRegionDataStore(org.apache.geode.internal.cache.PartitionedRegionDataStore) SizeEntry(org.apache.geode.internal.cache.PartitionedRegion.SizeEntry) ReplyException(org.apache.geode.distributed.internal.ReplyException)

Aggregations

SizeEntry (org.apache.geode.internal.cache.PartitionedRegion.SizeEntry)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)1 ReplyException (org.apache.geode.distributed.internal.ReplyException)1 ForceReattemptException (org.apache.geode.internal.cache.ForceReattemptException)1 PartitionedRegionDataStore (org.apache.geode.internal.cache.PartitionedRegionDataStore)1