Search in sources :

Example 1 with RegionSubRegionSnapshot

use of org.apache.geode.admin.RegionSubRegionSnapshot in project geode by apache.

the class RegionSubRegionsSizeResponse method populateSnapshot.

void populateSnapshot(DistributionManager dm) {
    if (this.cancelled) {
        return;
    }
    DistributedSystem sys = dm.getSystem();
    InternalCache cache = (InternalCache) CacheFactory.getInstance(sys);
    if (this.cancelled) {
        return;
    }
    RegionSubRegionSnapshot root = new RegionSubRegionSnapshot();
    /*
     * This root exists only on admin side as a root of all root-region just to create a tree-like
     * structure
     */
    root.setName("Root");
    root.setParent(null);
    root.setEntryCount(0);
    Set rootRegions = cache.rootRegions();
    this.snapshot = root;
    populateRegionSubRegions(root, rootRegions, cache);
}
Also used : RegionSubRegionSnapshot(org.apache.geode.admin.RegionSubRegionSnapshot) Set(java.util.Set) InternalCache(org.apache.geode.internal.cache.InternalCache) DistributedSystem(org.apache.geode.distributed.DistributedSystem)

Example 2 with RegionSubRegionSnapshot

use of org.apache.geode.admin.RegionSubRegionSnapshot in project geode by apache.

the class RegionSubRegionsSizeResponse method populateRegionSubRegions.

/**
   * Populates the collection of sub-region snapshots for the parentSnapShot with snapshots for the
   * regions given.
   * 
   * @param parentSnapShot RegionSubRegionSnapshot of a parent region
   * @param regions collection of sub-regions of the region represented by parentSnapShot
   * @param cache cache instance is used for to get the LogWriter instance to log exceptions if any
   */
private void populateRegionSubRegions(RegionSubRegionSnapshot parentSnapShot, Set regions, InternalCache cache) {
    if (this.cancelled) {
        return;
    }
    for (Object region : regions) {
        Region subRegion = (Region) region;
        try {
            RegionSubRegionSnapshot subRegionSnapShot = new RegionSubRegionSnapshot(subRegion);
            parentSnapShot.addSubRegion(subRegionSnapShot);
            Set subRegions = subRegion.subregions(false);
            populateRegionSubRegions(subRegionSnapShot, subRegions, cache);
        } catch (Exception e) {
            logger.debug("Failed to create snapshot for region: {}. Continuing with next region.", subRegion.getFullPath(), e);
        }
    }
}
Also used : RegionSubRegionSnapshot(org.apache.geode.admin.RegionSubRegionSnapshot) Set(java.util.Set) Region(org.apache.geode.cache.Region) IOException(java.io.IOException)

Aggregations

Set (java.util.Set)2 RegionSubRegionSnapshot (org.apache.geode.admin.RegionSubRegionSnapshot)2 IOException (java.io.IOException)1 Region (org.apache.geode.cache.Region)1 DistributedSystem (org.apache.geode.distributed.DistributedSystem)1 InternalCache (org.apache.geode.internal.cache.InternalCache)1