ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-12477 Optimize stackConfigPropertiesMapper execution time. (ababiichuk)
Date Tue, 21 Jul 2015 15:23:34 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 88d38ab3a -> 1b84c3448


AMBARI-12477 Optimize stackConfigPropertiesMapper execution time. (ababiichuk)


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

Branch: refs/heads/branch-2.1
Commit: 1b84c34480360c1b0b4dc4bc9685095cd1e06407
Parents: 88d38ab
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Tue Jul 21 18:22:08 2015 +0300
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Tue Jul 21 18:22:08 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/data/HDP2/site_properties.js     |  1 +
 .../configs/stack_config_properties_mapper.js   | 59 +++++---------------
 ambari-web/app/utils/config.js                  | 43 +++++++++++---
 .../main/service/info/config_test.js            | 26 +++++++++
 .../stack_config_properties_mapper_test.js      |  4 +-
 ambari-web/test/utils/config_test.js            | 14 ++++-
 6 files changed, 93 insertions(+), 54 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/1b84c344/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 d946900..e359a41 100644
--- a/ambari-web/app/data/HDP2/site_properties.js
+++ b/ambari-web/app/data/HDP2/site_properties.js
@@ -181,6 +181,7 @@ var hdp2properties = [
     "isRequiredByAgent": false,
     "isVisible": false,
     "category": "Advanced hdfs-site",
+    "filename": "hdfs-site.xml",
     "serviceName": "HDFS"
   },
   {

http://git-wip-us.apache.org/repos/asf/ambari/blob/1b84c344/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
index 5913943..09f3cf9 100644
--- a/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
+++ b/ambari-web/app/mappers/configs/stack_config_properties_mapper.js
@@ -63,6 +63,20 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
                 type : dep.StackConfigurationDependency.dependency_type,
                 name : dep.StackConfigurationDependency.dependency_name
               });
