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


##########
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:
   Currently `TestDatanodeReconfiguration.reconfigurableProperties` has null 
`scmServiceId` so it should not show up in the `listReconfigureProperties` 
after the recent commits.



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