use of org.apache.pulsar.common.policies.data.SubscriptionPolicies in project pulsar by yahoo.
the class PersistentTopicsBase method internalRemoveSubscriptionLevelDispatchRate.
protected CompletableFuture<Void> internalRemoveSubscriptionLevelDispatchRate(String subName, boolean isGlobal) {
return getTopicPoliciesAsyncWithRetry(topicName, isGlobal).thenCompose(op -> {
if (!op.isPresent()) {
return CompletableFuture.completedFuture(null);
}
TopicPolicies topicPolicies = op.get();
SubscriptionPolicies sp = topicPolicies.getSubscriptionPolicies().get(subName);
if (sp == null) {
return CompletableFuture.completedFuture(null);
}
sp.setDispatchRate(null);
if (sp.checkEmpty()) {
// cleanup empty SubscriptionPolicies
topicPolicies.getSubscriptionPolicies().remove(subName, sp);
}
topicPolicies.setIsGlobal(isGlobal);
return pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName, op.get());
});
}
use of org.apache.pulsar.common.policies.data.SubscriptionPolicies in project incubator-pulsar by apache.
the class PersistentTopicsBase method internalRemoveSubscriptionLevelDispatchRate.
protected CompletableFuture<Void> internalRemoveSubscriptionLevelDispatchRate(String subName, boolean isGlobal) {
return getTopicPoliciesAsyncWithRetry(topicName, isGlobal).thenCompose(op -> {
if (!op.isPresent()) {
return CompletableFuture.completedFuture(null);
}
TopicPolicies topicPolicies = op.get();
SubscriptionPolicies sp = topicPolicies.getSubscriptionPolicies().get(subName);
if (sp == null) {
return CompletableFuture.completedFuture(null);
}
sp.setDispatchRate(null);
if (sp.checkEmpty()) {
// cleanup empty SubscriptionPolicies
topicPolicies.getSubscriptionPolicies().remove(subName, sp);
}
topicPolicies.setIsGlobal(isGlobal);
return pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName, op.get());
});
}
use of org.apache.pulsar.common.policies.data.SubscriptionPolicies in project incubator-pulsar by apache.
the class PersistentTopicsBase method internalSetSubscriptionLevelDispatchRate.
protected CompletableFuture<Void> internalSetSubscriptionLevelDispatchRate(String subName, DispatchRateImpl dispatchRate, boolean isGlobal) {
final DispatchRateImpl newDispatchRate = DispatchRateImpl.normalize(dispatchRate);
if (newDispatchRate == null) {
return CompletableFuture.completedFuture(null);
}
return getTopicPoliciesAsyncWithRetry(topicName, isGlobal).thenCompose(op -> {
TopicPolicies topicPolicies = op.orElseGet(TopicPolicies::new);
topicPolicies.setIsGlobal(isGlobal);
topicPolicies.getSubscriptionPolicies().computeIfAbsent(subName, k -> new SubscriptionPolicies()).setDispatchRate(newDispatchRate);
return pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName, topicPolicies);
});
}
use of org.apache.pulsar.common.policies.data.SubscriptionPolicies in project pulsar by yahoo.
the class PersistentTopicsBase method internalSetSubscriptionLevelDispatchRate.
protected CompletableFuture<Void> internalSetSubscriptionLevelDispatchRate(String subName, DispatchRateImpl dispatchRate, boolean isGlobal) {
final DispatchRateImpl newDispatchRate = DispatchRateImpl.normalize(dispatchRate);
if (newDispatchRate == null) {
return CompletableFuture.completedFuture(null);
}
return getTopicPoliciesAsyncWithRetry(topicName, isGlobal).thenCompose(op -> {
TopicPolicies topicPolicies = op.orElseGet(TopicPolicies::new);
topicPolicies.setIsGlobal(isGlobal);
topicPolicies.getSubscriptionPolicies().computeIfAbsent(subName, k -> new SubscriptionPolicies()).setDispatchRate(newDispatchRate);
return pulsar().getTopicPoliciesService().updateTopicPoliciesAsync(topicName, topicPolicies);
});
}
Aggregations