/** returns a set of all DistributedRegions for allRegions processing */
 private Set<DistributedRegion> getAllRegions(DistributionManager dm) {
   // set the init level requirement so that we don't hang in CacheFactory.getInstance() (bug
   // 36175)
   int oldLevel = LocalRegion.setThreadInitLevelRequirement(LocalRegion.BEFORE_INITIAL_IMAGE);
   try {
     GemFireCacheImpl gfc = (GemFireCacheImpl) CacheFactory.getInstance(dm.getSystem());
     Set<DistributedRegion> result = new HashSet();
     for (LocalRegion r : gfc.getAllRegions()) {
       // it's important not to check if the cache is closing, so access
       // the isDestroyed boolean directly
       if (r instanceof DistributedRegion && !r.isDestroyed) {
         result.add((DistributedRegion) r);
       }
     }
     return result;
   } finally {
     LocalRegion.setThreadInitLevelRequirement(oldLevel);
   }
 }