You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by al...@apache.org on 2015/06/21 01:59:59 UTC

ambari git commit: AMBARI-12049. Host can be deleted despite some required masters are present (alexantonenko)

Repository: ambari
Updated Branches:
  refs/heads/branch-2.1 09eb223ae -> 5e8e94cb5


AMBARI-12049. Host can be deleted despite some required masters are present (alexantonenko)


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

Branch: refs/heads/branch-2.1
Commit: 5e8e94cb5af1d62549b12a5365a61fcb0c37ea76
Parents: 09eb223
Author: Alex Antonenko <hi...@gmail.com>
Authored: Sun Jun 21 00:01:54 2015 +0300
Committer: Alex Antonenko <hi...@gmail.com>
Committed: Sun Jun 21 02:59:54 2015 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host/details.js | 15 ++++++++
 .../test/controllers/main/host/details_test.js  | 36 ++++++++++++++++++++
 2 files changed, 51 insertions(+)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/5e8e94cb/ambari-web/app/controllers/main/host/details.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index 144465b..02b3c64 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -1874,6 +1874,21 @@ App.MainHostDetailsController = Em.Controller.extend({
         if (!cInstance.get('isDeletable')) {
           container.nonDeletableComponents.push(cInstance.get('displayName'));
         }
+        // if is deletable, but with cardinality 1+ and is the only instance on server
+        if (cInstance.get('isMaster') && cInstance.get('isDeletable')) {
+          var displayName = cInstance.get('displayName'),
+            componentName = cInstance.get('componentName');
+          var stackComponentCount = App.StackServiceComponent.find(componentName).get('minToInstall');
+          var installedCount = App.StackServiceComponent.find(componentName).get('isMaster')
+            ? App.HostComponent.find().filterProperty('componentName', componentName).length
+            : App.SlaveComponent.find().findProperty('componentName', componentName).get('totalCount');
+          var  isDeleteComponentDisabled = (installedCount <= stackComponentCount)
+            || ![App.HostComponentStatus.stopped, App.HostComponentStatus.unknown, App.HostComponentStatus.install_failed, App.HostComponentStatus.upgrade_failed, App.HostComponentStatus.init].contains(this.get('workStatus'));
+          if (isDeleteComponentDisabled) {
+            if (!container.masterComponents.contains(displayName))
+              container.masterComponents.push(displayName);
+          }
+        }
         if (workStatus === App.HostComponentStatus.unknown) {
           container.unknownComponents.push(cInstance.get('displayName'));
         }

http://git-wip-us.apache.org/repos/asf/ambari/blob/5e8e94cb/ambari-web/test/controllers/main/host/details_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js
index 4023a0e..9827a8b 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -1565,6 +1565,42 @@ describe('App.MainHostDetailsController', function () {
       expect(controller.getHostComponentsInfo().nonDeletableComponents).to.eql(['ZK1']);
       App.HostComponent.find.restore();
     });
+
+
+    it('content.hostComponents has master deletable with cardinality 1+ and only one installed component', function () {
+      sinon.stub(App.HostComponent, 'find', function () {
+        return [
+          {
+            id: 'TASKTRACKER_host1',
+            componentName: 'TASKTRACKER'
+          }
+        ];
+      });
+      sinon.stub(App.StackServiceComponent, 'find', function (component) {
+        return Em.Object.create(
+          {
+            componentName: 'TASKTRACKER',
+            minToInstall: 1,
+            isMaster: true
+          });
+      });
+      sinon.stub(App.SlaveComponent, 'find', function () {
+        return [];
+      });
+      controller.set('content', {hostComponents: [Em.Object.create({
+        componentName: 'TASKTRACKER',
+        workStatus: 'INIT',
+        isDeletable: true,
+        isMaster: true,
+        displayName: 'ZK1'
+      })]});
+      expect(controller.getHostComponentsInfo().masterComponents.contains('ZK1')).to.be.true;
+      App.HostComponent.find.restore();
+      App.StackServiceComponent.find.restore();
+      App.SlaveComponent.find.restore();
+    });
+
+
     it('content.hostComponents has running component', function () {
       sinon.stub(App.HostComponent, 'find', function () {
         return [