ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject git commit: AMBARI-4762 Modify Config pages to store/retrieve custom log4j configs as raw text. (ababiichuk)
Date Fri, 21 Feb 2014 21:42:05 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 822cd75a2 -> 965bd9df9


AMBARI-4762 Modify Config pages to store/retrieve custom log4j configs as raw text. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: 965bd9df97167555a6cca23d9a41f36f542872c0
Parents: 822cd75
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Fri Feb 21 23:34:39 2014 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Fri Feb 21 23:34:39 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  |   3 +
 .../app/controllers/wizard/step8_controller.js  |   6 +-
 ambari-web/app/data/HDP2/site_properties.js     | 138 ++++++++++++-
 ambari-web/app/data/service_configs.js          |  28 +--
 ambari-web/app/data/site_properties.js          | 126 +++++++++++-
 ambari-web/app/utils/config.js                  | 198 +++++++++++++------
 6 files changed, 424 insertions(+), 75 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/965bd9df/ambari-web/app/controllers/wizard/step7_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step7_controller.js b/ambari-web/app/controllers/wizard/step7_controller.js
index d360cf9..3ff6309 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -357,6 +357,9 @@ App.WizardStep7Controller = Em.Controller.extend({
     if (this.get('allSelectedServiceNames').contains('YARN') && !App.supports.capacitySchedulerUi)
{
       configs = App.config.fileConfigsIntoTextarea(configs, 'capacity-scheduler.xml');
     }
+    this.get('allSelectedServiceNames').forEach(function(serviceName) {
+      App.config.addLog4jConfig(configs, serviceName);
+    });
     this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete')
|| []);
     var localDB = {
       hosts: this.get('wizardController').getDBProperty('hosts'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/965bd9df/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index e8ba8e3..419058b 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1290,12 +1290,12 @@ App.WizardStep8Controller = Em.Controller.extend({
     return {"type": "hdfs-site", "tag": "version1", "properties": hdfsProperties };
   },
 
-  createLog4jObj: function (fileName) {
-    fileName = fileName.toLowerCase();
+  createLog4jObj: function (serviceName) {
+    var fileName = serviceName.toLowerCase();
     var Log4jObj = this.get('configs').filterProperty('filename', fileName + '-log4j.xml');
     var Log4jProperties = {};
     Log4jObj.forEach(function (_configProperty) {
-      Log4jProperties[_configProperty.name] = App.config.escapeXMLCharacters(_configProperty.value);
+      Log4jProperties[_configProperty.name] = _configProperty.value;
       console.log("STEP*: name of the property is: " + _configProperty.name);
       console.log("STEP8: value of the property is: " + _configProperty.value);
     }, this);

http://git-wip-us.apache.org/repos/asf/ambari/blob/965bd9df/ambari-web/app/data/HDP2/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/HDP2/site_properties.js b/ambari-web/app/data/HDP2/site_properties.js
index e5a6a04..e189e8c 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -1596,6 +1596,142 @@ module.exports =
       "displayType": "multiLine",
       "serviceName": "WEBHCAT",
       "category": "Advanced"
-    }
+   /**********************************************log4j.properties***************************************/
+    },
+    {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "HDFS",
+     "filename": "hdfs-log4j.xml",
+     "category": "AdvancedHDFSLog4j"
+     },
+     {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "MAPREDUCE2",
+     "filename": "mapreduce2-log4j.xml",
+     "category": "AdvancedMapredLog4j"
+     },
+     {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "YARN",
+     "filename": "yarn-log4j.xml",
+     "category": "AdvancedYARNLog4j"
+     },
+     {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "HBASE",
+     "filename": "hbase-log4j.xml",
+     "category": "AdvancedHbaseLog4j"
+     },
+     {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "HIVE",
+     "filename": "hive-exec-log4j.xml",
+     "category": "AdvancedHiveExecLog4j"
+     },
+     {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "HIVE",
+     "filename": "hive-log4j.xml",
+     "category": "AdvancedHiveLog4j"
+     },
+     {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "OOZIE",
+     "filename": "oozie-log4j.xml",
+     "category": "AdvancedOozieLog4j"
+     },
+     {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "ZOOKEEPER",
+     "filename": "zookeeper-log4j.xml",
+     "category": "AdvancedZooLog4j"
+     },
+     {
+     "id": "site property",
+     "name": "content",
+     "displayName": "content",
+     "value": "",
+     "defaultValue": "",
+     "description": "log4j properties",
+     "displayType": "custom",
+     "isOverridable": true,
+     "isRequired": false,
+     "isVisible": true,
+     "serviceName": "PIG",
+     "filename": "pig-log4j.xml",
+     "category": "AdvancedPigLog4j"
+     }
   ]
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/965bd9df/ambari-web/app/data/service_configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/service_configs.js b/ambari-web/app/data/service_configs.js
index 5660782..803d6df 100644
--- a/ambari-web/app/data/service_configs.js
+++ b/ambari-web/app/data/service_configs.js
@@ -37,7 +37,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
       App.ServiceConfigCategory.create({ name: 'AdvancedCoreSite', displayName : 'Custom
core-site.xml', siteFileName: 'core-site.xml', canAddProperty: true}),
       App.ServiceConfigCategory.create({ name: 'AdvancedHDFSSite', displayName : 'Custom
hdfs-site.xml', siteFileName: 'hdfs-site.xml', canAddProperty: true}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedHDFSLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'hdfs-log4j.xml', canAddProperty: true})
+      App.ServiceConfigCategory.create({ name: 'AdvancedHDFSLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'hdfs-log4j.xml'})
     ],
     sites: ['global', 'core-site', 'hdfs-site', 'hdfs-log4j'],
     configs: []
@@ -64,9 +64,9 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'General', displayName : 'General'}),
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
       App.ServiceConfigCategory.create({ name: 'AdvancedMapredSite', displayName : 'Custom
mapred-site.xml', siteFileName: 'mapred-site.xml', canAddProperty: true}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedMapredLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'mapred-log4j.xml', canAddProperty: true})
+      App.ServiceConfigCategory.create({ name: 'AdvancedMapredLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'mapreduce-log4j.xml'})
     ],
-    sites: ['global', 'mapred-site', 'mapred-queue-acls', 'mapred-log4j'],
+    sites: ['global', 'mapred-site', 'mapred-queue-acls', 'mapreduce-log4j'],
     configs: []
   },
 
@@ -84,7 +84,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'CapacityScheduler', displayName : 'Scheduler',
isCapacityScheduler : true, isCustomView: true, siteFileName: 'capacity-scheduler.xml', siteFileNames:
['capacity-scheduler.xml', 'mapred-queue-acls.xml'], canAddProperty: App.supports.capacitySchedulerUi}),
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
       App.ServiceConfigCategory.create({ name: 'AdvancedYARNSite', displayName : 'Custom
yarn-site.xml', siteFileName: 'yarn-site.xml', canAddProperty: true}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedYARNLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'yarn-log4j.xml', canAddProperty: true})
+      App.ServiceConfigCategory.create({ name: 'AdvancedYARNLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'yarn-log4j.xml'})
     ],
     sites: ['global', 'yarn-site', 'capacity-scheduler', 'yarn-log4j'],
     configs: []
@@ -101,9 +101,9 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'General', displayName : 'General'}),
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
       App.ServiceConfigCategory.create({ name: 'AdvancedMapredSite', displayName : 'Custom
mapred-site.xml', siteFileName: 'mapred-site.xml', canAddProperty: true}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedMapredLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'mapred-log4j.xml', canAddProperty: true})
+      App.ServiceConfigCategory.create({ name: 'AdvancedMapredLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'mapreduce2-log4j.xml'})
     ],
-    sites: ['global', 'mapred-site', 'mapred-queue-acls', 'mapred-log4j'],
+    sites: ['global', 'mapred-site', 'mapred-queue-acls', 'mapreduce2-log4j'],
     configs: []
   },
 
@@ -115,10 +115,10 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'Hive Metastore', displayName : 'Hive Metastore'}),
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
       App.ServiceConfigCategory.create({ name: 'AdvancedHiveSite', displayName : 'Custom
hive-site.xml', siteFileName: 'hive-site.xml', canAddProperty: true}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedHiveLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'hive-log4j.xml', canAddProperty: true}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedHiveExecLog4j', displayName : 'Custom
hive-exec-log4j', siteFileName: 'hive-exec-log4j.xml', canAddProperty: true})
+      App.ServiceConfigCategory.create({ name: 'AdvancedHiveLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'hive-log4j.xml'}),
+      App.ServiceConfigCategory.create({ name: 'AdvancedHiveExecLog4j', displayName : 'Custom
hive-exec-log4j', siteFileName: 'hive-exec-log4j.xml'})
     ],
-    sites: ['global', 'hive-site', 'hive-log4j', 'hive-log4j-exec'],
+    sites: ['global', 'hive-site', 'hive-log4j', 'hive-exec-log4j'],
     configs: []
   },
 
@@ -145,7 +145,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'General', displayName : 'General'}),
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
       App.ServiceConfigCategory.create({ name: 'AdvancedHbaseSite', displayName : 'Custom
hbase-site.xml', siteFileName: 'hbase-site.xml', canAddProperty: true}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedHbaseLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'hbase-log4j.xml', canAddProperty: true})
+      App.ServiceConfigCategory.create({ name: 'AdvancedHbaseLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'hbase-log4j.xml'})
     ],
     sites: ['global', 'hbase-site', 'hbase-log4j'],
     configs: []
@@ -157,10 +157,10 @@ module.exports = [
     configCategories: [
       App.ServiceConfigCategory.create({ name: 'ZooKeeper Server', displayName : 'ZooKeeper
Server'}),
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedZooLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'zoo-log4j.xml', canAddProperty: true}),
+      App.ServiceConfigCategory.create({ name: 'AdvancedZooLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'zookeeper-log4j.xml'}),
       App.ServiceConfigCategory.create({ name: 'AdvancedZooCfg', displayName : 'Custom zoo.cfg',
siteFileName: 'zoo.cfg', canAddProperty: true})
     ],
-    sites: ['global', 'zoo-log4j', 'zoo.cfg'],
+    sites: ['global', 'zookeeper-log4j', 'zoo.cfg'],
     configs: []
   },
 
@@ -172,7 +172,7 @@ module.exports = [
       App.ServiceConfigCategory.create({ name: 'Oozie Server', displayName : 'Oozie Server'}),
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
       App.ServiceConfigCategory.create({ name: 'AdvancedOozieSite', displayName : 'Custom
oozie-site.xml', siteFileName: 'oozie-site.xml', canAddProperty: true}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedOozieLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'oozie-log4j.xml', canAddProperty: true})
+      App.ServiceConfigCategory.create({ name: 'AdvancedOozieLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'oozie-log4j.xml'})
     ],
     sites: ['global', 'oozie-site', 'oozie-log4j'],
     configs: []
@@ -215,7 +215,7 @@ module.exports = [
     displayName: 'Pig',
     configCategories: [
       App.ServiceConfigCategory.create({ name: 'Advanced', displayName : 'Advanced'}),
-      App.ServiceConfigCategory.create({ name: 'AdvancedPigLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'pig-log4j.xml', canAddProperty: true})
+      App.ServiceConfigCategory.create({ name: 'AdvancedPigLog4j', displayName : 'Custom
log4j.properties', siteFileName: 'pig-log4j.xml'})
     ],
     sites: ['pig-log4j'],
     configs: []

http://git-wip-us.apache.org/repos/asf/ambari/blob/965bd9df/ambari-web/app/data/site_properties.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/data/site_properties.js b/ambari-web/app/data/site_properties.js
index 8e9546c..589688e 100644
--- a/ambari-web/app/data/site_properties.js
+++ b/ambari-web/app/data/site_properties.js
@@ -524,8 +524,8 @@ module.exports =
       "name": "hbase.hstore.blockingStoreFiles",
       "displayName": "hstore blocking storefiles",
       "description": "If more than this number of StoreFiles in any one Store (one StoreFile
is written per flush of " +
-        "MemStore) then updates are blocked for this HRegion until a compaction is completed,
or until " +
-        "hbase.hstore.blockingWaitTime has been exceeded.",
+          "MemStore) then updates are blocked for this HRegion until a compaction is completed,
or until " +
+          "hbase.hstore.blockingWaitTime has been exceeded.",
       "defaultValue": "",
       "isRequired": true,
       "displayType": "int",
@@ -704,6 +704,128 @@ module.exports =
       "displayType": "multiLine",
       "serviceName": "WEBHCAT",
       "category": "Advanced"
+    },
+  /**********************************************log4j.properties***************************************/
+
+    {
+      "id": "site property",
+      "name": "content",
+      "displayName": "content",
+      "value": "",
+      "defaultValue": "",
+      "description": "log4j properties",
+      "displayType": "custom",
+      "isOverridable": true,
+      "isRequired": false,
+      "isVisible": true,
+      "serviceName": "HDFS",
+      "filename": "hdfs-log4j.xml",
+      "category": "AdvancedHDFSLog4j"
+    },
+    {
+      "id": "site property",
+      "name": "content",
+      "displayName": "content",
+      "value": "",
+      "defaultValue": "",
+      "description": "log4j properties",
+      "displayType": "custom",
+      "isOverridable": true,
+      "isRequired": false,
+      "isVisible": true,
+      "serviceName": "MAPREDUCE",
+      "filename": "mapreduce-log4j.xml",
+      "category": "AdvancedMapredLog4j"
+    },
+    {
+      "id": "site property",
+      "name": "content",
+      "displayName": "content",
+      "value": "",
+      "defaultValue": "",
+      "description": "log4j properties",
+      "displayType": "custom",
+      "isOverridable": true,
+      "isRequired": false,
+      "isVisible": true,
+      "serviceName": "HBASE",
+      "filename": "hbase-log4j.xml",
+      "category": "AdvancedHbaseLog4j"
+    },
+    {
+      "id": "site property",
+      "name": "content",
+      "displayName": "content",
+      "value": "",
+      "defaultValue": "",
+      "description": "log4j properties",
+      "displayType": "custom",
+      "isOverridable": true,
+      "isRequired": false,
+      "isVisible": true,
+      "serviceName": "HIVE",
+      "filename": "hive-exec-log4j.xml",
+      "category": "AdvancedHiveExecLog4j"
+    },
+    {
+      "id": "site property",
+      "name": "content",
+      "displayName": "content",
+      "value": "",
+      "defaultValue": "",
+      "description": "log4j properties",
+      "displayType": "custom",
+      "isOverridable": true,
+      "isRequired": false,
+      "isVisible": true,
+      "serviceName": "HIVE",
+      "filename": "hive-log4j.xml",
+      "category": "AdvancedHiveLog4j"
+    },
+    {
+      "id": "site property",
+      "name": "content",
+      "displayName": "content",
+      "value": "",
+      "defaultValue": "",
+      "description": "log4j properties",
+      "displayType": "custom",
+      "isOverridable": true,
+      "isRequired": false,
+      "isVisible": true,
+      "serviceName": "OOZIE",
+      "filename": "oozie-log4j.xml",
+      "category": "AdvancedOozieLog4j"
+    },
+    {
+      "id": "site property",
+      "name": "content",
+      "displayName": "content",
+      "value": "",
+      "defaultValue": "",
+      "description": "log4j properties",
+      "displayType": "custom",
+      "isOverridable": true,
+      "isRequired": false,
+      "isVisible": true,
+      "serviceName": "ZOOKEEPER",
+      "filename": "zookeeper-log4j.xml",
+      "category": "AdvancedZooLog4j"
+    },
+    {
+      "id": "site property",
+      "name": "content",
+      "displayName": "content",
+      "value": "",
+      "defaultValue": "",
+      "description": "log4j properties",
+      "displayType": "custom",
+      "isOverridable": true,
+      "isRequired": false,
+      "isVisible": true,
+      "serviceName": "PIG",
+      "filename": "pig-log4j.xml",
+      "category": "AdvancedPigLog4j"
     }
   ]
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/965bd9df/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index d45f94b..d9a4540 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -19,6 +19,7 @@
 var App = require('app');
 var stringUtils = require('utils/string_utils');
 
+var categotyConfigs = require('data/service_configs');
 var serviceComponents = {};
 var configGroupsByTag = [];
 
@@ -49,6 +50,11 @@ App.config = Em.Object.create({
    */
   filenameExceptions: ['zoo.cfg'],
 
+  log4jNotDefaultFilenames: [
+    {serviceName: 'HIVE', tagName: 'hive-exec-log4j.xml', configCroupName: 'AdvancedHiveExecLog4j',
fileName:  'hive-exec-log4j.properties'},
+    {serviceName: 'HIVE', tagName: 'hive-log4j.xml', configCroupName: 'AdvancedHiveLog4j',
fileName:  'hive-log4j.properties'}
+  ],
+
   /**
    * Since values end up in XML files (core-sit.xml, etc.), certain
    * XML sensitive characters should be escaped. If not we will have
@@ -245,7 +251,7 @@ App.config = Em.Object.create({
       properties = (properties.length) ? properties.objectAt(0).properties : {};
       for (var index in properties) {
         var configsPropertyDef =  null;
-        var preDefinedConfig = preDefinedConfigs.filterProperty('name', index);
+        var preDefinedConfig = preDefinedConfigs.filterProperty('serviceName',serviceName).filterProperty('name',
index);
         preDefinedConfig.forEach(function(_preDefinedConfig){
           if (selectedServiceNames.contains(_preDefinedConfig.serviceName) || _preDefinedConfig.serviceName
=== 'MISC') {
             configsPropertyDef = _preDefinedConfig;
@@ -358,10 +364,15 @@ App.config = Em.Object.create({
     }, this);
 
     this.get('preDefinedSiteProperties').mapProperty('name').forEach(function (name) {
-      var _site = siteConfigs.findProperty('name', name);
-      if (_site) {
-        siteStart.push(_site);
-        siteConfigs = siteConfigs.without(_site);
+      var _site = siteConfigs.filterProperty('name', name);
+      if (_site.length == 1) {
+        siteStart.push(_site[0]);
+        siteConfigs = siteConfigs.without(_site[0]);
+      } else if (_site.length >1) {
+        _site.forEach(function(site){
+          siteStart.push(site);
+          siteConfigs = siteConfigs.without(site);
+        }, this);
       }
     }, this);
 
@@ -388,69 +399,87 @@ App.config = Em.Object.create({
   mergePreDefinedWithStored: function (storedConfigs, advancedConfigs, selectedServiceNames)
{
     var mergedConfigs = [];
     var preDefinedConfigs = $.extend(true, [], this.get('preDefinedGlobalProperties').concat(this.get('preDefinedSiteProperties')));
-    var categoryMetaData = null;
+
     storedConfigs = (storedConfigs) ? storedConfigs : [];
 
     var preDefinedNames = preDefinedConfigs.mapProperty('name');
     var storedNames = storedConfigs.mapProperty('name');
     var names = preDefinedNames.concat(storedNames).uniq();
     names.forEach(function (name) {
-      var stored = storedConfigs.findProperty('name', name);
-      var preDefined;
+      var storedCfgs = storedConfigs.filterProperty('name', name);
+      var preDefinedCfgs = [];
       var preDefinedConfig = preDefinedConfigs.filterProperty('name', name);
-         preDefinedConfig.forEach(function(_preDefinedConfig){
-           if (selectedServiceNames.contains(_preDefinedConfig.serviceName) || _preDefinedConfig.serviceName
=== 'MISC') {
-             preDefined = _preDefinedConfig;
-           }
-         },this);
+      preDefinedConfig.forEach(function (_preDefinedConfig) {
+        if (selectedServiceNames.contains(_preDefinedConfig.serviceName) || _preDefinedConfig.serviceName
=== 'MISC') {
+          preDefinedCfgs.push(_preDefinedConfig);
+        }
+      }, this);
 
       var configData = {};
-      var isAdvanced = advancedConfigs.someProperty('name', name);
-      if (preDefined && stored) {
-        configData = preDefined;
-        configData.value = stored.value;
-        configData.defaultValue = stored.defaultValue;
-        configData.overrides = stored.overrides;
-        configData.filename = stored.filename;
-        configData.description = stored.description;
-        configData.isRequiredByAgent = (configData.isRequiredByAgent !== undefined) ? configData.isRequiredByAgent
: true;
-      } else if (!preDefined && stored) {
+      if (storedCfgs.length <= 1 && preDefinedCfgs.length <= 1) {
+        var stored = storedCfgs[0];
+        var preDefined = preDefinedCfgs[0];
+        var isAdvanced = advancedConfigs.someProperty('name', name);
+        if (preDefined && stored) {
+          configData = preDefined;
+          configData.value = stored.value;
+          configData.defaultValue = stored.defaultValue;
+          configData.overrides = stored.overrides;
+          configData.filename = stored.filename;
+          configData.description = stored.description;
+          configData.isRequiredByAgent = (configData.isRequiredByAgent !== undefined) ? configData.isRequiredByAgent
: true;
+        } else if (!preDefined && stored) {
 
-        configData = {
-          id: stored.id,
-          name: stored.name,
-          displayName: stored.name,
-          serviceName: stored.serviceName,
-          value: stored.value,
-          defaultValue: stored.defaultValue,
-          displayType: stringUtils.isSingleLine(stored.value) ? 'advanced' : 'multiLine',
-          filename: stored.filename,
-          category: 'Advanced',
-          isUserProperty: stored.isUserProperty === true,
-          isOverridable: true,
-          overrides: stored.overrides,
-          isRequired: true
-        };
-        this.calculateConfigProperties(configData, isAdvanced, advancedConfigs);
-      } else if (preDefined && !stored) {
-        configData = preDefined;
-        configData.isRequiredByAgent = (configData.isRequiredByAgent !== undefined) ? configData.isRequiredByAgent
: true;
-        if (isAdvanced) {
-          var advanced = advancedConfigs.findProperty('name', configData.name);
-          // Password fields should be made blank by default in installer wizard
-          // irrespective of whatever value is sent from stack definition.
-          // This forces the user to fill the password field.
-          configData.value = configData.displayType == "password" ? '' : advanced.value;
+          configData = {
+            id: stored.id,
+            name: stored.name,
+            displayName: stored.name,
+            serviceName: stored.serviceName,
+            value: stored.value,
+            defaultValue: stored.defaultValue,
+            displayType: stringUtils.isSingleLine(stored.value) ? 'advanced' : 'multiLine',
+            filename: stored.filename,
+            category: 'Advanced',
+            isUserProperty: stored.isUserProperty === true,
+            isOverridable: true,
+            overrides: stored.overrides,
+            isRequired: true
+          };
+          this.calculateConfigProperties(configData, isAdvanced, advancedConfigs);
+        } else if (preDefined && !stored) {
+          configData = preDefined;
+          configData.isRequiredByAgent = (configData.isRequiredByAgent !== undefined) ? configData.isRequiredByAgent
: true;
+          if (isAdvanced) {
+            var advanced = advancedConfigs.findProperty('name', configData.name);
+            // Password fields should be made blank by default in installer wizard
+            // irrespective of whatever value is sent from stack definition.
+            // This forces the user to fill the password field.
+            configData.value = configData.displayType == "password" ? '' : advanced.value;
+            configData.defaultValue = configData.value;
+            configData.filename = advanced.filename;
+            configData.description = advanced.description;
+          }
+        }
+        if (configData.displayType === 'checkbox') {
+          configData.value = configData.value === 'true'; // convert {String} value to {Boolean}
           configData.defaultValue = configData.value;
-          configData.filename = advanced.filename;
-          configData.description = advanced.description;
         }
+        mergedConfigs.push(configData);
+      } else {
+        preDefinedCfgs.forEach(function (cfg) {
+          configData = cfg;
+          var storedCfg = storedCfgs.findProperty('filename', cfg.filename);
+          if (storedCfg) {
+            configData.value = storedCfg.value;
+            configData.defaultValue = storedCfg.defaultValue;
+            configData.overrides = storedCfg.overrides;
+            configData.filename = storedCfg.filename;
+            configData.description = storedCfg.description;
+            configData.isRequiredByAgent = (configData.isRequiredByAgent !== undefined) ?
configData.isRequiredByAgent : true;
+          }
+          mergedConfigs.push(configData);
+        }, this);
       }
-      if (configData.displayType === 'checkbox') {
-        configData.value = configData.value === 'true'; // convert {String} value to {Boolean}
-        configData.defaultValue = configData.value;
-      }
-      mergedConfigs.push(configData);
     }, this);
     return mergedConfigs;
   },
@@ -955,6 +984,65 @@ App.config = Em.Object.create({
     return configs;
   },
 
+
+  addLog4jConfig: function (configs, serviceName) {
+    var fileName = serviceName.toLowerCase() + '-log4j.xml';
+    var content = configs.filterProperty('serviceName', serviceName).findProperty('name',
'content');
+    if (!content || !content.value.length) {
+      var category = categotyConfigs.findProperty('serviceName', serviceName) &&
categotyConfigs.findProperty('serviceName', serviceName).configCategories.findProperty('siteFileName',
fileName);
+      if (category) {
+        if (serviceName == 'HIVE') {
+          this.get('log4jNotDefaultFilenames').forEach(function (info) {
+            this.loadLog4jDefaultProperties(configs, 'HIVE', info.tagName, info.configCroupName,
info.fileName);
+          }, this);
+        } else {
+          this.loadLog4jDefaultProperties(configs, serviceName, category.siteFileName, category.name);
+        }
+      }
+    }
+    /**
+     * Filtering properties to exclude {serviceName}-log4j.xml file. We don't use properties
from this file,
+     * instead we load log4j.properties file as one property named "content".
+     * Filter can be deleted after {serviceName}-log4j.xml will be deleted from server
+     */
+    return configs.filter(function (_config) {
+      return (_config.filename !== fileName || _config.name == "content");
+    });
+  },
+
+  loadLog4jDefaultProperties: function(configs, serviceName, fileName, categoryName, log4jFile)
{
+    var url = "/resources//stacks/HDP/" + App.get('currentStackVersionNumber') + "/services/"
+ serviceName + "/configuration/" + (log4jFile || "log4j.properties");
+    $.ajax({
+      type: "GET",
+      url: url,
+      async: false,
+      success: function(data) {
+        var log4jObj = new Object({
+          "id": "puppet var",
+          "name": "content",
+          "displayName": "content",
+          "value": data,
+          "defaultValue": data,
+          "description": "log4j properties",
+          "displayType": "custom",
+          "isOverridable": true,
+          "isRequired": true,
+          "isVisible": true,
+          "serviceName": serviceName,
+          "filename": fileName,
+          "category": categoryName
+        });
+        var cfg = configs.findProperty('filename',fileName);
+        if (!cfg) {
+          configs.push(log4jObj);
+        } else {
+          cfg.value = data;
+          cfg.defaultValue = data;
+        }
+      }
+    });
+  },
+
   /**
    * trim trailing spaces for all properties.
    * trim both trailing and leading spaces for host displayType and hive/oozie datebases
url.


Mime
View raw message