gaoran10 commented on a change in pull request #8446:
URL: https://github.com/apache/pulsar/pull/8446#discussion_r517383406



##########
File path: 
pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/NamespacesBase.java
##########
@@ -3000,6 +3001,47 @@ protected void internalSetOffloadPolicies(AsyncResponse 
asyncResponse, OffloadPo
         }
     }
 
+    protected void internalRemoveOffloadPolicies(AsyncResponse asyncResponse) {
+        validateNamespacePolicyOperation(namespaceName, PolicyName.OFFLOAD, 
PolicyOperation.WRITE);
+        validatePoliciesReadOnlyAccess();
+
+        try {
+            Stat nodeStat = new Stat();
+            final String path = path(POLICIES, namespaceName.toString());
+            byte[] content = globalZk().getData(path, null, nodeStat);
+            Policies policies = jsonMapper().readValue(content, 
Policies.class);
+
+            policies.offload_policies = null;
+            String updatedOffloadPolicies = 
jsonMapper().writeValueAsString(policies.offload_policies);
+            globalZk().setData(path, jsonMapper().writeValueAsBytes(policies), 
nodeStat.getVersion(),
+                    (rc, path1, ctx, stat) -> {
+                        if (rc == KeeperException.Code.OK.intValue()) {
+                            policiesCache().invalidate(path(POLICIES, 
namespaceName.toString()));
+                            log.info("[{}] Successfully updated offload 
configuration: namespace={}, map={}", clientAppId(),
+                                    namespaceName, updatedOffloadPolicies);
+                            asyncResponse.resume(Response.noContent().build());
+                        } else {
+                            String errorMsg = String.format(
+                                    "[%s] Failed to update offload 
configuration for namespace %s",
+                                    clientAppId(), namespaceName);
+                            if (rc == KeeperException.Code.NONODE.intValue()) {
+                                log.warn("{} : does not exist", errorMsg);
+                                asyncResponse.resume(new 
RestException(Status.NOT_FOUND, "Namespace does not exist"));
+                            } else if (rc == 
KeeperException.Code.BADVERSION.intValue()) {
+                                log.warn("{} : concurrent modification", 
errorMsg);
+                                asyncResponse.resume(new 
RestException(Status.CONFLICT, "Concurrent modification"));
+                            } else {
+                                
asyncResponse.resume(KeeperException.create(KeeperException.Code.get(rc), 
errorMsg));
+                            }
+                        }
+                    }, null);
+        } catch (Exception e) {
+            log.error("[{}] Failed to update offload configuration for 
namespace {}", clientAppId(), namespaceName,

Review comment:
       ```suggestion
               log.error("[{}] Failed to remove offload configuration for 
namespace {}", clientAppId(), namespaceName,
   ```




----------------------------------------------------------------
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]


Reply via email to