Class DispatchRateLimiter
java.lang.Object
org.apache.pulsar.broker.service.persistent.DispatchRateLimiter
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDispatchRateLimiter(BrokerService brokerService) DispatchRateLimiter(PersistentTopic topic, String subscriptionName, DispatchRateLimiter.Type type) DispatchRateLimiter(PersistentTopic topic, DispatchRateLimiter.Type type) -
Method Summary
Modifier and TypeMethodDescriptionvoidclose()voidconsumeDispatchQuota(long numberOfMessages, long byteSize) It acquires msg and bytes permits from rate-limiter and returns if acquired permits succeed.longreturns available byte-permit if msg-dispatch-throttling is enabled else it returns -1.longreturns available msg-permit if msg-dispatch-throttling is enabled else it returns -1.longGet configured byte dispatch-throttling rate.longGet configured msg dispatch-throttling rate.static Optional<org.apache.pulsar.common.policies.data.Policies>getPolicies(BrokerService brokerService, String topicName) Deprecated.static CompletableFuture<Optional<org.apache.pulsar.common.policies.data.Policies>>getPoliciesAsync(BrokerService brokerService, String topicName) static booleanisDispatchRateEnabled(org.apache.pulsar.common.policies.data.DispatchRate dispatchRate) booleanChecks if dispatch-rate limiting is enabled.voidUpdate dispatch-throttling-rate.voidupdateDispatchRate(org.apache.pulsar.common.policies.data.DispatchRate dispatchRate) Update dispatch rate by updating msg and byte rate-limiter.
-
Constructor Details
-
DispatchRateLimiter
-
DispatchRateLimiter
public DispatchRateLimiter(PersistentTopic topic, String subscriptionName, DispatchRateLimiter.Type type) -
DispatchRateLimiter
-
-
Method Details
-
getAvailableDispatchRateLimitOnMsg
public long getAvailableDispatchRateLimitOnMsg()returns available msg-permit if msg-dispatch-throttling is enabled else it returns -1.- Returns:
-
getAvailableDispatchRateLimitOnByte
public long getAvailableDispatchRateLimitOnByte()returns available byte-permit if msg-dispatch-throttling is enabled else it returns -1.- Returns:
-
consumeDispatchQuota
public void consumeDispatchQuota(long numberOfMessages, long byteSize) It acquires msg and bytes permits from rate-limiter and returns if acquired permits succeed.- Parameters:
numberOfMessages-byteSize-
-
isDispatchRateLimitingEnabled
public boolean isDispatchRateLimitingEnabled()Checks if dispatch-rate limiting is enabled.- Returns:
-
updateDispatchRate
public void updateDispatchRate()Update dispatch-throttling-rate. Topic-level has the highest priority, then namespace-level, and finally use dispatch-throttling-rate in broker-level -
getPoliciesAsync
public static CompletableFuture<Optional<org.apache.pulsar.common.policies.data.Policies>> getPoliciesAsync(BrokerService brokerService, String topicName) -
getPolicies
@Deprecated public static Optional<org.apache.pulsar.common.policies.data.Policies> getPolicies(BrokerService brokerService, String topicName) Deprecated.Avoid using the deprecated method #NamespaceResources.getPoliciesIfCached(NamespaceName)and blocking call. we can use #getPoliciesAsync(BrokerService, String)to instead of it. -
updateDispatchRate
public void updateDispatchRate(org.apache.pulsar.common.policies.data.DispatchRate dispatchRate) Update dispatch rate by updating msg and byte rate-limiter. If dispatch-rate is configured < 0 then it closes the rate-limiter and disables appropriate rate-limiter.- Parameters:
dispatchRate-
-
getDispatchRateOnMsg
public long getDispatchRateOnMsg()Get configured msg dispatch-throttling rate. Returns -1 if not configured- Returns:
-
getDispatchRateOnByte
public long getDispatchRateOnByte()Get configured byte dispatch-throttling rate. Returns -1 if not configured- Returns:
-
isDispatchRateEnabled
public static boolean isDispatchRateEnabled(org.apache.pulsar.common.policies.data.DispatchRate dispatchRate) -
close
public void close()
-
NamespaceResources.getPoliciesIfCached(NamespaceName)and blocking call.