+              var service = App.StackService.find(config.StackConfigurations.service_name);
+              var dependentService = App.config.getServiceByConfigType(dep.StackConfigurationDependency.dependency_type);
+              if (dependentService && service && dependentService.get('serviceName')
!= service.get('serviceName') && !service.get('dependentServiceNames').contains(dependentService.get('serviceName')))
{
+                service.set('dependentServiceNames', service.get('dependentServiceNames').concat(dependentService.get('serviceName')));
+              }
+            });
+          }
+          if (Em.get(config, 'config.StackConfigurations.property_depends_on.length') >
0) {
+            config.StackConfigurations.property_depends_on.forEach(function(dep) {
+              var service = App.StackService.find(config.StackConfigurations.service_name);
+              var dependentService = App.config.getServiceByConfigType(dep.type);
+              if (dependentService && service && dependentService.get('serviceName')
!= service.get('serviceName') && !service.get('dependentServiceNames').contains(dependentService.get('serviceName')))
{
+                service.set('dependentServiceNames', service.get('dependentServiceNames').concat(dependentService.get('serviceName')));
+              }
             });
           }
           /**
@@ -75,10 +89,6 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
         }, this);
       }, this);
       App.store.loadMany(this.get('model'), configs);
-
-      App.StackService.find().filterProperty('id').forEach(function(service) {
-        this.setDependentServices(service);
-      }, this);
     }
     console.timeEnd('stackConfigMapper execution time');
   },
@@ -110,45 +120,6 @@ App.stackConfigPropertiesMapper = App.QuickDataMapper.create({
    * @method getUIConfig
    */
   getUIConfig: function(propertyName, siteName) {
-    return App.config.get('preDefinedSiteProperties').filterProperty('filename', siteName).findProperty('name',
propertyName);
-  },
-
-  /**
-   * runs <code>setDependentServicesAndFileNames<code>
-   * for stack properties for current service
-   * @method loadDependentConfigs
-   */
-  setDependentServices: function(service) {
-    App.StackConfigProperty.find().filterProperty('serviceName', service.get('serviceName')).forEach(function(stackProperty)
{
-      if (stackProperty.get('propertyDependedBy.length')) {
-        this._setDependentServices(stackProperty, 'propertyDependedBy', service);
-      }
-      if (stackProperty.get('propertyDependsOn.length')) {
-        this._setDependentServices(stackProperty, 'propertyDependsOn', service);
-      }
-    }, this);
-  },
-  /**
-   * defines service names for configs and set them to <code>dependentServiceNames<code>
-   * @param {App.StackConfigProperty} stackProperty
-   * @param {String} [key='propertyDependedBy'] - attribute to check dependent configs
-   * @param service
-   * @private
-   */
-  _setDependentServices: function(stackProperty, key, service) {
-    key = key || 'propertyDependedBy';
-    if (stackProperty.get(key + '.length') > 0) {
-      stackProperty.get(key).forEach(function(dependent) {
-        var tag = App.config.getConfigTagFromFileName(dependent.type);
-        /** setting dependent serviceNames (without current serviceName) **/
-        var dependentProperty = App.StackConfigProperty.find(dependent.name + "_" + tag);
-        if (dependentProperty) {
-          if (dependentProperty.get('serviceName') && dependentProperty.get('serviceName')
!= service.get('serviceName') && !service.get('dependentServiceNames').contains(dependentProperty.get('serviceName')))
{
-            service.set('dependentServiceNames', service.get('dependentServiceNames').concat([dependentProperty.get('serviceName')]));
-          }
-          this._setDependentServices(dependentProperty, key, service);
-        }
-      }, this);
-    }
+    return App.config.get('preDefinedSitePropertiesMap')[App.config.configId(propertyName,
siteName)];
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/1b84c344/ambari-web/app/utils/config.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/config.js b/ambari-web/app/utils/config.js
index e88b6ea..2fd9f94 100644
--- a/ambari-web/app/utils/config.js
+++ b/ambari-web/app/utils/config.js
@@ -124,18 +124,45 @@ App.config = Em.Object.create({
 
   preDefinedSiteProperties: function () {
     var sitePropertiesForCurrentStack = this.preDefinedConfigFile('site_properties');
+    var serviceNames = App.StackService.find().mapProperty('serviceName').concat('MISC');
+    var properties = [];
     if (sitePropertiesForCurrentStack) {
-      return sitePropertiesForCurrentStack.configProperties;
-    }
-    if (App.get('isHadoop23Stack')) {
-      return require('data/HDP2.3/site_properties').configProperties;
-    }
-    if (App.get('isHadoop22Stack')) {
-      return require('data/HDP2.2/site_properties').configProperties;
+      properties =  sitePropertiesForCurrentStack.configProperties;
+    } else if (App.get('isHadoop23Stack')) {
+      properties = require('data/HDP2.3/site_properties').configProperties;
+    } else if (App.get('isHadoop22Stack')) {
+      properties = require('data/HDP2.2/site_properties').configProperties;
+    } else {
+      properties = require('data/HDP2/site_properties').configProperties;
     }
-    return require('data/HDP2/site_properties').configProperties;
+    return properties.filter(function(p) {
+      return serviceNames.contains(p.serviceName);
+    });
   }.property('App.isHadoop22Stack', 'App.isHadoop23Stack'),
 
+  /**
+   * map of <code>preDefinedSiteProperties</code> provide search by index
+   * @type {object}
+   */
+  preDefinedSitePropertiesMap: function () {
+    var map = {};
+
+    this.get('preDefinedSiteProperties').forEach(function (c) {
+      map[this.configId(c.name, c.filename)] = c;
+    }, this);
+    return map;
+  }.property('preDefinedSiteProperties'),
+
+  /**
+   *
+   * @param name
+   * @param fileName
+   * @returns {string}
+   */
+  configId: function(name, fileName) {
+    return name + "_" + App.config.getConfigTagFromFileName(fileName);
+  },
+
   preDefinedConfigFile: function(file) {
     try {
       return require('data/{0}/{1}'.format(App.get('currentStackName'), file));

http://git-wip-us.apache.org/repos/asf/ambari/blob/1b84c344/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index 8911743..6c7c273 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -887,7 +887,20 @@ describe("App.MainServiceInfoConfigsController", function () {
   });
 
   describe('#setHiveHostName', function () {
+    beforeEach(function () {
+      sinon.stub(App.StackService, 'find').returns([
+        {
+          serviceName: 'HIVE'
+        },
+        {
+          serviceName: 'OOZIE'
+        }
+      ]);
+    });
 
+    afterEach(function () {
+      App.StackService.find.restore();
+    });
     Em.A([
         {
           globals: [
@@ -984,7 +997,20 @@ describe("App.MainServiceInfoConfigsController", function () {
   });
 
   describe('#setOozieHostName', function () {
+    beforeEach(function () {
+      sinon.stub(App.StackService, 'find').returns([
+        {
+          serviceName: 'HIVE'
+        },
+        {
+          serviceName: 'OOZIE'
+        }
+      ]);
+    });
 
+    afterEach(function () {
+      App.StackService.find.restore();
+    });
     Em.A([
         {
           globals: [

http://git-wip-us.apache.org/repos/asf/ambari/blob/1b84c344/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
index fbe5a9b..ba0f046 100644
--- a/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
+++ b/ambari-web/test/mappers/configs/stack_config_properties_mapper_test.js
@@ -69,7 +69,7 @@ describe('App.stackConfigPropertiesMapper', function () {
               {
                 "StackConfigurationDependency" : {
                   "dependency_name" : "p4",
-                  "dependency_type" : "site4",
+                  "dependency_type" : "site4"
                 }
               }
             ]
@@ -162,9 +162,11 @@ describe('App.stackConfigPropertiesMapper', function () {
     beforeEach(function () {
       App.resetDsStoreTypeMap(App.StackConfigProperty);
       sinon.stub(App.store, 'commit', Em.K);
+      sinon.stub(App.StackService, 'find', function() { return Em.A()});
     });
     afterEach(function(){
       App.store.commit.restore();
+      App.StackService.find.restore();
     });
 
     it('should not do anything as there is no json', function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/1b84c344/ambari-web/test/utils/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/config_test.js b/ambari-web/test/utils/config_test.js
index b5f717f..689f35a 100644
--- a/ambari-web/test/utils/config_test.js
+++ b/ambari-web/test/utils/config_test.js
@@ -379,6 +379,11 @@ describe('App.config', function () {
   describe('#preDefinedSiteProperties-bigtop', function () {
     before(function() {
       setups.setupStackVersion(this, 'BIGTOP-0.8');
+      sinon.stub(App.StackService, 'find').returns([
+        {
+          serviceName: 'HIVE'
+        }
+      ]);
     });
 
     it('bigtop should use New PostgreSQL Database as its default hive metastore database',
function () {
@@ -386,13 +391,19 @@ describe('App.config', function () {
     });
 
     after(function() {
+      App.StackService.find.restore();
       setups.restoreStackVersion(this);
     });
   });
 
   describe('#preDefinedSiteProperties-hdp2', function () {
-    before(function() {
+    before(function () {
       setups.setupStackVersion(this, 'HDP-2.0');
+      sinon.stub(App.StackService, 'find').returns([
+        {
+          serviceName: 'HIVE'
+        }
+      ]);
     });
 
     it('HDP2 should use New MySQL Database as its default hive metastore database', function
() {
@@ -400,6 +411,7 @@ describe('App.config', function () {
     });
 
     after(function() {
+      App.StackService.find.restore();
       setups.restoreStackVersion(this);
     });
   });


Mime
View raw message