THIS IS A TEST INSTANCE. ALL YOUR CHANGES WILL BE LOST!!!!
...
2. We are already monitoring the global and the topic level bytesIn rate using Meter. Meter exposes a OneMinuteRate, which is an EWMA and is refreshed every 5 seconds by default. This should be good enough for measuring the observed bytesIn rate.
3. Introduce RequestQuotaTopicQuota.
Code Block |
---|
Object RequestQuotaTopicQuota { public bool recordQuota(Meter observedTotalRate, Long expectedTotalRate, Meter observedTopicRate, Long expectedTopicRate, Long incomingDataSize) { if (observedTotalRate.getOneMinuteRate() > expectedTotalRate && observedTopicRate.getOneMinuteRate() > expectedTopicRate) return false observedTotalRate.record(incomingDataSize) observedTopicRate.record(incomingDataSize) return true } } |
4. In Log.append(), we do
Code Block |
---|
if (Topic.Quota.recordQuota(....))
append to log
else
throw QuotaExceededException
|
...