Source:
<code>public void run() { logger.info("Aggregating stats for local report"); try { long totalFetchAndAggregateStartTimeMs = time.milliseconds(); StatsSnapshot aggregatedSnapshot = new StatsSnapshot(0L, null); List<PartitionId> unreachablePartitions = new ArrayList<>(); Iterator<PartitionId> iterator = (new HashSet<>(partitionToReplicaMap.keySet())).iterator(); while (!cancelled && iterator.hasNext()) { PartitionId partitionId = iterator.next(); logger.info("Aggregating stats for local report started for store {}", partitionId); collectAndAggregate(aggregatedSnapshot, partitionId, unreachablePartitions); } List<String> unreachableStores = examineUnreachablePartitions(unreachablePartitions); if (!cancelled) { metrics.totalFetchAndAggregateTimeMs.update(time.milliseconds() - totalFetchAndAggregateStartTimeMs); StatsHeader statsHeader = new StatsHeader(StatsHeader.StatsDescription.STORED_DATA_SIZE, time.milliseconds(), partitionToReplicaMap.keySet().size(), partitionToReplicaMap.keySet().size() - unreachableStores.size(), unreachableStores); StatsWrapper statsWrapper = new StatsWrapper(statsHeader, aggregatedSnapshot); if (accountStatsMySqlStore != null) { accountStatsMySqlStore.publish(statsWrapper); } <START> publish(new StatsWrapper(statsHeader, aggregatedSnapshot)); <END> logger.info("Local stats snapshot published to {}", statsOutputFile.getAbsolutePath()); } } catch (Exception | Error e) { metrics.statsAggregationFailureCount.inc(); logger.error("Exception while aggregating stats for local report. Stats output file path - {}", statsOutputFile.getAbsolutePath(), e); } }</code><technical_language>minor: statsWrapper is modified in accountStatsMySqlStore.publish(), reuse in original publish() method</technical_language>

Target:
public void run() { logger.info("Aggregating stats for local report"); try { long totalFetchAndAggregateStartTimeMs = time.milliseconds(); StatsSnapshot aggregatedSnapshot = new StatsSnapshot(0L, null); List<PartitionId> unreachablePartitions = new ArrayList<>(); Iterator<PartitionId> iterator = (new HashSet<>(partitionToReplicaMap.keySet())).iterator(); while (!cancelled && iterator.hasNext()) { PartitionId partitionId = iterator.next(); logger.info("Aggregating stats for local report started for store {}", partitionId); collectAndAggregate(aggregatedSnapshot, partitionId, unreachablePartitions); } List<String> unreachableStores = examineUnreachablePartitions(unreachablePartitions); if (!cancelled) { metrics.totalFetchAndAggregateTimeMs.update(time.milliseconds() - totalFetchAndAggregateStartTimeMs); StatsHeader statsHeader = new StatsHeader(StatsHeader.StatsDescription.STORED_DATA_SIZE, time.milliseconds(), partitionToReplicaMap.keySet().size(), partitionToReplicaMap.keySet().size() - unreachableStores.size(), unreachableStores); StatsWrapper statsWrapper = new StatsWrapper(statsHeader, aggregatedSnapshot); if (accountStatsMySqlStore != null) { accountStatsMySqlStore.publish(statsWrapper); } publish(statsWrapper); logger.info("Local stats snapshot published to {}", statsOutputFile.getAbsolutePath()); } } catch (Exception | Error e) { metrics.statsAggregationFailureCount.inc(); logger.error("Exception while aggregating stats for local report. Stats output file path - {}", statsOutputFile.getAbsolutePath(), e); } }