This is an automated email from the ASF dual-hosted git repository.

sshenoy pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/ozone.git


The following commit(s) were added to refs/heads/master by this push:
     new 2e19063c4e HDDS-10942. OM decommission config support for default 
serviceID. (#6834)
2e19063c4e is described below

commit 2e19063c4e42dbc2ec750f06127392b6e48ae236
Author: Aryan Gupta <[email protected]>
AuthorDate: Wed Jun 19 21:10:46 2024 +0530

    HDDS-10942. OM decommission config support for default serviceID. (#6834)
    
    Co-authored-by: Sadanand Shenoy <[email protected]>
---
 .../main/java/org/apache/hadoop/ozone/OmUtils.java | 37 ++++++++++++++++++----
 .../hadoop/ozone/om/TestAddRemoveOzoneManager.java |  7 ++--
 .../ozone/admin/om/DecommissionOMSubcommand.java   |  4 +--
 3 files changed, 35 insertions(+), 13 deletions(-)

diff --git 
a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java 
b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
index b4777c7a01..64aa9b1d24 100644
--- a/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
+++ b/hadoop-ozone/common/src/main/java/org/apache/hadoop/ozone/OmUtils.java
@@ -355,15 +355,38 @@ public final class OmUtils {
       String omServiceId) {
     String nodeIdsKey = ConfUtils.addSuffix(OZONE_OM_NODES_KEY, omServiceId);
     Collection<String> nodeIds = conf.getTrimmedStringCollection(nodeIdsKey);
-    String decommNodesKey = ConfUtils.addKeySuffixes(
-        OZONE_OM_DECOMMISSIONED_NODES_KEY, omServiceId);
-    Collection<String> decommNodeIds = conf.getTrimmedStringCollection(
-        decommNodesKey);
-    nodeIds.removeAll(decommNodeIds);
+    String decommissionNodesKeyWithServiceIdSuffix =
+        ConfUtils.addKeySuffixes(OZONE_OM_DECOMMISSIONED_NODES_KEY,
+            omServiceId);
+    Collection<String> decommissionedNodeIds =
+        getDecommissionedNodeIds(conf, 
decommissionNodesKeyWithServiceIdSuffix);
+    nodeIds.removeAll(decommissionedNodeIds);
 
     return nodeIds;
   }
 
+  /**
+   * Returns a collection of configured nodeId's that are to be decommissioned.
+   * Aggregate results from both config keys - with and without serviceId
+   * suffix. If ozone.om.service.ids contains a single service ID, then a 
config
+   * key without suffix defaults to nodeID associated with that serviceID.
+   */
+  public static Collection<String> getDecommissionedNodeIds(
+      ConfigurationSource conf,
+      String decommissionedNodesKeyWithServiceIdSuffix) {
+    HashSet<String> serviceIds = new HashSet<>(
+        conf.getTrimmedStringCollection(OZONE_OM_SERVICE_IDS_KEY));
+    HashSet<String> decommissionedNodeIds = new HashSet<>(
+        conf.getTrimmedStringCollection(
+            decommissionedNodesKeyWithServiceIdSuffix));
+    // If only one serviceID is configured, also check property without prefix
+    if (decommissionedNodeIds.isEmpty() && serviceIds.size() == 1) {
+      decommissionedNodeIds.addAll(
+          conf.getTrimmedStringCollection(OZONE_OM_DECOMMISSIONED_NODES_KEY));
+    }
+    return decommissionedNodeIds;
+  }
+
   /**
    * Get a collection of all omNodeIds (active and decommissioned) for a
    * gived omServiceId.
@@ -377,6 +400,7 @@ public final class OmUtils {
 
     nodeIds.addAll(conf.getTrimmedStringCollection(nodeIdsKey));
     nodeIds.addAll(conf.getTrimmedStringCollection(decommNodesKey));
+    
nodeIds.addAll(conf.getTrimmedStringCollection(OZONE_OM_DECOMMISSIONED_NODES_KEY));
 
     return nodeIds;
   }
@@ -819,10 +843,9 @@ public final class OmUtils {
     } else {
       omNodeIds = OmUtils.getActiveOMNodeIds(conf, omServiceId);
     }
-    Collection<String> decommissionedNodeIds = conf.getTrimmedStringCollection(
+    Collection<String> decommissionedNodeIds = getDecommissionedNodeIds(conf,
             ConfUtils.addKeySuffixes(OZONE_OM_DECOMMISSIONED_NODES_KEY,
                     omServiceId));
-
     if (omNodeIds.isEmpty()) {
       // If there are no nodeIds present, return empty list
       return Collections.emptyList();
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestAddRemoveOzoneManager.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestAddRemoveOzoneManager.java
index 463f44bf05..dfc3045be8 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestAddRemoveOzoneManager.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestAddRemoveOzoneManager.java
@@ -57,6 +57,7 @@ import org.junit.jupiter.api.Timeout;
 import org.slf4j.event.Level;
 
 import static org.apache.hadoop.ozone.OzoneConsts.SCM_DUMMY_SERVICE_ID;
+import static 
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_DECOMMISSIONED_NODES_KEY;
 import static 
org.apache.hadoop.ozone.om.OMConfigKeys.OZONE_OM_RATIS_SERVER_REQUEST_TIMEOUT_DEFAULT;
 import static org.apache.hadoop.ozone.om.TestOzoneManagerHA.createKey;
 import static org.assertj.core.api.Assertions.assertThat;
@@ -81,8 +82,6 @@ public class TestAddRemoveOzoneManager {
   private static final String OM_SERVICE_ID = "om-add-remove";
   private static final String VOLUME_NAME;
   private static final String BUCKET_NAME;
-  private static final String DECOMM_NODES_CONFIG_KEY =
-      "ozone.om.decommissioned.nodes." + OM_SERVICE_ID;
 
   static {
     VOLUME_NAME = "volume" + RandomStringUtils.randomNumeric(5);
@@ -387,9 +386,9 @@ public class TestAddRemoveOzoneManager {
    */
   private void decommissionOM(String decommNodeId) throws Exception {
     Collection<String> decommNodes = conf.getTrimmedStringCollection(
-        DECOMM_NODES_CONFIG_KEY);
+        OZONE_OM_DECOMMISSIONED_NODES_KEY);
     decommNodes.add(decommNodeId);
-    conf.set(DECOMM_NODES_CONFIG_KEY, StringUtils.join(",", decommNodes));
+    conf.set(OZONE_OM_DECOMMISSIONED_NODES_KEY, StringUtils.join(",", 
decommNodes));
     List<OzoneManager> activeOMs = new ArrayList<>();
     for (OzoneManager om : cluster.getOzoneManagersList()) {
       String omNodeId = om.getOMNodeId();
diff --git 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/DecommissionOMSubcommand.java
 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/DecommissionOMSubcommand.java
index d870edc70c..4b707c9208 100644
--- 
a/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/DecommissionOMSubcommand.java
+++ 
b/hadoop-ozone/tools/src/main/java/org/apache/hadoop/ozone/admin/om/DecommissionOMSubcommand.java
@@ -156,8 +156,8 @@ public class DecommissionOMSubcommand implements 
Callable<Void> {
   private void verifyConfigUpdatedOnAllOMs() throws IOException {
     String decommNodesKey = ConfUtils.addKeySuffixes(
         OZONE_OM_DECOMMISSIONED_NODES_KEY, omServiceId);
-    Collection<String> decommNodes = ozoneConf.getTrimmedStringCollection(
-        decommNodesKey);
+    Collection<String> decommNodes =
+        OmUtils.getDecommissionedNodeIds(ozoneConf, decommNodesKey);
     if (!decommNodes.contains(decommNodeId)) {
       throw new IOException("Please add the to be decommissioned OM "
           + decommNodeId + " to the " + decommNodesKey + " config in " +


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

Reply via email to