You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2015/09/11 15:47:07 UTC

ambari git commit: AMBARI-13072 'All Datanodes' not present for HDFS in Create Widget Wizard. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/trunk f41ed7f1e -> b3eacea90


AMBARI-13072 'All Datanodes' not present for HDFS in Create Widget Wizard. (atkach)


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

Branch: refs/heads/trunk
Commit: b3eacea90cb05aac0c01b789c312c33db2974f43
Parents: f41ed7f
Author: Andrii Tkach <at...@hortonworks.com>
Authored: Fri Sep 11 16:46:46 2015 +0300
Committer: Andrii Tkach <at...@hortonworks.com>
Committed: Fri Sep 11 16:46:46 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/models/host_component.js         | 20 +++++
 .../service/widgets/create/expression_view.js   |  3 +-
 ambari-web/test/models/host_component_test.js   | 82 +++++++++++++++++++-
 3 files changed, 99 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b3eacea9/ambari-web/app/models/host_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/host_component.js b/ambari-web/app/models/host_component.js
index 68b9f68..14ca7d6 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -139,6 +139,26 @@ App.HostComponent = DS.Model.extend({
 
 App.HostComponent.FIXTURES = [];
 
+
+/**
+ * get particular counter of host-component by name
+ * @param {string} componentName
+ * @param {string} type (installedCount|startedCount|totalCount)
+ * @returns {number}
+ */
+App.HostComponent.getCount = function (componentName, type) {
+  switch (App.StackServiceComponent.find(componentName).get('componentCategory')) {
+    case 'MASTER':
+      return Number(App.MasterComponent.find(componentName).get(type));
+    case 'SLAVE':
+      return Number(App.SlaveComponent.find(componentName).get(type));
+    case 'CLIENT':
+      return Number(App.ClientComponent.find(componentName).get(type));
+    default:
+      return 0;
+  }
+};
+
 App.HostComponentStatus = {
   started: "STARTED",
   starting: "STARTING",

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3eacea9/ambari-web/app/views/main/service/widgets/create/expression_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/widgets/create/expression_view.js b/ambari-web/app/views/main/service/widgets/create/expression_view.js
index f5b6bc2..30c5451 100644
--- a/ambari-web/app/views/main/service/widgets/create/expression_view.js
+++ b/ambari-web/app/views/main/service/widgets/create/expression_view.js
@@ -347,8 +347,7 @@ App.AddMetricExpressionView = Em.View.extend({
       for (var componentId in servicesMap[serviceName].components) {
         // Hide the option if none of the hostComponent is created in the cluster yet
         var componentName = servicesMap[serviceName].components[componentId].component_name;
-        var isHostComponentAbsent = !App.HostComponent.find().filterProperty('componentName',componentName).length;
-        if (isHostComponentAbsent) continue;
+        if (App.HostComponent.getCount(componentName, 'totalCount') === 0) continue;
         var component = Em.Object.create({
           componentName: servicesMap[serviceName].components[componentId].component_name,
           level: servicesMap[serviceName].components[componentId].level,

http://git-wip-us.apache.org/repos/asf/ambari/blob/b3eacea9/ambari-web/test/models/host_component_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/host_component_test.js b/ambari-web/test/models/host_component_test.js
index 8e7cedf..7b4cf74 100644
--- a/ambari-web/test/models/host_component_test.js
+++ b/ambari-web/test/models/host_component_test.js
@@ -229,15 +229,89 @@ describe('App.HostComponent', function() {
     });
   });
 
-  describe('#componentTextStatus', function() {
-    it('', function() {
-      var status = 'INSTALLED';
+  describe('#componentTextStatus', function () {
+    before(function () {
       sinon.stub(App.HostComponentStatus, 'getTextStatus', Em.K);
+    });
+    after(function () {
+      App.HostComponentStatus.getTextStatus.restore();
+    });
+    it('componentTextStatus should be changed', function () {
+      var status = 'INSTALLED';
       hc.set('workStatus', status);
       hc.propertyDidChange('componentTextStatus');
       hc.get('componentTextStatus');
       expect(App.HostComponentStatus.getTextStatus.calledWith(status)).to.be.true;
-      App.HostComponentStatus.getTextStatus.restore();
+    });
+  });
+
+  describe("#getCount", function () {
+    var testCases = [
+      {
+        t: 'unknown component',
+        data: {
+          componentName: 'CC',
+          type: 'totalCount',
+          stackComponent: Em.Object.create()
+        },
+        result: 0
+      },
+      {
+        t: 'master component',
+        data: {
+          componentName: 'C1',
+          type: 'totalCount',
+          stackComponent: Em.Object.create({componentCategory: 'MASTER'})
+        },
+        result: 3
+      },
+      {
+        t: 'slave component',
+        data: {
+          componentName: 'C1',
+          type: 'installedCount',
+          stackComponent: Em.Object.create({componentCategory: 'SLAVE'})
+        },
+        result: 4
+      },
+      {
+        t: 'client component',
+        data: {
+          componentName: 'C1',
+          type: 'startedCount',
+          stackComponent: Em.Object.create({componentCategory: 'CLIENT'})
+        },
+        result: 5
+      },
+      {
+        t: 'client component, unknown type',
+        data: {
+          componentName: 'C1',
+          type: 'unknownCount',
+          stackComponent: Em.Object.create({componentCategory: 'CLIENT'})
+        },
+        result: 0
+      }
+    ];
+
+    beforeEach(function () {
+      this.mock = sinon.stub(App.StackServiceComponent, 'find');
+      sinon.stub(App.MasterComponent, 'find').returns(Em.Object.create({totalCount: 3}));
+      sinon.stub(App.SlaveComponent, 'find').returns(Em.Object.create({installedCount: 4}));
+      sinon.stub(App.ClientComponent, 'find').returns(Em.Object.create({startedCount: 5, unknownCount: null}));
+    });
+    afterEach(function () {
+      this.mock.restore();
+      App.MasterComponent.find.restore();
+      App.SlaveComponent.find.restore();
+      App.ClientComponent.find.restore();
+    });
+
+    testCases.forEach(function (test) {
+      it(test.t, function () {
+        this.mock.returns(test.data.stackComponent);
+        expect(App.HostComponent.getCount(test.data.componentName, test.data.type)).to.equal(test.result);
+      });
     });
   });
 });
\ No newline at end of file