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-14015 Different values range for yarn.nodemanager.resource.memory-mb property after page refresh. (ababiichuk)
Date Mon, 23 Nov 2015 16:02:42 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 cab13ae84 -> 7effdec2a


AMBARI-14015 Different values range for yarn.nodemanager.resource.memory-mb property after
page refresh. (ababiichuk)


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

Branch: refs/heads/branch-2.1
Commit: 7effdec2a4de7b797f71bc85e63212fb86b84b13
Parents: cab13ae
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Mon Nov 23 17:58:24 2015 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Mon Nov 23 17:58:24 2015 +0200

----------------------------------------------------------------------
 .../app/controllers/wizard/step7_controller.js  | 30 +++++------
 ambari-web/app/utils/blueprint.js               | 55 +++++++++++---------
 ambari-web/test/utils/blueprint_test.js         | 39 +++++++++-----
 3 files changed, 69 insertions(+), 55 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/7effdec2/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 a9aca28..84142d7 100644
--- a/ambari-web/app/controllers/wizard/step7_controller.js
+++ b/ambari-web/app/controllers/wizard/step7_controller.js
@@ -713,23 +713,19 @@ App.WizardStep7Controller = Em.Controller.extend(App.ServerValidatorMixin,
App.E
     if (rangerService && !rangerService.get('isInstalled') && !rangerService.get('isSelected'))
{
       App.config.removeRangerConfigs(self.get('stepConfigs'));
     }
-    if (this.get('content.serviceConfigProperties.length') > 0) {
-      this.completeConfigLoading();
-    } else {
-      this.loadServerSideConfigsRecommendations().always(function () {
-        if (self.get('wizardController.name') == 'addServiceController') {
-          // for Add Service just remove or add dependent properties and ignore config values
changes
-          // for installed services only
-          self.addRemoveDependentConfigs(self.get('installedServiceNames'));
-          self.clearDependenciesForInstalledServices(self.get('installedServiceNames'), self.get('stepConfigs'));
-        }
-        // * add dependencies based on recommendations
-        // * update config values with recommended
-        // * remove properties received from recommendations
-        self.updateDependentConfigs();
-        self.completeConfigLoading();
-      });
-    }
+    this.loadServerSideConfigsRecommendations().always(function () {
+      if (self.get('wizardController.name') == 'addServiceController') {
+        // for Add Service just remove or add dependent properties and ignore config values
changes
+        // for installed services only
+        self.addRemoveDependentConfigs(self.get('installedServiceNames'));
+        self.clearDependenciesForInstalledServices(self.get('installedServiceNames'), self.get('stepConfigs'));
+      }
+      // * add dependencies based on recommendations
+      // * update config values with recommended
+      // * remove properties received from recommendations
+      self.updateDependentConfigs();
+      self.completeConfigLoading();
+    });
   },
 
   completeConfigLoading: function() {

http://git-wip-us.apache.org/repos/asf/ambari/blob/7effdec2/ambari-web/app/utils/blueprint.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/blueprint.js b/ambari-web/app/utils/blueprint.js
index 687c7fd..59290cd 100644
--- a/ambari-web/app/utils/blueprint.js
+++ b/ambari-web/app/utils/blueprint.js
@@ -385,39 +385,44 @@ module.exports = {
   },
 
   /**
+   * Small helper method to update hostMap
+   * it perform update of object only
+   * if unique component per host is added
+   *
+   * @param {Object} hostMapObject
+   * @param {string[]} hostNames
+   * @param {string} componentName
+   * @returns {Object}
+   * @private
+   */
+  _generateHostMap: function(hostMapObject, hostNames, componentName) {
+    Em.assert('hostMapObject, hostNames, componentName should be defined', !!hostMapObject
&& !!hostNames && !!componentName);
+    if (!hostNames.length) return hostMapObject;
+    hostNames.forEach(function(hostName) {
+      if (!hostMapObject[hostName])
+        hostMapObject[hostName] = [];
+
+      if (!hostMapObject[hostName].contains(componentName))
+        hostMapObject[hostName].push(componentName);
+    });
+    return hostMapObject;
+  },
+
+  /**
    * collect all component names that are present on hosts
    * @returns {object}
    */
   getComponentForHosts: function() {
     var hostsMap = {};
     App.ClientComponent.find().forEach(function(c) {
-      var componentName = c.get('componentName');
-      c.get('hostNames').forEach(function(hostName){
-        if (hostsMap[hostName]) {
-          hostsMap[hostName].push(componentName);
-        } else {
-          hostsMap[hostName] = [componentName];
-        }
-      });
-    });
+      hostsMap = this._generateHostMap(hostsMap, c.get('hostNames'), c.get('componentName'));
+    }, this);
     App.SlaveComponent.find().forEach(function (c) {
-      var componentName = c.get('componentName');
-      c.get('hostNames').forEach(function (hostName) {
-        if (hostsMap[hostName]) {
-          hostsMap[hostName].push(componentName);
-        } else {
-          hostsMap[hostName] = [componentName];
-        }
-      });
-    });
+      hostsMap = this._generateHostMap(hostsMap, c.get('hostNames'), c.get('componentName'));
+    }, this);
     App.HostComponent.find().forEach(function (c) {
-      var hostName = c.get('hostName');
-      if (hostsMap[hostName]) {
-        hostsMap[hostName].push(c.get('componentName'));
-      } else {
-        hostsMap[hostName] = [c.get('componentName')];
-      }
-    });
+      hostsMap = this._generateHostMap(hostsMap, [c.get('hostName')], c.get('componentName'));
+    }, this);
     return hostsMap;
   }
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/7effdec2/ambari-web/test/utils/blueprint_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/utils/blueprint_test.js b/ambari-web/test/utils/blueprint_test.js
index 29072a3..8fa3bcf 100644
--- a/ambari-web/test/utils/blueprint_test.js
+++ b/ambari-web/test/utils/blueprint_test.js
@@ -415,19 +415,32 @@ describe('utils/blueprint', function() {
       App.HostComponent.find.restore();
     });
 
-    it("", function() {
-      expect(blueprintUtils.getComponentForHosts()).to.eql({
-        "host1": [
-          "C1"
-        ],
-        "host2": [
-          "C1",
-          "C2"
-        ],
-        "host3": [
-          "C2",
-          "C3"
-        ]
+    it("generate components to host map", function() {
+      var res = blueprintUtils.getComponentForHosts();
+      expect(res['host1'][0]).to.eql("C1");
+      expect(res['host2'][0]).to.eql("C1");
+      expect(res['host2'][1]).to.eql("C2");
+      expect(res['host3'][0]).to.eql("C2");
+      expect(res['host3'][1]).to.eql("C3");
+    });
+  });
+
+  describe('#_generateHostMap', function() {
+    it('generate map', function() {
+      var map = blueprintUtils._generateHostMap({}, ['h1','h2', 'h1'],'c1');
+      expect(map['h1'][0]).to.eql('c1');
+      expect(map['h2'][0]).to.eql('c1');
+    });
+
+    it('skip generations as hosts is empty', function() {
+      expect(blueprintUtils._generateHostMap({}, [],'c1')).to.eql({});
+    });
+
+    it('skip throws error when data is wrong', function() {
+      it('should assert error if no data returned from server', function () {
+        expect(function () {
+          blueprintUtils._generateHostMap();
+        }).to.throw(Error);
       });
     });
   });


Mime
View raw message