xichen01 commented on code in PR #4794:
URL: https://github.com/apache/ozone/pull/4794#discussion_r1211300472


##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/conf/ReconfigurationHandler.java:
##########
@@ -0,0 +1,66 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.hadoop.hdds.conf;
+
+import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.conf.ReconfigurableBase;
+
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Map;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.UnaryOperator;
+
+import static java.util.function.UnaryOperator.identity;
+
+/**
+ * Keeps track of reconfigurable properties and the corresponding functions
+ * that implement reconfiguration.
+ */
+public class ReconfigurationHandler extends ReconfigurableBase {
+
+  private final Map<String, UnaryOperator<String>> properties =
+      new ConcurrentHashMap<>();
+
+  public ReconfigurationHandler(OzoneConfiguration config) {
+    setConf(config);
+  }
+
+  public ReconfigurationHandler register(
+      String property, UnaryOperator<String> reconfigureFunction) {
+    properties.put(property, reconfigureFunction);
+    return this;
+  }
+
+  @Override
+  protected Configuration getNewConf() {
+    return new OzoneConfiguration();
+  }
+
+  @Override
+  public List<String> getReconfigurableProperties() {
+    return new ArrayList<>(new TreeSet<>(properties.keySet()));
+  }
+
+  @Override
+  public String reconfigurePropertyImpl(String property, String newValue) {
+    return properties.getOrDefault(property, identity())
+        .apply(newValue);

Review Comment:
   maybe we only return the newValue String when the reconfig is execute 
normal, If the request `property` is not contain in the `properties`, we can 
throw an exception.



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/server/SCMClientProtocolServer.java:
##########
@@ -1306,20 +1311,20 @@ public String getServerName() throws IOException {
 
   @Override
   public void startReconfigure() throws IOException {

Review Comment:
   Maybe all OM/SCM/DN's 
`startReconfigure/getReconfigureStatus/listReconfigureProperties` can be 
implemented at `Class ReconfigurationHandler`



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


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to