Package org.apache.pulsar.broker.service
Interface PublishRateLimiter
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
PrecisPublishLimiter,PublishRateLimiterDisable,PublishRateLimiterImpl,ResourceGroupPublishLimiter
public interface PublishRateLimiter extends java.lang.AutoCloseable
-
-
Field Summary
Fields Modifier and Type Field Description static PublishRateLimiterDISABLED_RATE_LIMITER
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidcheckPublishRate()checks and update state of current publish and marks if it has exceeded the rate-limiting threshold.voidclose()Close the limiter.voidincrementPublishCount(int numOfMessages, long msgSizeInBytes)increments current publish count.booleanisPublishRateExceeded()returns true if current publish has reached the rate-limiting threshold.booleanresetPublishCount()reset current publish count.booleantryAcquire(int numbers, long bytes)try to acquire permit.voidupdate(org.apache.pulsar.common.policies.data.Policies policies, java.lang.String clusterName)updates rate-limiting threshold based on policies.voidupdate(org.apache.pulsar.common.policies.data.PublishRate maxPublishRate)updates rate-limiting threshold based on passed in rate limiter.
-
-
-
Field Detail
-
DISABLED_RATE_LIMITER
static final PublishRateLimiter DISABLED_RATE_LIMITER
-
-
Method Detail
-
checkPublishRate
void checkPublishRate()
checks and update state of current publish and marks if it has exceeded the rate-limiting threshold.
-
incrementPublishCount
void incrementPublishCount(int numOfMessages, long msgSizeInBytes)increments current publish count.- Parameters:
numOfMessages-msgSizeInBytes-
-
resetPublishCount
boolean resetPublishCount()
reset current publish count.- Returns:
-
isPublishRateExceeded
boolean isPublishRateExceeded()
returns true if current publish has reached the rate-limiting threshold.- Returns:
-
update
void update(org.apache.pulsar.common.policies.data.Policies policies, java.lang.String clusterName)updates rate-limiting threshold based on policies.- Parameters:
policies-clusterName-
-
update
void update(org.apache.pulsar.common.policies.data.PublishRate maxPublishRate)
updates rate-limiting threshold based on passed in rate limiter.- Parameters:
maxPublishRate-
-
tryAcquire
boolean tryAcquire(int numbers, long bytes)try to acquire permit.- Parameters:
numbers-bytes-
-
close
void close()
Close the limiter.- Specified by:
closein interfacejava.lang.AutoCloseable
-
-