@SuppressWarnings("DuplicatedCode")
    public void reset() {
        managedLedgerStats.reset();
        topicsCount = 0;
        subscriptionsCount = 0;
        producersCount = 0;
        consumersCount = 0;
        rateIn = 0;
        rateOut = 0;
        throughputIn = 0;
        throughputOut = 0;
        messageAckRate = 0;
        bytesInCounter = 0;
        msgInCounter = 0;

        bytesOutCounter = 0;
        msgOutCounter = 0;

        msgBacklog = 0;
        msgDelayed = 0;
        ongoingTxnCount = 0;
        abortedTxnCount = 0;
        committedTxnCount = 0;

        backlogQuotaLimit = 0;
        backlogQuotaLimitTime = -1;

        replicationStats.clear();
        subscriptionStats.clear();

        sizeBasedBacklogQuotaExceededEvictionCount = 0;
        timeBasedBacklogQuotaExceededEvictionCount = 0;

        compactionRemovedEventCount = 0;
        compactionSucceedCount = 0;
        compactionFailedCount = 0;
        compactionDurationTimeInMills = 0;
        compactionReadThroughput = 0;
        compactionWriteThroughput = 0;
        compactionCompactedEntriesCount = 0;
        compactionCompactedEntriesSize = 0;

        delayedMessageIndexSizeInBytes = 0;
        bucketDelayedIndexStats.clear();
    }
@Test
    public void testReset() {
        AggregatedNamespaceStats stats = new AggregatedNamespaceStats();
        stats.topicsCount = 8;
        stats.subscriptionsCount = 3;
        stats.producersCount = 1;
        stats.consumersCount = 8;
        stats.rateIn = 1.3;
        stats.rateOut = 3.5;
        stats.throughputIn = 3.2;
        stats.throughputOut = 5.8;
        stats.messageAckRate = 12;
        stats.bytesInCounter = 1234;
        stats.msgInCounter = 3889;
        stats.bytesOutCounter = 89775;
        stats.msgOutCounter = 28983;
        stats.msgBacklog = 39;
        stats.msgDelayed = 31;

        stats.ongoingTxnCount = 87;
        stats.abortedTxnCount = 74;
        stats.committedTxnCount = 34;

        stats.backlogQuotaLimit = 387;
        stats.backlogQuotaLimitTime = 8771;

        stats.replicationStats = new HashMap<>();
        stats.replicationStats.put("r", new AggregatedReplicationStats());

        stats.subscriptionStats = new HashMap<>();
        stats.subscriptionStats.put("r", new AggregatedSubscriptionStats());

        stats.compactionRemovedEventCount = 124;
        stats.compactionSucceedCount = 487;
        stats.compactionFailedCount = 84857;
        stats.compactionDurationTimeInMills = 2384;
        stats.compactionReadThroughput = 355423;
        stats.compactionWriteThroughput = 23299;
        stats.compactionCompactedEntriesCount = 37522;
        stats.compactionCompactedEntriesSize = 8475;

        stats.compactionLatencyBuckets = new StatsBuckets(5);
        stats.compactionLatencyBuckets.addValue(3);

        stats.delayedMessageIndexSizeInBytes = 45223;

        stats.bucketDelayedIndexStats = new HashMap<>();
        stats.bucketDelayedIndexStats.put("t", new TopicMetricBean());

        stats.reset();

        assertEquals(stats.bytesOutCounter, 0);
        assertEquals(stats.topicsCount, 0);
        assertEquals(stats.subscriptionsCount, 0);
        assertEquals(stats.producersCount, 0);
        assertEquals(stats.consumersCount, 0);
        assertEquals(stats.rateIn, 0);
        assertEquals(stats.rateOut, 0);
        assertEquals(stats.throughputIn, 0);
        assertEquals(stats.throughputOut, 0);
        assertEquals(stats.messageAckRate, 0);
        assertEquals(stats.bytesInCounter, 0);
        assertEquals(stats.msgInCounter, 0);
        assertEquals(stats.bytesOutCounter, 0);
        assertEquals(stats.msgOutCounter, 0);

        assertEquals(stats.managedLedgerStats.storageSize, 0);

        assertEquals(stats.msgBacklog, 0);
        assertEquals(stats.msgDelayed, 0);

        assertEquals(stats.ongoingTxnCount, 0);
        assertEquals(stats.abortedTxnCount, 0);
        assertEquals(stats.committedTxnCount, 0);

        assertEquals(stats.backlogQuotaLimit, 0);
        assertEquals(stats.backlogQuotaLimitTime, -1);

        assertEquals(stats.replicationStats.size(), 0);
        assertEquals(stats.subscriptionStats.size(), 0);

        assertEquals(stats.compactionRemovedEventCount, 0);
        assertEquals(stats.compactionSucceedCount, 0);
        assertEquals(stats.compactionFailedCount, 0);
        assertEquals(stats.compactionDurationTimeInMills, 0);
        assertEquals(stats.compactionReadThroughput, 0);
        assertEquals(stats.compactionWriteThroughput, 0);
        assertEquals(stats.compactionCompactedEntriesCount, 0);
        assertEquals(stats.compactionCompactedEntriesSize, 0);

        assertEquals(stats.compactionLatencyBuckets.getSum(), 0);

        assertEquals(stats.delayedMessageIndexSizeInBytes, 0);
        assertEquals(stats.bucketDelayedIndexStats.size(), 0);
    }