You are viewing a plain text version of this content. The canonical link for it is here.
Posted to common-commits@hadoop.apache.org by bh...@apache.org on 2019/03/07 01:44:06 UTC

[hadoop] branch trunk updated: HDDS-1093. Configuration tab in OM/SCM ui is not displaying the correct values.

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

bharat pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/hadoop.git


The following commit(s) were added to refs/heads/trunk by this push:
     new a55fc36  HDDS-1093. Configuration tab in OM/SCM ui is not displaying the correct values.
a55fc36 is described below

commit a55fc362999f269efa1b6304438148aef3c03ed8
Author: Vivek Ratnavel Subramanian <vi...@gmail.com>
AuthorDate: Wed Mar 6 17:43:57 2019 -0800

    HDDS-1093. Configuration tab in OM/SCM ui is not displaying the correct values.
---
 .../apache/hadoop/util/NodeHealthScriptRunner.java |   2 +-
 .../hadoop/hdds/conf/OzoneConfiguration.java       |  29 +++++
 .../hadoop/hdds/conf/TestOzoneConfiguration.java   | 143 +++++++++++++++++++++
 .../org/apache/hadoop/hdds/conf/package-info.java  |  22 ++++
 .../src/main/resources/webapps/static/ozone.js     |   2 -
 .../hadoop/hdds/scm/node/TestSCMNodeManager.java   |   2 +-
 hadoop-ozone/dist/src/main/smoketest/test.sh       |   2 +-
 7 files changed, 197 insertions(+), 5 deletions(-)

diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java
index cf1e460..7c46c5b 100644
--- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java
+++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/util/NodeHealthScriptRunner.java
@@ -249,7 +249,7 @@ public class NodeHealthScriptRunner extends AbstractService {
   }
 
   /**
-   * Sets if the node is healhty or not considering disks' health also.
+   * Sets if the node is healthy or not considering disks' health also.
    * 
    * @param isHealthy
    *          if or not node is healthy
diff --git a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/OzoneConfiguration.java b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/OzoneConfiguration.java
index 43e6fe7..b7166c7 100644
--- a/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/OzoneConfiguration.java
+++ b/hadoop-hdds/common/src/main/java/org/apache/hadoop/hdds/conf/OzoneConfiguration.java
@@ -30,7 +30,9 @@ import javax.xml.bind.annotation.XmlElement;
 import javax.xml.bind.annotation.XmlRootElement;
 import java.net.URL;
 import java.util.ArrayList;
+import java.util.Enumeration;
 import java.util.List;
+import java.util.Properties;
 
 /**
  * Configuration for ozone.
@@ -161,4 +163,31 @@ public class OzoneConfiguration extends Configuration {
     Configuration.addDefaultResource("ozone-default.xml");
     Configuration.addDefaultResource("ozone-site.xml");
   }
+
+  /**
+   * The super class method getAllPropertiesByTag
+   * does not override values of properties
+   * if there is no tag present in the configs of
+   * newly added resources.
+   * @param tag
+   * @return Properties that belong to the tag
+   */
+  @Override
+  public Properties getAllPropertiesByTag(String tag) {
+    // Call getProps first to load the newly added resources
+    // before calling super.getAllPropertiesByTag
+    Properties updatedProps = getProps();
+    Properties propertiesByTag = super.getAllPropertiesByTag(tag);
+    Properties props = new Properties();
+    Enumeration properties = propertiesByTag.propertyNames();
+    while (properties.hasMoreElements()) {
+      Object propertyName =  properties.nextElement();
+      // get the current value of the property
+      Object value = updatedProps.getProperty(propertyName.toString());
+      if (value != null) {
+        props.put(propertyName, value);
+      }
+    }
+    return props;
+  }
 }
