codelipenghui commented on a change in pull request #2659: Add backlog quota configuration on topic URL: https://github.com/apache/pulsar/pull/2659#discussion_r220808092
########## File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/PersistentTopicsBase.java ########## @@ -1067,6 +1070,118 @@ protected PersistentOfflineTopicStats internalGetBacklog(boolean authoritative) return offlineTopicStats; } + protected void internalSetBacklogQuota(BacklogQuota.BacklogQuotaType backlogQuotaType, BacklogQuota backlogQuota) { + validateAdminAccessForTenant(namespaceName.getTenant()); + validatePoliciesReadOnlyAccess(); + if (topicName.isGlobal()) { + validateGlobalNamespaceOwnership(namespaceName); + } + if (backlogQuotaType == null) { + backlogQuotaType = BacklogQuotaType.destination_storage; + } + try { + Stat nodeStat = new Stat(); + String path = path(POLICIES, namespaceName.toString(), topicName.getLocalName()); + byte[] content = null; + try { + content = globalZk().getData(path, null, nodeStat); + } catch (KeeperException.NoNodeException e) { + log.warn("[{}] Fail to get backlog configuration for namespace {} topic {}, back to use namespace backlog default.", + clientAppId(), namespaceName.toString(), topicName.getLocalName()); + } + if (content == null) { + path = path(POLICIES, namespaceName.toString()); + content = globalZk().getData(path, null, null); + } + Policies policies = jsonMapper().readValue(content, Policies.class); Review comment: For now, copy the namespace policy as the topic policy. I think no need to copy the namespace policy, just set current configuration to the topic policy, otherwise change the namespace policy can't affect topics which has it's local policy(copy from the namespace before). ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org With regards, Apache Git Services