Pair<AggregatedAccountStorageStats, AggregatedAccountStorageStats> aggregateHostAccountStorageStatsWrappers(
      AccountStorageStatsIterator accountStorageStatsIterator) throws IOException {

    Map<Long, Map<Short, Map<Short, ContainerStorageStats>>> combinedHostAccountStorageStatsMap = new HashMap<>();
    Map<Long, Map<Short, Map<Short, ContainerStorageStats>>> selectedHostAccountStorageStatsMap = new HashMap<>();
    Map<Long, Long> partitionTimestampMap = new HashMap<>();
    Map<Long, Long> partitionPhysicalStorageMap = new HashMap<>();

    while (accountStorageStatsIterator.hasNext()) {
      Pair<String, HostAccountStorageStatsWrapper> statsWrapperEntry = accountStorageStatsIterator.next();
      if (statsWrapperEntry.getSecond() == null) {
        continue;
      }
      String hostname = statsWrapperEntry.getFirst();
      HostAccountStorageStatsWrapper hostAccountStorageStatsWrapper = statsWrapperEntry.getSecond();
      HostAccountStorageStats hostAccountStorageStats = hostAccountStorageStatsWrapper.getStats();
      HostAccountStorageStats hostAccountStorageStatsCopy1 = new HostAccountStorageStats(hostAccountStorageStats);
      HostAccountStorageStats hostAccountStorageStatsCopy2 = new HostAccountStorageStats(hostAccountStorageStats);
      combineRawHostAccountStorageStatsMap(combinedHostAccountStorageStatsMap,
          hostAccountStorageStatsCopy1.getStorageStats());
      selectRawHostAccountStorageStatsMap(selectedHostAccountStorageStatsMap,
          hostAccountStorageStatsCopy2.getStorageStats(), partitionTimestampMap, partitionPhysicalStorageMap,
          hostAccountStorageStatsWrapper.getHeader().getTimestamp(), hostname);
    }
    if (logger.isTraceEnabled()) {
      logger.trace("Combined raw HostAccountStorageStats {}",
          mapper.writeValueAsString(combinedHostAccountStorageStatsMap));
      logger.trace("Selected raw HostAccountStorageStats {}",
          mapper.writeValueAsString(selectedHostAccountStorageStatsMap));
    }

    AggregatedAccountStorageStats combinedAggregated =
        new AggregatedAccountStorageStats(aggregateHostAccountStorageStats(combinedHostAccountStorageStatsMap));
    AggregatedAccountStorageStats selectedAggregated =
        new AggregatedAccountStorageStats(aggregateHostAccountStorageStats(selectedHostAccountStorageStatsMap));
    if (logger.isTraceEnabled()) {
      logger.trace("Aggregated combined {}", mapper.writeValueAsString(combinedAggregated));
      logger.trace("Aggregated selected {}", mapper.writeValueAsString(selectedAggregated));
    }
    return new Pair<>(combinedAggregated, selectedAggregated);
  }
Aggregate all {@link HostAccountStorageStatsWrapper} to generate two {@link AggregatedAccountStorageStats}s.
First {@link AggregatedAccountStorageStats} is the sum of all {@link HostAccountStorageStatsWrapper}s.
The second {@link AggregatedAccountStorageStats} is an aggregated storage stats for all replicas of each partition.
@param accountStorageStatsIterator An iterator for AccountStorageStatsIterator
@return A {@link Pair} of {@link AggregatedAccountStorageStats}.
@throws IOException
ambry-clustermap/src/main/java/com/github/ambry/clustermap/MySqlClusterAggregator.java