You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/02/07 09:40:50 UTC

[GitHub] [pulsar] Jason918 commented on a change in pull request #14087: Make ``BrokerBase#updateDynamicConfiguration`` pure async.

Jason918 commented on a change in pull request #14087:
URL: https://github.com/apache/pulsar/pull/14087#discussion_r800471905



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/admin/impl/BrokersBase.java
##########
@@ -235,31 +242,25 @@ public void deleteDynamicConfiguration(@PathParam("configName") String configNam
      * @param configValue
      *            : configuration value
      */
-    private synchronized void persistDynamicConfiguration(String configName, String configValue) {
-        try {
-            if (!BrokerService.validateDynamicConfiguration(configName, configValue)) {
-                throw new RestException(Status.PRECONDITION_FAILED, " Invalid dynamic-config value");
-            }
-            if (BrokerService.isDynamicConfiguration(configName)) {
-                dynamicConfigurationResources().setDynamicConfigurationWithCreate(old -> {
-                    Map<String, String> configurationMap = old.isPresent() ? old.get() : Maps.newHashMap();
-                    configurationMap.put(configName, configValue);
-                    return configurationMap;
-                });
-                LOG.info("[{}] Updated Service configuration {}/{}", clientAppId(), configName, configValue);
-            } else {
-                if (LOG.isDebugEnabled()) {
-                    LOG.debug("[{}] Can't update non-dynamic configuration {}/{}", clientAppId(), configName,
-                            configValue);
-                }
-                throw new RestException(Status.PRECONDITION_FAILED, " Can't update non-dynamic configuration");
+    private synchronized CompletableFuture<Void> persistDynamicConfigurationAsync(
+            String configName, String configValue) {
+        if (!BrokerService.validateDynamicConfiguration(configName, configValue)) {
+            return FutureUtil
+                    .failedFuture(new RestException(Status.PRECONDITION_FAILED, " Invalid dynamic-config value"));
+        }
+        if (BrokerService.isDynamicConfiguration(configName)) {
+            return dynamicConfigurationResources().setDynamicConfigurationWithCreateAsync(old -> {
+                Map<String, String> configurationMap = old.orElseGet(Maps::newHashMap);
+                configurationMap.put(configName, configValue);
+                return configurationMap;
+            });
+        } else {
+            if (LOG.isDebugEnabled()) {

Review comment:
       This debug log seems not necessary. We have error log in `updateDynamicConfiguration`.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org