lhotari commented on a change in pull request #9832:
URL: https://github.com/apache/pulsar/pull/9832#discussion_r589201685
##########
File path:
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
##########
@@ -1256,16 +1256,27 @@ protected void internalSetSubscribeRate(SubscribeRate
subscribeRate) {
}
}
+ protected void internalDeleteSubscribeRate() {
+ validateSuperUserAccess();
+ try {
+ final String path = path(POLICIES, namespaceName.toString());
+ updatePolicies(path, (policies) -> {
+
policies.clusterSubscribeRate.remove(pulsar().getConfiguration().getClusterName());
+ return policies;
+ });
+ log.info("[{}] Successfully delete the subscribeRate for cluster
on namespace {}", clientAppId(),
+ namespaceName);
+ } catch (Exception e) {
+ log.error("[{}] Failed to delete the subscribeRate for cluster on
namespace {}", clientAppId(),
+ namespaceName, e);
+ throw new RestException(e);
+ }
+ }
+
protected SubscribeRate internalGetSubscribeRate() {
validateNamespacePolicyOperation(namespaceName, PolicyName.RATE,
PolicyOperation.READ);
Policies policies = getNamespacePolicies(namespaceName);
- SubscribeRate subscribeRate =
policies.clusterSubscribeRate.get(pulsar().getConfiguration().getClusterName());
- if (subscribeRate != null) {
- return subscribeRate;
- } else {
- throw new RestException(Status.NOT_FOUND,
- "Subscribe-rate is not configured for cluster " +
pulsar().getConfiguration().getClusterName());
- }
+ return
policies.clusterSubscribeRate.get(pulsar().getConfiguration().getClusterName());
Review comment:
I referring to the unsafe mutation on line 1265
`policies.clusterSubscribeRate.remove(pulsar().getConfiguration().getClusterName())`
and the unsafe access on line 1279
`policies.clusterSubscribeRate.get(pulsar().getConfiguration().getClusterName())`.
Perhaps I'm missing something here. Do you consider this thread safe?
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]