You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@ozone.apache.org by GitBox <gi...@apache.org> on 2021/02/16 11:22:38 UTC

[GitHub] [ozone] bshashikant commented on a change in pull request #1918: HDDS-4820. Add multiple SCM nodes to MiniOzoneCluster.

bshashikant commented on a change in pull request #1918:
URL: https://github.com/apache/ozone/pull/1918#discussion_r576734570



##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java
##########
@@ -23,13 +23,7 @@
 import java.nio.file.Files;
 import java.nio.file.Path;
 import java.nio.file.Paths;
-import java.util.ArrayList;
-import java.util.Collection;
-import java.util.Collections;
-import java.util.List;
-import java.util.Optional;
-import java.util.OptionalInt;
-import java.util.UUID;
+import java.util.*;

Review comment:
       Nit: Remove * imports.

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
##########
@@ -445,4 +605,89 @@ private void initHAConfig(int basePort) throws IOException {
       conf.set(omNodesKey, omNodesKeyValue.substring(1));
     }
   }
+
+  @FunctionalInterface
+  public interface CheckedConsumer<T> {
+    void apply(T t) throws IOException;
+  }
+
+  static class MiniOzoneHAService<Type> {
+    private Map<String, Type> serviceMap;
+    private List<Type> services;
+    private String serviceId;
+
+    // Active OMs denote OMs which are up and running
+    private List<Type> activeServices;
+    private List<Type> inactiveServices;
+
+    MiniOzoneHAService(List<Type> activeList, List<Type> inactiveList, String serviceId, Function<Type, String> idProvider) {
+      this.serviceMap = Maps.newHashMap();
+      if (activeList != null) {
+        for (Type service : activeList) {
+          this.serviceMap.put(idProvider.apply(service), service);
+        }
+      }
+      if (inactiveList != null) {
+        for (Type service : inactiveList) {
+          this.serviceMap.put(idProvider.apply(service), service);
+        }
+      }
+      this.services = new ArrayList<>(serviceMap.values());
+      this.activeServices = activeList;
+      this.inactiveServices = inactiveList;
+      this.serviceId = serviceId;
+
+      // If the serviceID is null, then this should be a non-HA cluster.
+      if (serviceId == null) {
+        Preconditions.checkArgument(services.size() <= 1);
+      }
+    }
+
+    public String getServiceId() {
+      return serviceId;
+    }
+
+    public List<Type> getServices() {
+      return services;
+    }
+
+    public boolean isOMActive(String id) {
+      return activeServices.contains(serviceMap.get(id));
+    }
+
+    public Type getServiceByIndex(int index) {
+      return this.services.get(index);
+    }
+
+    public Type getServiceById(String id) {
+      return this.serviceMap.get(id);
+    }
+
+    public void startInactiveService(String id, CheckedConsumer<Type> serviceStarter) throws IOException {
+      Type service = serviceMap.get(id);
+      if (!inactiveServices.contains(service)) {
+        throw new IOException("OM is already active.");

Review comment:
       I guess, the msg here should be more generic not specific to OM.

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
##########
@@ -445,4 +605,89 @@ private void initHAConfig(int basePort) throws IOException {
       conf.set(omNodesKey, omNodesKeyValue.substring(1));
     }
   }
+
+  @FunctionalInterface
+  public interface CheckedConsumer<T> {
+    void apply(T t) throws IOException;
+  }
+
+  static class MiniOzoneHAService<Type> {
+    private Map<String, Type> serviceMap;
+    private List<Type> services;
+    private String serviceId;
+
+    // Active OMs denote OMs which are up and running
+    private List<Type> activeServices;
+    private List<Type> inactiveServices;
+
+    MiniOzoneHAService(List<Type> activeList, List<Type> inactiveList, String serviceId, Function<Type, String> idProvider) {
+      this.serviceMap = Maps.newHashMap();
+      if (activeList != null) {
+        for (Type service : activeList) {
+          this.serviceMap.put(idProvider.apply(service), service);
+        }
+      }
+      if (inactiveList != null) {
+        for (Type service : inactiveList) {
+          this.serviceMap.put(idProvider.apply(service), service);
+        }
+      }
+      this.services = new ArrayList<>(serviceMap.values());
+      this.activeServices = activeList;
+      this.inactiveServices = inactiveList;
+      this.serviceId = serviceId;
+
+      // If the serviceID is null, then this should be a non-HA cluster.
+      if (serviceId == null) {
+        Preconditions.checkArgument(services.size() <= 1);
+      }
+    }
+
+    public String getServiceId() {
+      return serviceId;
+    }
+
+    public List<Type> getServices() {
+      return services;
+    }
+
+    public boolean isOMActive(String id) {

Review comment:
       isOMActive --> isServiceActive?

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
##########
@@ -408,10 +432,146 @@ protected void initOMRatisConf() {
       return omList;
     }
 
+    /**
+     * Start OM service with multiple OMs.
+     */
+    protected List<StorageContainerManager> createSCMService() throws IOException,
+        AuthenticationException {
+
+      List<StorageContainerManager> scmList = Lists.newArrayList();
+
+      int retryCount = 0;
+      int basePort = 12000;
+
+      while (true) {
+        try {
+          basePort = 12000 + RANDOM.nextInt(1000) * 4;
+          initSCMHAConfig(basePort);
+
+          for (int i = 1; i<= numOfSCMs; i++) {
+            // Set nodeId
+            String nodeId = SCM_NODE_ID_PREFIX + i;
+            String metaDirPath = path + "/" + nodeId;
+            OzoneConfiguration scmConfig = new OzoneConfiguration(conf);
+            scmConfig.set(OZONE_METADATA_DIRS, metaDirPath);
+            scmConfig.set(ScmConfigKeys.OZONE_SCM_NODE_ID_KEY, nodeId);
+            scmConfig.set(ScmConfigKeys.OZONE_SCM_HTTP_ADDRESS_KEY, "");
+            scmConfig.set(ScmConfigKeys.OZONE_SCM_HTTPS_ADDRESS_KEY, "");
+
+            // TODO: set SCM HA configs
+
+            configureSCM();
+            SCMStorageConfig scmStore = new SCMStorageConfig(scmConfig);

Review comment:
       Probably, its better to call ScmInit() instead of directly initialising the SCMStorage here. Similarly, for the other SCMs , we need to call scmBootStrap() once bootstrap is done.

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
##########
@@ -445,4 +605,89 @@ private void initHAConfig(int basePort) throws IOException {
       conf.set(omNodesKey, omNodesKeyValue.substring(1));
     }
   }
+
+  @FunctionalInterface
+  public interface CheckedConsumer<T> {
+    void apply(T t) throws IOException;
+  }
+
+  static class MiniOzoneHAService<Type> {
+    private Map<String, Type> serviceMap;
+    private List<Type> services;
+    private String serviceId;
+
+    // Active OMs denote OMs which are up and running

Review comment:
       Misleading comment.

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/scm/TestStorageContainerManagerHA.java
##########
@@ -0,0 +1,67 @@
+/**
+ * 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.ozone.scm;
+
+import org.apache.hadoop.hdds.scm.server.StorageContainerManager;
+import org.apache.hadoop.ozone.MiniOzoneCluster;
+import org.apache.hadoop.ozone.om.TestOzoneManagerHA;
+import org.junit.After;
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+
+import java.util.List;
+
+

Review comment:
       Need to add tests where SCM HA can be tested with/without OM HA and vice versa. This can be done as a part of subsequent jira's.

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
##########
@@ -445,4 +605,89 @@ private void initHAConfig(int basePort) throws IOException {
       conf.set(omNodesKey, omNodesKeyValue.substring(1));
     }
   }
+
+  @FunctionalInterface
+  public interface CheckedConsumer<T> {
+    void apply(T t) throws IOException;
+  }
+
+  static class MiniOzoneHAService<Type> {
+    private Map<String, Type> serviceMap;
+    private List<Type> services;
+    private String serviceId;
+
+    // Active OMs denote OMs which are up and running
+    private List<Type> activeServices;
+    private List<Type> inactiveServices;
+

Review comment:
       Can we add some documentation/comments here ???

##########
File path: hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/om/TestOzoneManagerHA.java
##########
@@ -164,17 +164,22 @@ public void init() throws Exception {
      */
     conf.set(OZONE_BLOCK_DELETING_SERVICE_INTERVAL, "10s");
     conf.set(OZONE_KEY_DELETING_LIMIT_PER_TASK, "2");
-    cluster = (MiniOzoneHAClusterImpl) MiniOzoneCluster.newHABuilder(conf)
-        .setClusterId(clusterId)
-        .setScmId(scmId)
-        .setOMServiceId(omServiceId)
-        .setNumOfOzoneManagers(numOfOMs)
-        .build();
+    MiniOzoneCluster.Builder builder = MiniOzoneCluster.newHABuilder(conf);
+    initMiniOzoneHACluster(builder);
+    cluster = (MiniOzoneHAClusterImpl) builder.build();
     cluster.waitForClusterToBeReady();
     objectStore = OzoneClientFactory.getRpcClient(omServiceId, conf)
         .getObjectStore();
   }
 
+  public void initMiniOzoneHACluster(MiniOzoneCluster.Builder builder) {
+    builder
+        .setClusterId(clusterId)
+        .setScmId(scmId)

Review comment:
       Setting SCM id is really required here??




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

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



---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@ozone.apache.org
For additional commands, e-mail: issues-help@ozone.apache.org