@SuppressWarnings("rawtypes") private void collectAllRegionsDetails(SystemMemberCacheJmxImpl cache,RegionSubRegionSnapshot regionSnapshot,Map<String,Map<String,?>> regionsInfo,Map<String,ObjectName> existingRegionMbeans) throws AdminException, OperationsException, MBeanException, ReflectionException {
  String fullPath=regionSnapshot.getFullPath();
  if (!fullPath.equals(PLACE_HOLDER_ROOT_REGION)) {
    fullPath=fullPath.substring(PLACE_HOLDER_ROOT_REGION.length() - 1);
    String name=regionSnapshot.getName();
    Integer entryCount=Integer.valueOf(regionSnapshot.getEntryCount());
    Map<String,Object> details=new TreeMap<String,Object>();
    details.put(REGION_NAME,name);
    details.put(REGION_PATH,fullPath);
    details.put(REGION_ENTRYCOUNT,entryCount);
    ObjectName regionObjectName=existingRegionMbeans.get(fullPath);
    if (regionObjectName == null) {
      regionObjectName=cache.manageRegion(fullPath);
    }
    Object attribute=getAttribute(regionObjectName,"scope",NOT_AVAILABLE);
    attribute=attribute != null ? attribute.toString() : attribute;
    details.put(REGION_SCOPE,attribute);
    attribute=getAttribute(regionObjectName,"dataPolicy",NOT_AVAILABLE);
    attribute=attribute != null ? attribute.toString() : attribute;
    details.put(REGION_DATAPOLICY,attribute);
    SubscriptionAttributes interestPolicyAttr=(SubscriptionAttributes)getAttribute(regionObjectName,"subscriptionAttributes",null);
    String interestPolicyStr=NOT_AVAILABLE;
    if (interestPolicyAttr != null) {
      InterestPolicy interestPolicy=interestPolicyAttr.getInterestPolicy();
      if (interestPolicy != null) {
        interestPolicyStr=interestPolicy.toString();
      }
    }
    details.put(REGION_INTERESTPOLICY,interestPolicyStr);
    attribute=getAttribute(regionObjectName,"diskWriteAttributes",NOT_AVAILABLE);
    attribute=attribute != null ? attribute.toString() : attribute;
    details.put(REGION_DISKATTRS,attribute);
    regionsInfo.put(fullPath,details);
  }
  Set subRegionSnapshots=regionSnapshot.getSubRegionSnapshots();
  for (Iterator iterator=subRegionSnapshots.iterator(); iterator.hasNext(); ) {
    RegionSubRegionSnapshot subRegion=(RegionSubRegionSnapshot)iterator.next();
    collectAllRegionsDetails(cache,subRegion,regionsInfo,existingRegionMbeans);
  }
}

@ SuppressWarnings ( "rawtypes" ) private void collectAllRegionsDetails ( SystemMemberCacheJmxImpl cache , RegionSubRegionSnapshot regionSnapshot , Map < String , Map < String , ? > > regionsInfo , Map < String , ObjectName > existingRegionMbeans ) throws AdminException , OperationsException , MBeanException , ReflectionException { String fullPath = regionSnapshot . getFullPath ( ) ; if ( ! fullPath . equals ( PLACE_HOLDER_ROOT_REGION ) ) { fullPath = fullPath . substring ( PLACE_HOLDER_ROOT_REGION . length ( ) - 1 ) ; String name = regionSnapshot . getName ( ) ; Integer entryCount = Integer . valueOf ( regionSnapshot . getEntryCount ( ) ) ; Map < String , Object > details = new TreeMap < String , Object > ( ) ; details . put ( REGION_NAME , name ) ; details . put ( REGION_PATH , fullPath ) ; details . put ( REGION_ENTRYCOUNT , entryCount ) ; ObjectName regionObjectName = existingRegionMbeans . get ( fullPath ) ; if ( regionObjectName == null ) { regionObjectName = cache . manageRegion ( fullPath ) ; } Object attribute = getAttribute ( regionObjectName , "scope" , NOT_AVAILABLE ) ; attribute = attribute != null ? attribute . toString ( ) : attribute ; details . put ( REGION_SCOPE , attribute ) ; attribute = getAttribute ( regionObjectName , "dataPolicy" , NOT_AVAILABLE ) ; attribute = attribute != null ? attribute . toString ( ) : attribute ; details . put ( REGION_DATAPOLICY , attribute ) ; SubscriptionAttributes interestPolicyAttr = ( SubscriptionAttributes ) getAttribute ( regionObjectName , "subscriptionAttributes" , null ) ; String interestPolicyStr = NOT_AVAILABLE ; if ( interestPolicyAttr != null ) { InterestPolicy interestPolicy = interestPolicyAttr . getInterestPolicy ( ) ; if ( interestPolicy != null ) { interestPolicyStr = interestPolicy . toString ( ) ; } } details . put ( REGION_INTERESTPOLICY , interestPolicyStr ) ; attribute = getAttribute ( regionObjectName , "diskWriteAttributes" , NOT_AVAILABLE ) ; attribute = attribute != null ? attribute . toString ( ) : attribute ; details . put ( REGION_DISKATTRS , attribute ) ; regionsInfo . put ( fullPath , details ) ; } Set subRegionSnapshots = regionSnapshot . getSubRegionSnapshots ( ) ; for ( Iterator iterator = subRegionSnapshots . iterator ( ) ; iterator . hasNext ( ) ; ) { RegionSubRegionSnapshot subRegion = ( RegionSubRegionSnapshot ) iterator . next ( ) ; collectAllRegionsDetails ( cache , subRegion , regionsInfo , existingRegionMbeans ) ; } }
collects all the region details from the regionsubregionsnapshot instance passed and the cache mbean . checks in the set of existingregionmbeans before initializing region mbeans if there are not initialized yet .
