You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by sr...@apache.org on 2013/08/27 05:49:48 UTC

git commit: AMBARI-3031. Set mapreduce.admin.user.env in mapred-site.xml. (srimanth)

Updated Branches:
  refs/heads/branch-1.4 d9ee67276 -> 48959aa93


AMBARI-3031. Set mapreduce.admin.user.env in mapred-site.xml. (srimanth)


Project: http://git-wip-us.apache.org/repos/asf/incubator-ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-ambari/commit/48959aa9
Tree: http://git-wip-us.apache.org/repos/asf/incubator-ambari/tree/48959aa9
Diff: http://git-wip-us.apache.org/repos/asf/incubator-ambari/diff/48959aa9

Branch: refs/heads/branch-1.4
Commit: 48959aa93283b026c85f6fbea9e4f78059f83c2b
Parents: d9ee672
Author: Srimanth Gunturi <sg...@hortonworks.com>
Authored: Mon Aug 26 20:38:40 2013 -0700
Committer: Srimanth Gunturi <sg...@hortonworks.com>
Committed: Mon Aug 26 20:38:48 2013 -0700

----------------------------------------------------------------------
 .../MAPREDUCE2/configuration/mapred-site.xml    | 10 +++++
 .../MAPREDUCE2/configuration/mapred-site.xml    | 10 +++++
 .../controllers/main/service/info/configs.js    | 46 ++++++++++++++++++--
 3 files changed, 63 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/48959aa9/ambari-server/src/main/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml b/ambari-server/src/main/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml
index 5f95dc3..fad359e 100644
--- a/ambari-server/src/main/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDP/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml
@@ -369,4 +369,14 @@
     </description>
   </property>
 
+  <property>
+    <name>mapreduce.admin.user.env</name>
+    <value>LD_LIBRARY_PATH=/usr/lib/hadoop/lib/native:/usr/lib/hadoop/lib/native/`$JAVA_HOME/bin/java -d32 -version &amp;&gt; /dev/null;if [ $? -eq 0 ]; then echo Linux-i386-32; else echo Linux-amd64-64;fi`</value>
+    <description>
+      Additional execution environment entries for map and reduce task processes.
+      This is not an additive property. You must preserve the original value if
+      you want your map and reduce tasks to have access to native libraries (compression, etc)
+    </description>
+  </property>
+
 </configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/48959aa9/ambari-server/src/main/resources/stacks/HDPLocal/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml
----------------------------------------------------------------------
diff --git a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml
index 9a555fd..2f77361 100644
--- a/ambari-server/src/main/resources/stacks/HDPLocal/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml
+++ b/ambari-server/src/main/resources/stacks/HDPLocal/2.0.5/services/MAPREDUCE2/configuration/mapred-site.xml
@@ -369,4 +369,14 @@
     </description>
   </property>
 
+  <property>
+    <name>mapreduce.admin.user.env</name>
+    <value>LD_LIBRARY_PATH=/usr/lib/hadoop/lib/native:/usr/lib/hadoop/lib/native/`$JAVA_HOME/bin/java -d32 -version &amp;&gt; /dev/null;if [ $? -eq 0 ]; then echo Linux-i386-32; else echo Linux-amd64-64;fi`</value>
+    <description>
+      Additional execution environment entries for map and reduce task processes.
+      This is not an additive property. You must preserve the original value if
+      you want your map and reduce tasks to have access to native libraries (compression, etc)
+    </description>
+  </property>
+
 </configuration>

http://git-wip-us.apache.org/repos/asf/incubator-ambari/blob/48959aa9/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 4bc3401..228b21c 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -104,6 +104,26 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
    */
   savedSiteNameToServerServiceConfigDataMap: {},
   
+
+  /**
+   * XML characters which should be escaped in values
+   * http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML
+   */
+  xmlEscapeMap: {
+    "&": "&amp;",
+    "<": "&lt;",
+    ">": "&gt;",
+    '"': '&quot;',
+    "'": '&apos;'
+  },
+  xmlUnEscapeMap: {
+    "&amp;": "&",
+    "&lt;": "<",
+    "&gt;": ">",
+    "&quot;": '"',
+    "&apos;": "'"
+  },
+  
   isSubmitDisabled: function () {
     return (!(this.stepConfigs.everyProperty('errorCount', 0)) || this.get('isApplyingChanges'));
   }.property('stepConfigs.@each.errorCount', 'isApplyingChanges'),
@@ -1354,7 +1374,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
         if (/_heapsize|_newsize|_maxnewsize$/.test(_globalSiteObj.name) && !heapsizeException.contains(_globalSiteObj.name)) {
           _globalSiteObj.value += "m";
         }
-        globalSiteProperties[_globalSiteObj.name] = _globalSiteObj.value;
+        globalSiteProperties[_globalSiteObj.name] = this.escapeXMLCharacters(_globalSiteObj.value);
         this.recordHostOverride(_globalSiteObj, 'global', tagName, this);
         //console.log("TRACE: name of the global property is: " + _globalSiteObj.name);
         //console.log("TRACE: value of the global property is: " + _globalSiteObj.value);
@@ -1428,7 +1448,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     var coreSiteObj = this.get('uiConfigs').filterProperty('filename', 'core-site.xml');
     var coreSiteProperties = {};
     coreSiteObj.forEach(function (_coreSiteObj) {
-      coreSiteProperties[_coreSiteObj.name] = _coreSiteObj.value;
+      coreSiteProperties[_coreSiteObj.name] = this.escapeXMLCharacters(_coreSiteObj.value);
       this.recordHostOverride(_coreSiteObj, 'core-site', tagName, this);
     }, this);
     return {"type": "core-site", "tag": tagName, "properties": coreSiteProperties};
@@ -1449,11 +1469,31 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       siteObj = this.getHiveSiteObj(siteObj);
     }
     siteObj.forEach(function (_siteObj) {
-      siteProperties[_siteObj.name] = _siteObj.value;
+      siteProperties[_siteObj.name] = this.escapeXMLCharacters(_siteObj.value);
       this.recordHostOverride(_siteObj, siteName, tagName, this);
     }, this);
     return {"type": siteName, "tag": tagName, "properties": siteProperties};
   },
+  
+  /**
+   * Since values end up in XML files (core-sit.xml, etc.), certain
+   * XML sensitive characters should be escaped. If not we will have
+   * an invalid XML document, and services will fail to start. 
+   * 
+   * Special characters in XML are defined at
+   * http://en.wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references#Predefined_entities_in_XML
+   */
+  escapeXMLCharacters: function(value) {
+    var self = this;
+    // To prevent double/triple replacing '&gt;' to '&gt;gt;' to '&gt;gt;gt', we need
+    // to first unescape all XML chars, and then escape them again.
+    var newValue = String(value).replace(/(&amp;|&lt;|&gt;|&quot;|&apos;)/g, function (s) {
+      return self.xmlUnEscapeMap[s];
+    });
+    return String(newValue).replace(/[&<>"']/g, function (s) {
+      return self.xmlEscapeMap[s];
+    });
+  },
 
   /**
    * create site object for Oozie