From 06c65826944c1446b3400b1230183decacf0fc3f Mon Sep 17 00:00:00 2001 From: Anu Engineer Date: Sun, 15 Oct 2017 13:10:27 -0700 Subject: [PATCH] HDFS-12585. Ozone: KSM UI: Add description for configs in UI. Contributed by Ajay Kumar. --- .../hadoop/conf/OzoneConfiguration.java | 113 ++++++++++++++++++ .../main/webapps/static/css/ozone-conf.css | 7 +- .../src/main/webapps/static/js/ozone-conf.js | 25 ++-- .../static/templates/ozone-config.html | 18 ++- 4 files changed, 138 insertions(+), 25 deletions(-) diff --git a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/OzoneConfiguration.java b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/OzoneConfiguration.java index 3b93a2e2ea9..bd7ecc3110d 100644 --- a/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/OzoneConfiguration.java +++ b/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/conf/OzoneConfiguration.java @@ -18,6 +18,16 @@ package org.apache.hadoop.conf; +import java.net.URL; +import java.util.ArrayList; +import java.util.List; +import javax.xml.bind.JAXBContext; +import javax.xml.bind.JAXBException; +import javax.xml.bind.Unmarshaller; +import javax.xml.bind.annotation.XmlAccessType; +import javax.xml.bind.annotation.XmlAccessorType; +import javax.xml.bind.annotation.XmlElement; +import javax.xml.bind.annotation.XmlRootElement; import org.apache.hadoop.classification.InterfaceAudience; /** @@ -39,4 +49,107 @@ public class OzoneConfiguration extends Configuration { public OzoneConfiguration(Configuration conf) { super(conf); } + + public List readPropertyFromXml(URL url) throws JAXBException { + JAXBContext context = JAXBContext.newInstance(XMLConfiguration.class); + Unmarshaller um = context.createUnmarshaller(); + + XMLConfiguration config = (XMLConfiguration) um.unmarshal(url); + return config.getProperties(); + } + + /** + * Class to marshall/un-marshall configuration from xml files. + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlRootElement(name = "configuration") + public static class XMLConfiguration { + + @XmlElement(name = "property", type = Property.class) + private List properties = new ArrayList<>(); + + public XMLConfiguration() { + } + + public XMLConfiguration(List properties) { + this.properties = properties; + } + + public List getProperties() { + return properties; + } + + public void setProperties(List properties) { + this.properties = properties; + } + } + + /** + * Class to marshall/un-marshall configuration properties from xml files. + */ + @XmlAccessorType(XmlAccessType.FIELD) + @XmlRootElement(name = "property") + public static class Property implements Comparable { + + private String name; + private String value; + private String tag; + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getValue() { + return value; + } + + public void setValue(String value) { + this.value = value; + } + + public String getTag() { + return tag; + } + + public void setTag(String tag) { + this.tag = tag; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } + + @Override + public int compareTo(Property o) { + if (this == o) { + return 0; + } + return this.getName().compareTo(o.getName()); + } + + @Override + public String toString() { + return this.getName() + " " + this.getValue() + this.getTag(); + } + + @Override + public int hashCode(){ + return this.getName().hashCode(); + } + + @Override + public boolean equals(Object obj) { + return (obj instanceof Property) && (((Property) obj).getName()).equals + (this.getName()); + } + } } \ No newline at end of file diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/css/ozone-conf.css b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/css/ozone-conf.css index 4eaf8b00330..6197598a90d 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/css/ozone-conf.css +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/css/ozone-conf.css @@ -54,4 +54,9 @@ } .sortorder.reverse:after { content: '\25bc'; // BLACK DOWN-POINTING TRIANGLE -} \ No newline at end of file +} + +.wrap-table{ + word-wrap: break-word; + table-layout: fixed; +} diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/js/ozone-conf.js b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/js/ozone-conf.js index 3028aac6308..a1cdab9dbcc 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/js/ozone-conf.js +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/js/ozone-conf.js @@ -33,25 +33,16 @@ app.controller('tagController', function($scope, $http,$filter) { $scope.loadAll(); }); - $scope.convertToArray = function(configAr) { - $scope.configArray = []; - console.log("Reloading "+configAr); - for (config in configAr) { - var newProp = {}; - newProp['prop'] = config; - newProp['value'] = configAr[config]; - $scope.configArray.push(newProp); - } + $scope.configArray = configAr; } - $scope.loadAll = function() { console.log("Displaying all configs"); $http.get("/conf?cmd=getPropertyByTag&tags=" + $scope.tags + "&group=ozone").then(function(response) { $scope.configs = response.data; $scope.convertToArray($scope.configs); - $scope.sortBy('prop'); + $scope.sortBy('name'); }); }; @@ -89,18 +80,16 @@ app.controller('tagController', function($scope, $http,$filter) { $http.get("/conf?cmd=getPropertyByTag&tags=" + filter + "&group=ozone").then(function(response) { var tmpConfig = response.data; console.log('filtering config for tag:'+filter); - array3 = {}; + array3 = []; - for(var prop1 in tmpConfig) { + for(var i1 in tmpConfig) { - for(var prop2 in $scope.configs) { - if(prop1 == prop2){ - array3[prop1] = tmpConfig[prop1]; - console.log('match found for :'+prop1+' '+prop2); + for(var i2 in $scope.configs) { + if(tmpConfig[i1].name == $scope.configs[i2].name){ + array3.push( tmpConfig[i1]); } } } - console.log('array3->'+array3); $scope.convertToArray(array3); }); }; diff --git a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/templates/ozone-config.html b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/templates/ozone-config.html index 72d2bb25999..1fe511f1889 100644 --- a/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/templates/ozone-config.html +++ b/hadoop-hdfs-project/hadoop-hdfs/src/main/webapps/static/templates/ozone-config.html @@ -72,27 +72,33 @@
- +
- - + - + +
- Property - + Property + + Value + Description + +
{{config.prop}}{{config.name}} {{config.value}}{{config.description}}