private HRegion getBiggestMemStoreRegion(SortedMap<Long, Collection<HRegion>> regionsBySize,
    Set<HRegion> excludedRegions, boolean checkStoreFileCount) {
    synchronized (regionsInQueue) {
      for (Map.Entry<Long, Collection<HRegion>> entry : regionsBySize.entrySet()) {
        for (HRegion region : entry.getValue()) {
          if (excludedRegions.contains(region)) {
            continue;
          }

          if (region.writestate.flushing || !region.writestate.writesEnabled) {
            continue;
          }

          if (checkStoreFileCount && isTooManyStoreFiles(region)) {
            continue;
          }
          return region;
        }
      }
    }
    return null;
  }
Returns Return memstore data size or null if <code>r</code> is null
hbase-server/src/main/java/org/apache/hadoop/hbase/regionserver/MemStoreFlusher.java