diff --git a/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/TestOzoneConfiguration.java b/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/TestOzoneConfiguration.java
new file mode 100644
index 0000000..ef6e5a8
--- /dev/null
+++ b/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/TestOzoneConfiguration.java
@@ -0,0 +1,143 @@
+/**
+ * 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
+ * <p>
+ * http://www.apache.org/licenses/LICENSE-2.0
+ * <p>
+ * 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 org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.fs.Path;
+import org.junit.Rule;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.Assert;
+import org.junit.rules.TemporaryFolder;
+
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
+/**
+ * Test class for OzoneConfiguration.
+ */
+public class TestOzoneConfiguration {
+
+  private Configuration conf;
+
+  @Rule
+  public TemporaryFolder tempConfigs = new TemporaryFolder();
+
+  @Before
+  public void setUp() throws Exception {
+    conf = new OzoneConfiguration();
+  }
+
+  private void startConfig(BufferedWriter out) throws IOException {
+    out.write("<?xml version=\"1.0\"?>\n");
+    out.write("<configuration>\n");
+  }
+
+  private void endConfig(BufferedWriter out) throws IOException {
+    out.write("</configuration>\n");
+    out.flush();
+    out.close();
+  }
+
+  @Test
+  public void testGetAllPropertiesByTags() throws Exception {
+    File coreDefault = tempConfigs.newFile("core-default-test.xml");
+    File coreSite = tempConfigs.newFile("core-site-test.xml");
+    try (BufferedWriter out = new BufferedWriter(new FileWriter(coreDefault))) {
+      startConfig(out);
+      appendProperty(out, "hadoop.tags.system", "YARN,HDFS,NAMENODE");
+      appendProperty(out, "hadoop.tags.custom", "MYCUSTOMTAG");
+      appendPropertyByTag(out, "dfs.cblock.trace.io", "false", "YARN");
+      appendPropertyByTag(out, "dfs.replication", "1", "HDFS");
+      appendPropertyByTag(out, "dfs.namenode.logging.level", "INFO",
+          "NAMENODE");
+      appendPropertyByTag(out, "dfs.random.key", "XYZ", "MYCUSTOMTAG");
+      endConfig(out);
+
+      Path fileResource = new Path(coreDefault.getAbsolutePath());
+      conf.addResource(fileResource);
+      Assert.assertEquals(conf.getAllPropertiesByTag("MYCUSTOMTAG")
+          .getProperty("dfs.random.key"), "XYZ");
+    }
+
+    try (BufferedWriter out = new BufferedWriter(new FileWriter(coreSite))) {
+      startConfig(out);
+      appendProperty(out, "dfs.random.key", "ABC");
+      appendProperty(out, "dfs.replication", "3");
+      appendProperty(out, "dfs.cblock.trace.io", "true");
+      endConfig(out);
+
+      Path fileResource = new Path(coreSite.getAbsolutePath());
+      conf.addResource(fileResource);
+    }
+
+    // Test if values are getting overridden even without tags being present
+    Assert.assertEquals("3", conf.getAllPropertiesByTag("HDFS")
+        .getProperty("dfs.replication"));
+    Assert.assertEquals("ABC", conf.getAllPropertiesByTag("MYCUSTOMTAG")
+        .getProperty("dfs.random.key"));
+    Assert.assertEquals("true", conf.getAllPropertiesByTag("YARN")
+        .getProperty("dfs.cblock.trace.io"));
+  }
+
+  private void appendProperty(BufferedWriter out, String name, String val)
+      throws IOException {
+    this.appendProperty(out, name, val, false);
+  }
+
+  private void appendProperty(BufferedWriter out, String name, String val,
+                              boolean isFinal) throws IOException {
+    out.write("<property>");
+    out.write("<name>");
+    out.write(name);
+    out.write("</name>");
+    out.write("<value>");
+    out.write(val);
+    out.write("</value>");
+    if (isFinal) {
+      out.write("<final>true</final>");
+    }
+    out.write("</property>\n");
+  }
+
+  private void appendPropertyByTag(BufferedWriter out, String name, String val,
+                                   String tags) throws IOException {
+    this.appendPropertyByTag(out, name, val, false, tags);
+  }
+
+  private void appendPropertyByTag(BufferedWriter out, String name, String val,
+                                   boolean isFinal,
+                                   String tag) throws IOException {
+    out.write("<property>");
+    out.write("<name>");
+    out.write(name);
+    out.write("</name>");
+    out.write("<value>");
+    out.write(val);
+    out.write("</value>");
+    if (isFinal) {
+      out.write("<final>true</final>");
+    }
+    out.write("<tag>");
+    out.write(tag);
+    out.write("</tag>");
+    out.write("</property>\n");
+  }
+}
diff --git a/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/package-info.java b/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/package-info.java
new file mode 100644
index 0000000..e72c902
--- /dev/null
+++ b/hadoop-hdds/common/src/test/java/org/apache/hadoop/hdds/conf/package-info.java
@@ -0,0 +1,22 @@
+/*
+ * 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.
+ */
+
+/**
+ * This package contains the OzoneConfiguration related tests.
+ */
+package org.apache.hadoop.hdds.conf;
\ No newline at end of file
diff --git a/hadoop-hdds/framework/src/main/resources/webapps/static/ozone.js b/hadoop-hdds/framework/src/main/resources/webapps/static/ozone.js
index c2ed2ad..a31078c 100644
--- a/hadoop-hdds/framework/src/main/resources/webapps/static/ozone.js
+++ b/hadoop-hdds/framework/src/main/resources/webapps/static/ozone.js
@@ -308,7 +308,6 @@
             ctrl.convertToArray(response.data);
             ctrl.configs = Object.values(ctrl.keyTagMap);
             ctrl.component = 'All';
-            console.log("ajay -> " + JSON.stringify(ctrl.configs));
             ctrl.sortBy('name');
           });
       };
@@ -326,7 +325,6 @@
 
           if (ctrl.component != 'All' && (item['tag'].indexOf(ctrl
               .component) < 0)) {
-            console.log(item['name'] + " false tag " + item['tag']);
             return false;
           }
 
diff --git a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java
index b810503..1e9e174 100644
--- a/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java
+++ b/hadoop-hdds/server-scm/src/test/java/org/apache/hadoop/hdds/scm/node/TestSCMNodeManager.java
@@ -518,7 +518,7 @@ public class TestSCMNodeManager {
 
       // 3.5 seconds have elapsed for stale node, so it moves into Stale.
       // 7 seconds have elapsed for dead node, so it moves into dead.
-      // 2 Seconds have elapsed for healthy node, so it stays in healhty state.
+      // 2 Seconds have elapsed for healthy node, so it stays in healthy state.
       healthyList = nodeManager.getNodes(HEALTHY);
       List<DatanodeDetails> staleList = nodeManager.getNodes(STALE);
       List<DatanodeDetails> deadList = nodeManager.getNodes(DEAD);
diff --git a/hadoop-ozone/dist/src/main/smoketest/test.sh b/hadoop-ozone/dist/src/main/smoketest/test.sh
index 5704404..582fbdf 100755
--- a/hadoop-ozone/dist/src/main/smoketest/test.sh
+++ b/hadoop-ozone/dist/src/main/smoketest/test.sh
@@ -45,7 +45,7 @@ wait_for_datanodes(){
 
          #Print it only if a number. Could be not a number if scm is not yet started
          if [[ "$datanodes" ]]; then
-            echo "$datanodes datanode is up and healhty (until now)"
+            echo "$datanodes datanode is up and healthy (until now)"
          fi
       fi
 


---------------------------------------------------------------------
To unsubscribe, e-mail: common-commits-unsubscribe@hadoop.apache.org
For additional commands, e-mail: common-commits-help@hadoop.apache.org