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

nanda 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 932a0ac93b HDDS-10342. Reduce code duplication in MiniOzoneCluster 
builders (#6206)
932a0ac93b is described below

commit 932a0ac93bfb9143e0928111edf20c5768370d14
Author: Doroszlai, Attila <[email protected]>
AuthorDate: Tue Feb 20 07:07:23 2024 +0100

    HDDS-10342. Reduce code duplication in MiniOzoneCluster builders (#6206)
---
 .../apache/hadoop/ozone/MiniOzoneChaosCluster.java |   3 +-
 .../org/apache/hadoop/ozone/MiniOzoneCluster.java  |  41 +----
 .../apache/hadoop/ozone/MiniOzoneClusterImpl.java  | 170 +++++++++------------
 .../hadoop/ozone/MiniOzoneHAClusterImpl.java       |  69 +++------
 4 files changed, 95 insertions(+), 188 deletions(-)

diff --git 
a/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/MiniOzoneChaosCluster.java
 
b/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/MiniOzoneChaosCluster.java
index 26f896663b..76da4a5a8c 100644
--- 
a/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/MiniOzoneChaosCluster.java
+++ 
b/hadoop-ozone/fault-injection-test/mini-chaos-tests/src/test/java/org/apache/hadoop/ozone/MiniOzoneChaosCluster.java
@@ -313,8 +313,7 @@ public class MiniOzoneChaosCluster extends 
MiniOzoneHAClusterImpl {
         throw new IOException("Unable to build MiniOzoneCluster. ", ex);
       }
 
-      final List<HddsDatanodeService> hddsDatanodes = createHddsDatanodes(
-          scmService.getActiveServices(), null);
+      final List<HddsDatanodeService> hddsDatanodes = createHddsDatanodes();
 
       MiniOzoneChaosCluster cluster =
           new MiniOzoneChaosCluster(conf, omService, scmService, hddsDatanodes,
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
index 667f7448a1..c8e32a7917 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneCluster.java
@@ -93,7 +93,7 @@ public interface MiniOzoneCluster extends AutoCloseable {
   void waitForClusterToBeReady() throws TimeoutException, InterruptedException;
 
   /**
-   * Waits for atleast one RATIS pipeline of given factor to be reported in 
open
+   * Waits for at least one RATIS pipeline of given factor to be reported in 
open
    * state.
    *
    * @param factor replication factor
@@ -121,21 +121,6 @@ public interface MiniOzoneCluster extends AutoCloseable {
    */
   void waitTobeOutOfSafeMode() throws TimeoutException, InterruptedException;
 
-  /**
-   * Returns OzoneManager Service ID.
-   *
-   * @return Service ID String
-   */
-  String getOMServiceId();
-
-
-  /**
-   * Returns StorageContainerManager Service ID.
-   *
-   * @return Service ID String
-   */
-  String getSCMServiceId();
-
   /**
    * Returns {@link StorageContainerManager} associated with this
    * {@link MiniOzoneCluster} instance.
@@ -180,20 +165,12 @@ public interface MiniOzoneCluster extends AutoCloseable {
   /**
    * Returns StorageContainerLocationClient to communicate with
    * {@link StorageContainerManager} associated with the MiniOzoneCluster.
-   *
-   * @return StorageContainerLocation Client
-   * @throws IOException
    */
   StorageContainerLocationProtocolClientSideTranslatorPB
       getStorageContainerLocationClient() throws IOException;
 
   /**
    * Restarts StorageContainerManager instance.
-   *
-   * @param waitForDatanode
-   * @throws IOException
-   * @throws TimeoutException
-   * @throws InterruptedException
    */
   void restartStorageContainerManager(boolean waitForDatanode)
       throws InterruptedException, TimeoutException, IOException,
@@ -201,8 +178,6 @@ public interface MiniOzoneCluster extends AutoCloseable {
 
   /**
    * Restarts OzoneManager instance.
-   *
-   * @throws IOException
    */
   void restartOzoneManager() throws IOException;
 
@@ -266,11 +241,6 @@ public interface MiniOzoneCluster extends AutoCloseable {
    */
   void stop();
 
-  /**
-   * Start Scm.
-   */
-  void startScm() throws IOException;
-
   /**
    * Start DataNodes.
    */
@@ -373,13 +343,6 @@ public interface MiniOzoneCluster extends AutoCloseable {
       return this;
     }
 
-    /**
-     * Sets the certificate client.
-     *
-     * @param client
-     *
-     * @return MiniOzoneCluster.Builder
-     */
     public Builder setCertificateClient(CertificateClient client) {
       this.certClient = client;
       return this;
@@ -477,8 +440,6 @@ public interface MiniOzoneCluster extends AutoCloseable {
      * Constructs and returns MiniOzoneCluster.
      *
      * @return {@link MiniOzoneCluster}
-     *
-     * @throws IOException
      */
     public abstract MiniOzoneCluster build() throws IOException;
   }
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java
index dd9b83e66d..0e71063600 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneClusterImpl.java
@@ -81,6 +81,8 @@ import 
org.apache.hadoop.security.authentication.client.AuthenticationException;
 import org.apache.ozone.test.GenericTestUtils;
 
 import org.apache.commons.io.FileUtils;
+
+import static java.util.Collections.singletonList;
 import static 
org.apache.hadoop.hdds.protocol.proto.HddsProtos.NodeState.HEALTHY;
 import static 
org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_ADDRESS_KEY;
 import static 
org.apache.hadoop.hdds.recon.ReconConfigKeys.OZONE_RECON_DATANODE_ADDRESS_KEY;
@@ -113,6 +115,8 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
   private static final Logger LOG =
       LoggerFactory.getLogger(MiniOzoneClusterImpl.class);
 
+  private static final String[] NO_ARGS = new String[0];
+
   static {
     CodecBuffer.enableLeakDetection();
   }
@@ -132,15 +136,13 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
 
   /**
    * Creates a new MiniOzoneCluster with Recon.
-   *
-   * @throws IOException if there is an I/O error
    */
-  MiniOzoneClusterImpl(OzoneConfiguration conf,
-                       SCMConfigurator scmConfigurator,
-                       OzoneManager ozoneManager,
-                       StorageContainerManager scm,
-                       List<HddsDatanodeService> hddsDatanodes,
-                       ReconServer reconServer) {
+  private MiniOzoneClusterImpl(OzoneConfiguration conf,
+      SCMConfigurator scmConfigurator,
+      OzoneManager ozoneManager,
+      StorageContainerManager scm,
+      List<HddsDatanodeService> hddsDatanodes,
+      ReconServer reconServer) {
     this.conf = conf;
     this.ozoneManager = ozoneManager;
     this.scm = scm;
@@ -154,9 +156,6 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
    * StorageContainerManager. This is used by
    * {@link MiniOzoneHAClusterImpl} for starting multiple
    * OzoneManagers and StorageContainerManagers.
-   *
-   * @param conf
-   * @param hddsDatanodes
    */
   MiniOzoneClusterImpl(OzoneConfiguration conf, SCMConfigurator 
scmConfigurator,
       List<HddsDatanodeService> hddsDatanodes, ReconServer reconServer) {
@@ -180,18 +179,6 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
     this.conf = newConf;
   }
 
-  @Override
-  public String getOMServiceId() {
-    // Non-HA cluster doesn't have OM Service Id.
-    return null;
-  }
-
-  @Override
-  public String getSCMServiceId() {
-    // Non-HA cluster doesn't have OM Service Id.
-    return null;
-  }
-
   public void waitForSCMToBeReady() throws TimeoutException,
       InterruptedException {
     if (SCMHAUtils.isSCMHAEnabled(conf)) {
@@ -204,9 +191,6 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
     return scm;
   }
 
-  /**
-   * Waits for the Ozone cluster to be ready for processing requests.
-   */
   @Override
   public void waitForClusterToBeReady()
       throws TimeoutException, InterruptedException {
@@ -230,10 +214,6 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
     }, 1000, waitForClusterToBeReadyTimeout);
   }
 
-  /**
-   * Waits for atleast one RATIS pipeline of given factor to be reported in 
open
-   * state.
-   */
   @Override
   public void waitForPipelineTobeReady(HddsProtos.ReplicationFactor factor,
                                        int timeoutInMs) throws
@@ -246,24 +226,11 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
     }, 1000, timeoutInMs);
   }
 
-  /**
-   * Sets the timeout value after which
-   * {@link MiniOzoneClusterImpl#waitForClusterToBeReady} times out.
-   *
-   * @param timeoutInMs timeout value in milliseconds
-   */
   @Override
   public void setWaitForClusterToBeReadyTimeout(int timeoutInMs) {
     waitForClusterToBeReadyTimeout = timeoutInMs;
   }
 
-  /**
-   * Waits for SCM to be out of Safe Mode. Many tests can be run iff we are out
-   * of Safe mode.
-   *
-   * @throws TimeoutException
-   * @throws InterruptedException
-   */
   @Override
   public void waitTobeOutOfSafeMode()
       throws TimeoutException, InterruptedException {
@@ -404,8 +371,7 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       // wait for node to be removed from SCM healthy node list.
       waitForHddsDatanodeToStop(datanodeService.getDatanodeDetails());
     }
-    String[] args = new String[] {};
-    HddsDatanodeService service = new HddsDatanodeService(args);
+    HddsDatanodeService service = new HddsDatanodeService(NO_ARGS);
     service.setConfiguration(config);
     hddsDatanodes.add(i, service);
     startHddsDatanode(service);
@@ -461,15 +427,7 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
     stopRecon(reconServer);
   }
 
-  /**
-   * Start Scm.
-   */
-  @Override
-  public void startScm() throws IOException {
-    scm.start();
-  }
-
-  public void startHddsDatanode(HddsDatanodeService datanode) {
+  private void startHddsDatanode(HddsDatanodeService datanode) {
     try {
       datanode.setCertificateClient(getCAClient());
     } catch (IOException e) {
@@ -479,9 +437,6 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
     datanode.start();
   }
 
-  /**
-   * Start DataNodes.
-   */
   @Override
   public void startHddsDatanodes() {
     hddsDatanodes.forEach(this::startHddsDatanode);
@@ -501,7 +456,7 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
   @Override
   public void startRecon() {
     reconServer = new ReconServer();
-    reconServer.execute(new String[]{});
+    reconServer.execute(NO_ARGS);
   }
 
   @Override
@@ -587,25 +542,10 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       ReconServer reconServer = null;
       List<HddsDatanodeService> hddsDatanodes = Collections.emptyList();
       try {
-        scm = createSCM();
-        scm.start();
-        om = createOM();
-        if (certClient != null) {
-          om.setCertClient(certClient);
-        }
-        if (secretKeyClient != null) {
-          om.setSecretKeyClient(secretKeyClient);
-        }
-        om.start();
-
-        if (includeRecon) {
-          configureRecon();
-          reconServer = new ReconServer();
-          reconServer.execute(new String[] {});
-        }
-
-        hddsDatanodes = createHddsDatanodes(
-            Collections.singletonList(scm), reconServer);
+        scm = createAndStartSingleSCM();
+        om = createAndStartSingleOM();
+        reconServer = createRecon();
+        hddsDatanodes = createHddsDatanodes();
 
         MiniOzoneClusterImpl cluster = new MiniOzoneClusterImpl(conf,
             scmConfigurator, om, scm,
@@ -638,10 +578,17 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       }
     }
 
+    protected void setClients(OzoneManager om) throws IOException {
+      if (certClient != null) {
+        om.setCertClient(certClient);
+      }
+      if (secretKeyClient != null) {
+        om.setSecretKeyClient(secretKeyClient);
+      }
+    }
+
     /**
      * Initializes the configuration required for starting MiniOzoneCluster.
-     *
-     * @throws IOException
      */
     protected void initializeConfiguration() throws IOException {
       Path metaDir = Paths.get(path, "ozone-meta");
@@ -665,11 +612,18 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       FileUtils.deleteQuietly(new File(path));
     }
 
+    protected StorageContainerManager createAndStartSingleSCM()
+        throws AuthenticationException, IOException {
+      StorageContainerManager scm = createSCM();
+      scm.start();
+      configureScmDatanodeAddress(singletonList(scm));
+      return scm;
+    }
+
     /**
      * Creates a new StorageContainerManager instance.
      *
      * @return {@link StorageContainerManager}
-     * @throws IOException
      */
     protected StorageContainerManager createSCM()
         throws IOException, AuthenticationException {
@@ -688,6 +642,7 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       }
       return scm;
     }
+
     protected void initializeScmStorage(SCMStorageConfig scmStore)
         throws IOException {
       if (scmStore.getState() == StorageState.INITIALIZED) {
@@ -723,11 +678,17 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       omStorage.initialize();
     }
 
+    protected OzoneManager createAndStartSingleOM() throws 
AuthenticationException, IOException {
+      OzoneManager om = createOM();
+      setClients(om);
+      om.start();
+      return om;
+    }
+
     /**
      * Creates a new OzoneManager instance.
      *
      * @return {@link OzoneManager}
-     * @throws IOException
      */
     protected OzoneManager createOM()
         throws IOException, AuthenticationException {
@@ -737,14 +698,15 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       return OzoneManager.createOm(conf);
     }
 
-    protected String getSCMAddresses(List<StorageContainerManager> scms) {
+    private String getSCMAddresses(List<StorageContainerManager> scms) {
       StringBuilder stringBuilder = new StringBuilder();
       Iterator<StorageContainerManager> iter = scms.iterator();
 
       while (iter.hasNext()) {
         StorageContainerManager scm = iter.next();
-        stringBuilder.append(scm.getDatanodeRpcAddress().getHostString() +
-            ":" + scm.getDatanodeRpcAddress().getPort());
+        stringBuilder.append(scm.getDatanodeRpcAddress().getHostString())
+            .append(":")
+            .append(scm.getDatanodeRpcAddress().getPort());
         if (iter.hasNext()) {
           stringBuilder.append(",");
         }
@@ -753,23 +715,38 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       return stringBuilder.toString();
     }
 
+    protected void configureScmDatanodeAddress(List<StorageContainerManager> 
scms) {
+      conf.setStrings(ScmConfigKeys.OZONE_SCM_NAMES, getSCMAddresses(scms));
+    }
+
+    protected ReconServer createRecon() {
+      ReconServer reconServer = null;
+      if (includeRecon) {
+        configureRecon();
+        reconServer = new ReconServer();
+        reconServer.execute(NO_ARGS);
+
+        OzoneStorageContainerManager reconScm =
+            reconServer.getReconStorageContainerManager();
+        conf.set(OZONE_RECON_ADDRESS_KEY,
+            reconScm.getDatanodeRpcAddress().getHostString() + ":" +
+                reconScm.getDatanodeRpcAddress().getPort());
+      }
+      return reconServer;
+    }
+
     /**
      * Creates HddsDatanodeService(s) instance.
      *
      * @return List of HddsDatanodeService
-     * @throws IOException
      */
-    protected List<HddsDatanodeService> createHddsDatanodes(
-        List<StorageContainerManager> scms, ReconServer reconServer)
+    protected List<HddsDatanodeService> createHddsDatanodes()
         throws IOException {
-      String scmAddress = getSCMAddresses(scms);
-      String[] args = new String[] {};
-      conf.setStrings(ScmConfigKeys.OZONE_SCM_NAMES, scmAddress);
       List<HddsDatanodeService> hddsDatanodes = new ArrayList<>();
       for (int i = 0; i < numOfDatanodes; i++) {
         OzoneConfiguration dnConf = new OzoneConfiguration(conf);
         configureDatanodePorts(dnConf);
-        String datanodeBaseDir = path + "/datanode-" + Integer.toString(i);
+        String datanodeBaseDir = path + "/datanode-" + i;
         Path metaDir = Paths.get(datanodeBaseDir, "meta");
         List<String> dataDirs = new ArrayList<>();
         List<String> reservedSpaceList = new ArrayList<>();
@@ -795,15 +772,8 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
             reservedSpaceString);
         dnConf.set(OzoneConfigKeys.DFS_CONTAINER_RATIS_DATANODE_STORAGE_DIR,
             ratisDir.toString());
-        if (reconServer != null) {
-          OzoneStorageContainerManager reconScm =
-              reconServer.getReconStorageContainerManager();
-          dnConf.set(OZONE_RECON_ADDRESS_KEY,
-              reconScm.getDatanodeRpcAddress().getHostString() + ":" +
-                  reconScm.getDatanodeRpcAddress().getPort());
-        }
 
-        HddsDatanodeService datanode = new HddsDatanodeService(args);
+        HddsDatanodeService datanode = new HddsDatanodeService(NO_ARGS);
         datanode.setConfiguration(dnConf);
         hddsDatanodes.add(datanode);
       }
@@ -859,7 +829,7 @@ public class MiniOzoneClusterImpl implements 
MiniOzoneCluster {
       conf.setFromObject(new ReplicationConfig().setPort(getFreePort()));
     }
 
-    protected void configureRecon() throws IOException {
+    protected void configureRecon() {
       ConfigurationProvider.resetConfiguration();
 
       File tempNewFolder = new File(path, "recon");
diff --git 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
index ceade72e7d..928ae907c6 100644
--- 
a/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
+++ 
b/hadoop-ozone/integration-test/src/test/java/org/apache/hadoop/ozone/MiniOzoneHAClusterImpl.java
@@ -80,11 +80,6 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
   private static final int RATIS_RPC_TIMEOUT = 1000; // 1 second
   public static final int NODE_FAILURE_TIMEOUT = 2000; // 2 seconds
 
-  /**
-   * Creates a new MiniOzoneCluster.
-   *
-   * @throws IOException if there is an I/O error
-   */
   public MiniOzoneHAClusterImpl(
       OzoneConfiguration conf,
       SCMConfigurator scmConfigurator,
@@ -99,19 +94,8 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
     this.clusterMetaPath = clusterPath;
   }
 
-  @Override
-  public String getOMServiceId() {
-    return omhaService.getServiceId();
-  }
-
-  @Override
-  public String getSCMServiceId() {
-    return scmhaService.getServiceId();
-  }
-
   /**
    * Returns the first OzoneManager from the list.
-   * @return
    */
   @Override
   public OzoneManager getOzoneManager() {
@@ -353,12 +337,12 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
   public static class Builder extends MiniOzoneClusterImpl.Builder {
 
     private static final String OM_NODE_ID_PREFIX = "omNode-";
-    private List<OzoneManager> activeOMs = new ArrayList<>();
-    private List<OzoneManager> inactiveOMs = new ArrayList<>();
+    private final List<OzoneManager> activeOMs = new ArrayList<>();
+    private final List<OzoneManager> inactiveOMs = new ArrayList<>();
 
     private static final String SCM_NODE_ID_PREFIX = "scmNode-";
-    private List<StorageContainerManager> activeSCMs = new ArrayList<>();
-    private List<StorageContainerManager> inactiveSCMs = new ArrayList<>();
+    private final List<StorageContainerManager> activeSCMs = new ArrayList<>();
+    private final List<StorageContainerManager> inactiveSCMs = new 
ArrayList<>();
 
     /**
      * Creates a new Builder.
@@ -397,21 +381,16 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
       initOMRatisConf();
       SCMHAService scmService;
       OMHAService omService;
-      ReconServer reconServer = null;
+      ReconServer reconServer;
       try {
         scmService = createSCMService();
         omService = createOMService();
-        if (includeRecon) {
-          configureRecon();
-          reconServer = new ReconServer();
-          reconServer.execute(new String[] {});
-        }
+        reconServer = createRecon();
       } catch (AuthenticationException ex) {
         throw new IOException("Unable to build MiniOzoneCluster. ", ex);
       }
 
-      final List<HddsDatanodeService> hddsDatanodes = createHddsDatanodes(
-          scmService.getActiveServices(), reconServer);
+      final List<HddsDatanodeService> hddsDatanodes = createHddsDatanodes();
 
       MiniOzoneHAClusterImpl cluster = new MiniOzoneHAClusterImpl(conf,
           scmConfigurator, omService, scmService, hddsDatanodes, path,
@@ -458,8 +437,7 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
     protected OMHAService createOMService() throws IOException,
         AuthenticationException {
       if (omServiceId == null) {
-        OzoneManager om = createOM();
-        om.start();
+        OzoneManager om = createAndStartSingleOM();
         return new OMHAService(singletonList(om), null, null);
       }
 
@@ -487,9 +465,7 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
 
             OzoneManager.omInit(config);
             OzoneManager om = OzoneManager.createOm(config);
-            if (certClient != null) {
-              om.setCertClient(certClient);
-            }
+            setClients(om);
             omList.add(om);
 
             if (i <= numOfActiveOMs) {
@@ -526,8 +502,7 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
     protected SCMHAService createSCMService()
         throws IOException, AuthenticationException {
       if (scmServiceId == null) {
-        StorageContainerManager scm = createSCM();
-        scm.start();
+        StorageContainerManager scm = createAndStartSingleSCM();
         return new SCMHAService(singletonList(scm), null, null);
       }
 
@@ -592,6 +567,8 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
         }
       }
 
+      configureScmDatanodeAddress(activeSCMs);
+
       return new SCMHAService(activeSCMs, inactiveSCMs, scmServiceId);
     }
 
@@ -720,7 +697,7 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
 
     while (true) {
       try {
-        OzoneConfiguration newConf = addNewOMToConfig(getOMServiceId(),
+        OzoneConfiguration newConf = 
addNewOMToConfig(omhaService.getServiceId(),
             omNodeId);
 
         if (updateConfigs) {
@@ -777,7 +754,7 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
   /**
    * Update the configurations of the given list of OMs.
    */
-  public void updateOMConfigs(OzoneConfiguration newConf) {
+  private void updateOMConfigs(OzoneConfiguration newConf) {
     for (OzoneManager om : omhaService.getActiveServices()) {
       om.setConfiguration(newConf);
     }
@@ -870,17 +847,17 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
    * @param <Type>
    */
   static class MiniOzoneHAService<Type> {
-    private Map<String, Type> serviceMap;
-    private List<Type> services;
-    private String serviceId;
-    private String serviceName;
+    private final Map<String, Type> serviceMap;
+    private final List<Type> services;
+    private final String serviceId;
+    private final String serviceName;
 
     // Active services s denote OM/SCM services which are up and running
-    private List<Type> activeServices;
-    private List<Type> inactiveServices;
+    private final List<Type> activeServices;
+    private final List<Type> inactiveServices;
 
     // Function to extract the Id from service
-    private Function<Type, String> serviceIdProvider;
+    private final Function<Type, String> serviceIdProvider;
 
     MiniOzoneHAService(String name, List<Type> activeList,
         List<Type> inactiveList, String serviceId,
@@ -1006,8 +983,8 @@ public class MiniOzoneHAClusterImpl extends 
MiniOzoneClusterImpl {
 
   private static final class ExitManagerForOM extends ExitManager {
 
-    private MiniOzoneHAClusterImpl cluster;
-    private String omNodeId;
+    private final MiniOzoneHAClusterImpl cluster;
+    private final String omNodeId;
 
     private ExitManagerForOM(MiniOzoneHAClusterImpl cluster, String nodeId) {
       this.cluster = cluster;


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

Reply via email to