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 2022/06/10 07:22:37 UTC

[GitHub] [ozone] JyotinderSingh commented on a diff in pull request #3499: HDDS-6695. Enable SCM Ratis by default for new clusters only

JyotinderSingh commented on code in PR #3499:
URL: https://github.com/apache/ozone/pull/3499#discussion_r894216055


##########
hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/DefaultConfigManager.java:
##########
@@ -0,0 +1,21 @@
+package org.apache.hadoop.hdds.conf;

Review Comment:
   Please include the apache license information in a block comment at the top of any new files you introduce.
   ```suggestion
   /*
    * 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;
   ```



##########
hadoop-hdds/server-scm/src/main/java/org/apache/hadoop/hdds/scm/ha/SCMHANodeDetails.java:
##########
@@ -158,7 +166,28 @@ public static SCMHANodeDetails loadSCMHAConfig(OzoneConfiguration conf)
         ScmConfigKeys.OZONE_SCM_DEFAULT_SERVICE_ID);
 
     LOG.info("ServiceID for StorageContainerManager is {}", localScmServiceId);
-
+    if(!storageConfig.isPresent()){
+      storageConfig = Optional.of(new SCMStorageConfig(conf));
+    }
+    Storage.StorageState state = storageConfig.get().getState();
+    boolean scmHAEnableDefault = state == Storage.StorageState.INITIALIZED
+        ? storageConfig.get().isSCMHAEnabled()
+        : SCMHAUtils.isSCMHAEnabled(conf);
+    boolean scmHAEnabled = SCMHAUtils.isSCMHAEnabled(conf);
+    if (Storage.StorageState.INITIALIZED == state
+        && Strings.isNotEmpty(conf.get(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY))
+        && scmHAEnabled != scmHAEnableDefault) {
+      throw new ConfigurationException(String.format("Invalid Config %s " +
+          "Provided ConfigValue: %s, Expected Config Value: %s",
+          ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, scmHAEnabled, scmHAEnableDefault));
+    } else if (Storage.StorageState.INITIALIZED == state
+        && scmHAEnabled != scmHAEnableDefault) {
+      LOG.warn("Invalid Config {}, Expected Config Value: {}, Default Config " +
+              "Value: {}", ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY,
+          scmHAEnableDefault, scmHAEnabled);
+    }

Review Comment:
   I feel this if-else block can be simplified as follows for readability
   ```suggestion
   String scmHAEnableConfig = conf.get(ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY);
   if (state.equals(Storage.StorageState.INITIALIZED) &&
   scmHAEnabled != scmHAEnableDefault)){
     if (Strings.isNotEmpty(scmHAEnableConfig)) {
       throw new ConfigurationException(String.format("Invalid Config %s " +
               "Provided ConfigValue: %s, Expected Config Value: %s",
           ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY, scmHAEnabled,
           scmHAEnableDefault));
     } else {
       LOG.warn(
           "Invalid Config {}, Expected Config Value: {}, Default Config " +
               "Value: {}", ScmConfigKeys.OZONE_SCM_HA_ENABLE_KEY,
           scmHAEnableDefault, scmHAEnabled);
     }
   }
   ```



-- 
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: issues-unsubscribe@ozone.apache.org

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