adoroszlai commented on code in PR #9863:
URL: https://github.com/apache/ozone/pull/9863#discussion_r2882831033


##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java:
##########
@@ -299,8 +302,11 @@ public String getNamespace() {
         }
       }
 
+      scmServiceId = HddsUtils.getScmServiceId(conf);
+
       reconfigurationHandler =
-          new ReconfigurationHandler("DN", conf, this::checkAdminPrivilege)
+          new DatanodeReconfigurationHandler("DN", conf, 
this::checkAdminPrivilege)
+              .registerPrefix(ConfUtils.addKeySuffixes(OZONE_SCM_ADDRESS_KEY, 
true, scmServiceId))

Review Comment:
   Shouldn't `registerPrefix` be called within `if (scmServiceId != null)` 
block?



##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/ozone/ha/ConfUtils.java:
##########
@@ -48,8 +48,20 @@ public static String addSuffix(String key, String suffix) {
    * Return configuration key of format key.suffix1.suffix2...suffixN.
    */
   public static String addKeySuffixes(String key, String... suffixes) {
+    return addKeySuffixes(key, false, suffixes);
+  }
+
+  /**
+   * Return configuration key of format key.suffix1.suffix2...suffixN with the 
option to
+   * add a trailing separator.
+   */
+  public static String addKeySuffixes(String key, boolean 
withTrailingSeparator, String... suffixes) {
     String keySuffix = concatSuffixes(suffixes);
-    return addSuffix(key, keySuffix);
+    String suffix = addSuffix(key, keySuffix);
+    if (withTrailingSeparator) {
+      suffix = suffix.concat(".");

Review Comment:
   I'd rather append `.` in `DatanodeReconfigurationHandler.registerPrefix`:
   
   - safety: ensure that `prefix` ends with `.` instead of relying on caller to 
add it
   - simplicity: new `addKeySuffixes` function just to append `.` seems overkill



##########
hadoop-hdds/framework/src/main/java/org/apache/hadoop/hdds/conf/DatanodeReconfigurationHandler.java:
##########
@@ -0,0 +1,62 @@
+/*
+ * 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
+ *
+ *      http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * 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 java.io.IOException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Set;
+import java.util.TreeSet;
+import java.util.concurrent.ConcurrentSkipListSet;
+import org.apache.ratis.util.function.CheckedConsumer;
+
+/**
+ * Reconfiguration handler for Datanode. Allows reconfiguration of some 
properties
+ * even if the properties are not registered in advance.
+ */
+public class DatanodeReconfigurationHandler extends ReconfigurationHandler {
+
+  private final Set<String> prefixProperties = new ConcurrentSkipListSet<>();
+
+  public DatanodeReconfigurationHandler(String name, OzoneConfiguration config,
+      CheckedConsumer<String, IOException> requireAdminPrivilege) {
+    super(name, config, requireAdminPrivilege);
+  }
+
+  public DatanodeReconfigurationHandler registerPrefix(String prefixProperty) {
+    prefixProperties.add(prefixProperty);
+    return this;
+  }
+
+  @Override
+  public boolean isPropertyReconfigurable(String property) {
+    for (String prefixProperty : prefixProperties) {
+      if (property.startsWith(prefixProperty)) {
+        return true;
+      }
+    }
+    return getReconfigurableProperties().contains(property);
+  }
+
+  @Override
+  public List<String> listReconfigureProperties() throws IOException {
+    Set<String> reconfigureSet = new 
TreeSet<>(super.listReconfigureProperties());
+    reconfigureSet.addAll(prefixProperties);

Review Comment:
   `TestDatanodeReconfiguration.reconfigurableProperties` needs to be updated.
   
   
https://github.com/apache/ozone/actions/runs/22660446735/job/65680352472?pr=9863#step:13:5791



##########
hadoop-hdds/container-service/src/main/java/org/apache/hadoop/ozone/HddsDatanodeService.java:
##########
@@ -575,6 +580,13 @@ public void stop() {
           }
         }
       }
+      if (reconfigurationHandler != null) {
+        try {
+          reconfigurationHandler.close();
+        } catch (IOException e) {
+          LOG.error("DatanodeReconfigurationHandler stop failed", e);
+        }
+      }

Review Comment:
   Nice find about `reconfigurationHandler` not being closed.  Should we fix it 
in separate patch, since it affects OM and SCM, too?
   
   nit: can simplify?
   
   ```java
   import org.apache.hadoop.hdds.utils.IOUtils;
   
   IOUtils.close(LOG, 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