private void removeInvalidAggregatedAccountAndContainerStats(AggregatedAccountStorageStats currentStats)
      throws Exception {
    AggregatedAccountStorageStats existingStats = accountStatsStore.queryAggregatedAccountStorageStats();
    List<Pair<Short, Short>> toBeDeletedAccountAndContainers = new ArrayList<>();
    for (Map.Entry<Short, Map<Short, ContainerStorageStats>> accountEntry : existingStats.getStorageStats()
        .entrySet()) {
      short accountId = accountEntry.getKey();
      for (short containerId : accountEntry.getValue().keySet()) {
        if (!currentStats.getStorageStats().containsKey(accountId) || !currentStats.getStorageStats()
            .get(accountId)
            .containsKey(containerId)) {
          toBeDeletedAccountAndContainers.add(new Pair<>(accountId, containerId));
        }
      }
    }
    // delete the account/container stats that are no longer valid
    for (Pair<Short, Short> accountContainer : toBeDeletedAccountAndContainers) {
      accountStatsStore.deleteAggregatedAccountStatsForContainer(accountContainer.getFirst(),
          accountContainer.getSecond());
    }
  }
Instantiates {@link MySqlReportAggregatorTask}.
@param manager The {@link HelixManager} to retrieve all storage nodes.
@param relevantTimePeriodInMs relevant time period in ms within which values are considered to be valid. Values
                              outside of this period will be ignored.
@param statsReportType the type of stats report
@param accountStatsStore The {@link AccountStatsStore} to retrieve stats and store aggregated stats.
@param callback a callback which will be invoked when the aggregation report has been generated successfully.
@param clusterMapConfig the {@link ClusterMapConfig} associated with helix participant.
@param registry the {@link MetricRegistry}.
ambry-clustermap/src/main/java/com/github/ambry/clustermap/MySqlReportAggregatorTask.java