Package org.apache.pulsar.broker.service
Class PrecisPublishLimiter
java.lang.Object
org.apache.pulsar.broker.service.PrecisPublishLimiter
- All Implemented Interfaces:
AutoCloseable,PublishRateLimiter
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected longprotected intFields inherited from interface org.apache.pulsar.broker.service.PublishRateLimiter
DISABLED_RATE_LIMITER -
Constructor Summary
ConstructorsConstructorDescriptionPrecisPublishLimiter(org.apache.pulsar.common.policies.data.Policies policies, String clusterName, org.apache.pulsar.common.util.RateLimitFunction rateLimitFunction) PrecisPublishLimiter(org.apache.pulsar.common.policies.data.PublishRate publishRate, org.apache.pulsar.common.util.RateLimitFunction rateLimitFunction) PrecisPublishLimiter(org.apache.pulsar.common.policies.data.PublishRate publishRate, org.apache.pulsar.common.util.RateLimitFunction rateLimitFunction, ScheduledExecutorService scheduledExecutorService) -
Method Summary
Modifier and TypeMethodDescriptionvoidchecks 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.booleanreturns true if current publish has reached the rate-limiting threshold.booleanreset current publish count.booleantryAcquire(int numbers, long bytes) try to acquire permit.voidupdates 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 Details
-
publishMaxMessageRate
protected volatile int publishMaxMessageRate -
publishMaxByteRate
protected volatile long publishMaxByteRate
-
-
Constructor Details
-
PrecisPublishLimiter
public PrecisPublishLimiter(org.apache.pulsar.common.policies.data.Policies policies, String clusterName, org.apache.pulsar.common.util.RateLimitFunction rateLimitFunction) -
PrecisPublishLimiter
public PrecisPublishLimiter(org.apache.pulsar.common.policies.data.PublishRate publishRate, org.apache.pulsar.common.util.RateLimitFunction rateLimitFunction) -
PrecisPublishLimiter
public PrecisPublishLimiter(org.apache.pulsar.common.policies.data.PublishRate publishRate, org.apache.pulsar.common.util.RateLimitFunction rateLimitFunction, ScheduledExecutorService scheduledExecutorService)
-
-
Method Details
-
checkPublishRate
public void checkPublishRate()Description copied from interface:PublishRateLimiterchecks and update state of current publish and marks if it has exceeded the rate-limiting threshold.- Specified by:
checkPublishRatein interfacePublishRateLimiter
-
incrementPublishCount
public void incrementPublishCount(int numOfMessages, long msgSizeInBytes) Description copied from interface:PublishRateLimiterincrements current publish count.- Specified by:
incrementPublishCountin interfacePublishRateLimiter
-
resetPublishCount
public boolean resetPublishCount()Description copied from interface:PublishRateLimiterreset current publish count.- Specified by:
resetPublishCountin interfacePublishRateLimiter- Returns:
-
isPublishRateExceeded
public boolean isPublishRateExceeded()Description copied from interface:PublishRateLimiterreturns true if current publish has reached the rate-limiting threshold.- Specified by:
isPublishRateExceededin interfacePublishRateLimiter- Returns:
-
update
Description copied from interface:PublishRateLimiterupdates rate-limiting threshold based on policies.- Specified by:
updatein interfacePublishRateLimiter
-
update
public void update(org.apache.pulsar.common.policies.data.PublishRate maxPublishRate) Description copied from interface:PublishRateLimiterupdates rate-limiting threshold based on passed in rate limiter.- Specified by:
updatein interfacePublishRateLimiter
-
tryAcquire
public boolean tryAcquire(int numbers, long bytes) Description copied from interface:PublishRateLimitertry to acquire permit.- Specified by:
tryAcquirein interfacePublishRateLimiter
-
close
public void close()Description copied from interface:PublishRateLimiterClose the limiter.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfacePublishRateLimiter
-