@Override
    // Return true if a report needs to be sent for the current round; false if it can be suppressed for this round.
    public boolean needToReportLocalUsage(long currentBytesUsed, long lastReportedBytes,
                                                    long currentMessagesUsed, long lastReportedMessages,
                                                    long lastReportTimeMSecsSinceEpoch) {
        // If we are about to go more than maxUsageReportSuppressRounds without reporting, send a report.
        long currentTimeMSecs = System.currentTimeMillis();
        long mSecsSinceLastReport = currentTimeMSecs - lastReportTimeMSecsSinceEpoch;
        if (mSecsSinceLastReport >= ResourceGroupService.maxIntervalForSuppressingReportsMSecs) {
            return true;
        }

        // If the percentage change (increase or decrease) in usage is more than a threshold for
        // either bytes or messages, send a report.
        final float toleratedDriftPercentage = ResourceGroupService.UsageReportSuppressionTolerancePercentage;
        if (currentBytesUsed > 0) {
            long diff = abs(currentBytesUsed - lastReportedBytes);
            float diffPercentage = (float) diff * 100 / lastReportedBytes;
            if (diffPercentage > toleratedDriftPercentage) {
                return true;
            }
        }

        if (currentMessagesUsed > 0) {
            long diff = abs(currentMessagesUsed - lastReportedMessages);
            float diffPercentage = (float) diff * 100 / lastReportedMessages;
            if (diffPercentage > toleratedDriftPercentage) {
                return true;
            }
        }

        return false;
    }
@Test
    public void testNeedToReportLocalUsage() {
        // If the percentage change (increase or decrease) in usage is more than 5% for
        // either bytes or messages, send a report.
        Assert.assertFalse(rqCalc.needToReportLocalUsage(1040, 1000, 104, 100, System.currentTimeMillis()));
        Assert.assertFalse(rqCalc.needToReportLocalUsage(950, 1000, 95, 100, System.currentTimeMillis()));
        Assert.assertTrue(rqCalc.needToReportLocalUsage(1060, 1000, 106, 100, System.currentTimeMillis()));
        Assert.assertTrue(rqCalc.needToReportLocalUsage(940, 1000, 94, 100, System.currentTimeMillis()));
    }