Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

When a request hits one of these limits we will simply reject it with a QUOTA_EXCEEDED exception. 

https://issues.apache.org/jira/browse/KAFKA-656Image Added

Conceptual Design:

This is psuedo-code obviously:, and incomplete, just starting to put some ideas down. 

Code Block
class RequestQuotaclass RequestQuota
{
    public bool checkRequestQuotas('client_ip', 'topic', 'bytes_to_read', 'bytes_to_write')
{
	Meter rps = Metrics.newMeter(class, 'requests-${topic}', 'requests', TimeUnit.SECONDS);
	rps.mark();


	if (rps.getOneMinuteRate() >= quotas.getRPSLimit('topic'))
	{
		return false;
	}
}
bool topicRPS(string topic)
{
	String ClientIP, String Topic, Long BytesToRead, Long BytesToWrite)
    {
        long topicRPSLImit = QuotaConfiguration.getTopicRPSLimit(Topic);
        if (! Quota.checkRPS(Topic, topicRPSLImit))
        {
            return false;
        }

        long clientRPSLImit = QuotaConfiguration.getclientRPSLimit(ClientIP);
        if (! Quota.checkRPS(ClientIP, clientRPSLImit))
        {
            return false;
        }

    }
}
class Quota
{
    public bool checkRPS(String targetEntity, long Limit)
    {
        Meter rps = Metrics.newMeter(this.class, 'requestsrps-${topic}'' + targetEntity, 'requests', TimeUnit.SECONDS);
	        rps.mark();
	
        if (Limit > 0 && rps.getOneMinuteRate() >= quotas.getRPSLimit('topic'))	{		Limit)
        {
            return false;	}}

        }
        return true;
    }
}