nodece commented on code in PR #17383:
URL: https://github.com/apache/pulsar/pull/17383#discussion_r960225925
##########
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java:
##########
@@ -1462,57 +1462,29 @@ protected CompletableFuture<DispatchRate>
internalGetReplicatorDispatchRateAsync
policies ->
policies.replicatorDispatchRate.get(pulsar().getConfiguration().getClusterName()));
}
- protected void internalSetBacklogQuota(BacklogQuotaType backlogQuotaType,
BacklogQuota backlogQuota) {
- validateNamespacePolicyOperation(namespaceName, PolicyName.BACKLOG,
PolicyOperation.WRITE);
- validatePoliciesReadOnlyAccess();
- final BacklogQuotaType quotaType = backlogQuotaType != null ?
backlogQuotaType
- : BacklogQuotaType.destination_storage;
- try {
- Policies policies = namespaceResources().getPolicies(namespaceName)
- .orElseThrow(() -> new RestException(Status.NOT_FOUND,
"Namespace policies does not exist"));
- RetentionPolicies r = policies.retention_policies;
- if (r != null) {
- Policies p = new Policies();
- p.backlog_quota_map.put(quotaType, backlogQuota);
- if (!checkQuotas(p, r)) {
- log.warn(
- "[{}] Failed to update backlog configuration"
- + " for namespace {}: conflicts with
retention quota",
- clientAppId(), namespaceName);
- throw new RestException(Status.PRECONDITION_FAILED,
- "Backlog Quota exceeds configured retention quota
for namespace."
- + " Please increase retention quota and
retry");
- }
- }
- policies.backlog_quota_map.put(quotaType, backlogQuota);
- namespaceResources().setPolicies(namespaceName, p -> policies);
- log.info("[{}] Successfully updated backlog quota map:
namespace={}, map={}", clientAppId(), namespaceName,
- jsonMapper().writeValueAsString(backlogQuota));
-
- } catch (RestException pfe) {
- throw pfe;
- } catch (Exception e) {
- log.error("[{}] Failed to update backlog quota map for namespace
{}", clientAppId(), namespaceName, e);
- throw new RestException(e);
- }
- }
-
- protected void internalRemoveBacklogQuota(BacklogQuotaType
backlogQuotaType) {
- validateNamespacePolicyOperation(namespaceName, PolicyName.BACKLOG,
PolicyOperation.WRITE);
- validatePoliciesReadOnlyAccess();
- final BacklogQuotaType quotaType = backlogQuotaType != null ?
backlogQuotaType
- : BacklogQuotaType.destination_storage;
- try {
- updatePolicies(namespaceName, policies -> {
- policies.backlog_quota_map.remove(quotaType);
+ protected CompletableFuture<Void>
internalSetBacklogQuotaAsync(BacklogQuotaType backlogQuotaType,
+
BacklogQuota quota) {
+ return namespaceResources().setPoliciesAsync(namespaceName, policies
-> {
Review Comment:
You didn't check if the policy exists.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]