ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-7750 After change decommission mechanism for RS it fails due time outю (atkach)
Date Sun, 12 Oct 2014 11:04:07 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 183ab7a80 -> 4862ae3b3


AMBARI-7750 After change decommission mechanism for RS it fails due time outю (atkach)


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

Branch: refs/heads/trunk
Commit: 4862ae3b380df448a4dd8d91d96ba06cd109adff
Parents: 183ab7a
Author: atkach <atkach@hortonworks.com>
Authored: Sun Oct 12 14:03:53 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Sun Oct 12 14:03:53 2014 +0300

----------------------------------------------------------------------
 ambari-web/app/controllers/main/host.js         |   2 +-
 ambari-web/app/controllers/main/host/details.js |  54 ++++-
 ambari-web/app/messages.js                      |   1 +
 ambari-web/app/utils/ajax/ajax.js               |   4 +
 .../test/controllers/main/host/details_test.js  | 216 ++++++++++---------
 ambari-web/test/controllers/main/host_test.js   |  28 +++
 6 files changed, 202 insertions(+), 103 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/4862ae3b/ambari-web/app/controllers/main/host.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host.js b/ambari-web/app/controllers/main/host.js
index e247bc7..c54547f 100644
--- a/ambari-web/app/controllers/main/host.js
+++ b/ambari-web/app/controllers/main/host.js
@@ -888,7 +888,7 @@ App.MainHostController = Em.ArrayController.extend({
     if (Em.get(data, 'items.length')) {
       App.router.get('mainHostDetailsController').showHbaseActiveWarning();
     } else {
-      App.router.get('mainHostDetailsController').doDecommissionRegionServer(params.hostNames,
"HBASE", "HBASE_MASTER", "HBASE_REGIONSERVER");
+      App.router.get('mainHostDetailsController').checkRegionServerState(params.hostNames);
     }
   },
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/4862ae3b/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 b90e9f1..378f6da 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -927,16 +927,66 @@ App.MainHostDetailsController = Em.Controller.extend({
    * @method warnBeforeDecommission
    * @param {string} hostNames - list of host when run from bulk operations or current host
    */
-
   warnBeforeDecommission: function (hostNames) {
     if (this.get('content.hostComponents').findProperty('componentName', 'HBASE_REGIONSERVER').get('passiveState')
== "OFF") {
       this.showHbaseActiveWarning();
     } else {
-      this.doDecommissionRegionServer(hostNames, "HBASE", "HBASE_MASTER", "HBASE_REGIONSERVER");
+      this.checkRegionServerState(hostNames);
+    }
+  },
+
+  /**
+   *  send call to check is this regionserver last in cluster which has desired_admin_state
property "INSERVICE"
+   * @method checkRegionServerState
+   * @param hostNames
+   */
+  checkRegionServerState: function (hostNames) {
+    return App.ajax.send({
+      name: 'host.region_servers.in_inservice',
+      sender: this,
+      data: {
+        hostNames: hostNames
+      },
+      success: 'checkRegionServerStateSuccessCallback'
+    });
+  },
+
+  /**
+   * check is this regionserver last in cluster which has desired_admin_state property "INSERVICE"
+   * @method checkRegionServerStateSuccessCallback
+   * @param data
+   * @param opt
+   * @param params
+   */
+  checkRegionServerStateSuccessCallback: function (data, opt, params) {
+    var hostArray = params.hostNames.split(",");
+    var decommissionPossible = (data.items.mapProperty('HostRoles.host_name').filter(function
(hostName) {
+      return !hostArray.contains(hostName);
+    }, this).length >= 1);
+    if (decommissionPossible) {
+      this.doDecommissionRegionServer(params.hostNames, "HBASE", "HBASE_MASTER", "HBASE_REGIONSERVER");
+    } else {
+      this.showRegionServerWarning();
     }
   },
 
   /**
+   * show warning that regionserver is last in cluster which has desired_admin_state property
"INSERVICE"
+   * @method showRegionServerWarning
+   * @param hostNames
+   */
+  showRegionServerWarning: function () {
+    return App.ModalPopup.show({
+      header: Em.I18n.t('common.warning'),
+      message: Em.I18n.t('hosts.host.hbase_regionserver.decommission.warning'),
+      bodyClass: Ember.View.extend({
+        template: Em.Handlebars.compile('<div class="alert alert-warning">{{message}}</div>')
+      }),
+      secondary: false
+    });
+  },
+
+  /**
    * shows warning: put hbase regionserver in passive state
    * @method showHbaseActiveWarning
    * @return {App.ModalPopup}

http://git-wip-us.apache.org/repos/asf/ambari/blob/4862ae3b/ambari-web/app/messages.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/messages.js b/ambari-web/app/messages.js
index 7d935e0..8922f03 100644
--- a/ambari-web/app/messages.js
+++ b/ambari-web/app/messages.js
@@ -1732,6 +1732,7 @@ Em.I18n.translations = {
   'hosts.host.regionserver.decommission.batch3':'Decommission RegionServer - Turn drain mode
off',
   'hosts.host.hbase_regionserver.recommission':'Recommission RegionServer',
   'hosts.host.hbase_regionserver.decommission':'Decommission RegionServer',
+  'hosts.host.hbase_regionserver.decommission.warning':'Last RegionServer can\'t be decommissioned',
   'hosts.host.decommissioned':'Decommissioned',
   'hosts.host.decommissioning':'Decommissioning',
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/4862ae3b/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index f3a5234..0e4fa2f 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -533,6 +533,10 @@ var urls = {
     'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/{componentName}?fields=metrics/dfs/namenode',
     'mock': ''
   },
+  'host.region_servers.in_inservice': {
+    'real': '/clusters/{clusterName}/host_components?HostRoles/component_name=HBASE_REGIONSERVER&HostRoles/desired_admin_state=INSERVICE&fields=HostRoles/host_name&minimal_response=true',
+    'mock': ''
+  },
   'host.host_component.decommission_slave': {
     'real' : '/clusters/{clusterName}/requests',
     'mock' : '',

http://git-wip-us.apache.org/repos/asf/ambari/blob/4862ae3b/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 1c31784..24580d1 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -27,14 +27,19 @@ var controller;
 describe('App.MainHostDetailsController', function () {
 
 
-  beforeEach(function() {
+  beforeEach(function () {
+    sinon.stub(App.ajax, 'send', Em.K);
     controller = App.MainHostDetailsController.create({
       securityEnabled: function () {
         return this.get('mockSecurityStatus');
       }.property(),
+      content: Em.Object.create(),
       mockSecurityStatus: false
     });
   });
+  afterEach(function () {
+    App.ajax.send.restore();
+  });
 
 
   describe('#serviceActiveComponents', function () {
@@ -144,11 +149,9 @@ describe('App.MainHostDetailsController', function () {
 
     beforeEach(function () {
       sinon.spy(App, "showConfirmationPopup");
-      sinon.stub(App.ajax, "send", Em.K);
     });
     afterEach(function () {
       App.showConfirmationPopup.restore();
-      App.ajax.send.restore();
     });
 
     it('confirm popup should be displayed', function () {
@@ -315,14 +318,6 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#primary()', function () {
-
-    beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
     it('Query should be sent', function () {
       var component = Em.Object.create({
         componentName: 'COMP1',
@@ -380,14 +375,6 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#sendRefreshComponentConfigsCommand()', function () {
-
-    beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
     it('Query should be sent', function () {
       var component = Em.Object.create({
         service: {},
@@ -400,14 +387,6 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#loadConfigs()', function () {
-
-    beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
     it('Query should be sent', function () {
       controller.loadConfigs();
       expect(App.ajax.send.calledOnce).to.be.true;
@@ -477,13 +456,11 @@ describe('App.MainHostDetailsController', function () {
   describe('#loadConfigsSuccessCallback()', function () {
 
     beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
       sinon.stub(controller, "constructConfigUrlParams", function () {
         return this.get('mockUrlParams');
       });
     });
     afterEach(function () {
-      App.ajax.send.restore();
       controller.constructConfigUrlParams.restore();
     });
 
@@ -505,13 +482,11 @@ describe('App.MainHostDetailsController', function () {
       sinon.stub(controller, "getZkServerHosts", Em.K);
       sinon.stub(controller, "concatZkNames", Em.K);
       sinon.stub(controller, "setZKConfigs", Em.K);
-      sinon.spy(App.ajax, "send");
     });
     afterEach(function () {
       controller.getZkServerHosts.restore();
       controller.concatZkNames.restore();
       controller.setZKConfigs.restore();
-      App.ajax.send.restore();
     });
 
     it('data.items is empty', function () {
@@ -679,12 +654,10 @@ describe('App.MainHostDetailsController', function () {
 
     beforeEach(function () {
       sinon.spy(App.ModalPopup, "show");
-      sinon.stub(App.ajax, "send", Em.K);
     });
 
     afterEach(function () {
       App.ModalPopup.show.restore();
-      App.ajax.send.restore();
     });
 
     it('popup should be displayed', function () {
@@ -778,14 +751,6 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#doDecommission()', function () {
-
-    beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
     it('Query should be sent', function () {
       controller.doDecommission('', '', '', '');
       expect(App.ajax.send.calledOnce).to.be.true;
@@ -793,63 +758,132 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#doDecommissionRegionServer()', function () {
+    it('Query should be sent', function () {
+      controller.doDecommissionRegionServer('', '', '', '');
+      expect(App.ajax.send.calledOnce).to.be.true;
+    });
+  });
 
+  describe('#warnBeforeDecommission()', function () {
     beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
+      sinon.stub(controller, "showHbaseActiveWarning", Em.K);
+      sinon.stub(controller, "checkRegionServerState", Em.K);
     });
     afterEach(function () {
-      App.ajax.send.restore();
+      controller.checkRegionServerState.restore();
+      controller.showHbaseActiveWarning.restore();
     });
 
-    it('Query should be sent', function () {
-      controller.doDecommissionRegionServer('', '', '', '');
-      expect(App.ajax.send.calledOnce).to.be.true;
+    it('Component in passive state', function () {
+      controller.set('content.hostComponents', [Em.Object.create({
+        componentName: 'HBASE_REGIONSERVER',
+        passiveState: 'ON'
+      })]);
+      controller.warnBeforeDecommission('host1');
+      expect(controller.checkRegionServerState.calledOnce).to.be.true;
+    });
+    it('Component is not in passive state', function () {
+      controller.set('content.hostComponents', [Em.Object.create({
+        componentName: 'HBASE_REGIONSERVER',
+        passiveState: 'OFF'
+      })]);
+      controller.warnBeforeDecommission('host1');
+      expect(controller.showHbaseActiveWarning.calledOnce).to.be.true;
     });
   });
 
-  /**
-   * TODO uncomment test when final rules will be implemented into warnBeforeDecommission
function
-   */
-  /* describe('#warnBeforeDecommission()', function () {
-
-   beforeEach(function () {
-   sinon.stub(controller, "doDecommissionRegionServer", Em.K);
-   sinon.stub(App.ModalPopup, "show", Em.K);
-   });
-   afterEach(function () {
-   App.ModalPopup.show.restore();
-   controller.doDecommissionRegionServer.restore();
-   });
-
-   it('Component in passive state', function () {
-   controller.set('content.hostComponents', [Em.Object.create({
-   componentName: 'HBASE_REGIONSERVER',
-   passiveState: 'ON'
-   })]);
-   controller.warnBeforeDecommission('host1', 'HBASE', 'HBASE_REGIONSERVER', 'SLAVE');
-   expect(App.ModalPopup.show.called).to.be.false;
-   expect(controller.doDecommissionRegionServer.calledWith('host1', 'HBASE', 'HBASE_REGIONSERVER',
'SLAVE')).to.be.true;
-   });
-   it('Component is not in passive state', function () {
-   controller.set('content.hostComponents', [Em.Object.create({
-   componentName: 'HBASE_REGIONSERVER',
-   passiveState: 'OFF'
-   })]);
-   controller.warnBeforeDecommission('host1', 'HBASE', 'HBASE_REGIONSERVER', 'SLAVE');
-   expect(App.ModalPopup.show.calledOnce).to.be.true;
-   expect(controller.doDecommissionRegionServer.called).to.be.false;
-   });
-   });*/
+  describe('#checkRegionServerState()', function () {
+    it('', function () {
+      expect(controller.checkRegionServerState('host1')).to.be.an('object');
+      expect(App.ajax.send.getCall(0).args[0].data.hostNames).to.equal('host1');
+    });
+  });
 
-  describe('#doRecommissionAndStart()', function () {
+  describe('#checkRegionServerStateSuccessCallback()', function () {
+    beforeEach(function () {
+      sinon.stub(controller, "doDecommissionRegionServer", Em.K);
+      sinon.stub(controller, "showRegionServerWarning", Em.K);
+    });
+    afterEach(function () {
+      controller.doDecommissionRegionServer.restore();
+      controller.showRegionServerWarning.restore();
+    });
+
+    it('Decommission all regionservers', function () {
+      var data = {
+        items: [
+          {
+            HostRoles: {
+              host_name: 'host1'
+            }
+          },
+          {
+            HostRoles: {
+              host_name: 'host2'
+            }
+          }
+        ]
+      };
+      controller.checkRegionServerStateSuccessCallback(data, {}, {hostNames: 'host1,host2'});
+      expect(controller.showRegionServerWarning.calledOnce).to.be.true;
+    });
+    it('Decommission one of two regionservers', function () {
+      var data = {
+        items: [
+          {
+            HostRoles: {
+              host_name: 'host1'
+            }
+          },
+          {
+            HostRoles: {
+              host_name: 'host2'
+            }
+          }
+        ]
+      };
+      controller.checkRegionServerStateSuccessCallback(data, {}, {hostNames: 'host1'});
+      expect(controller.doDecommissionRegionServer.calledWith('host1', "HBASE", "HBASE_MASTER",
"HBASE_REGIONSERVER")).to.be.true;
+    });
+    it('Decommission one of three regionservers', function () {
+      var data = {
+        items: [
+          {
+            HostRoles: {
+              host_name: 'host1'
+            }
+          },
+          {
+            HostRoles: {
+              host_name: 'host2'
+            }
+          },
+          {
+            HostRoles: {
+              host_name: 'host3'
+            }
+          }
+        ]
+      };
+      controller.checkRegionServerStateSuccessCallback(data, {}, {hostNames: 'host1'});
+      expect(controller.doDecommissionRegionServer.calledWith('host1', "HBASE", "HBASE_MASTER",
"HBASE_REGIONSERVER")).to.be.true;
+    });
+  });
 
+  describe('#showRegionServerWarning()', function () {
     beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
+      sinon.stub(App.ModalPopup, 'show', Em.K);
     });
     afterEach(function () {
-      App.ajax.send.restore();
+      App.ModalPopup.show.restore();
     });
+    it('', function () {
+      controller.showRegionServerWarning();
+      expect(App.ModalPopup.show.calledOnce).to.be.true;
+    });
+  });
 
+  describe('#doRecommissionAndStart()', function () {
     it('Query should be sent', function () {
       controller.doRecommissionAndStart('', '', '', '');
       expect(App.ajax.send.calledOnce).to.be.true;
@@ -882,14 +916,6 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#doRecommissionAndRestart()', function () {
-
-    beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
     it('Query should be sent', function () {
       controller.doRecommissionAndRestart('', '', '', '');
       expect(App.ajax.send.calledOnce).to.be.true;
@@ -995,14 +1021,6 @@ describe('App.MainHostDetailsController', function () {
   });
 
   describe('#hostPassiveModeRequest()', function () {
-
-    beforeEach(function () {
-      sinon.stub(App.ajax, "send", Em.K);
-    });
-    afterEach(function () {
-      App.ajax.send.restore();
-    });
-
     it('Query should be sent', function () {
       controller.hostPassiveModeRequest('', '');
       expect(App.ajax.send.calledOnce).to.be.true;
@@ -1456,11 +1474,9 @@ describe('App.MainHostDetailsController', function () {
   describe('#executeCustomCommands', function() {
     beforeEach(function () {
       sinon.spy(App, "showConfirmationPopup");
-      sinon.stub(App.ajax, "send", Em.K);
     });
     afterEach(function () {
       App.showConfirmationPopup.restore();
-      App.ajax.send.restore();
     });
 
     it('confirm popup should be displayed', function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/4862ae3b/ambari-web/test/controllers/main/host_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host_test.js b/ambari-web/test/controllers/main/host_test.js
index 6e05766..53fe019 100644
--- a/ambari-web/test/controllers/main/host_test.js
+++ b/ambari-web/test/controllers/main/host_test.js
@@ -156,4 +156,32 @@ describe('MainHostController', function () {
     });
   });
 
+  describe('#warnBeforeDecommissionSuccess()', function () {
+    var mock = {
+      showHbaseActiveWarning: Em.K,
+      checkRegionServerState: Em.K
+    };
+    beforeEach(function () {
+      hostController = App.MainHostController.create({});
+      sinon.stub(App.router, 'get', function () {
+        return mock;
+      });
+      sinon.spy(mock, 'showHbaseActiveWarning');
+      sinon.spy(mock, 'checkRegionServerState');
+    });
+    afterEach(function () {
+      App.router.get.restore();
+      mock.showHbaseActiveWarning.restore();
+      mock.checkRegionServerState.restore();
+    });
+
+    it('items length more than 0', function () {
+      hostController.warnBeforeDecommissionSuccess({items: [1]}, {}, {});
+      expect(mock.showHbaseActiveWarning.calledOnce).to.be.true;
+    });
+    it('items length equal 0', function () {
+      hostController.warnBeforeDecommissionSuccess({items: []}, {}, {hostNames: 'host1'});
+      expect(mock.checkRegionServerState.calledWith('host1')).to.be.true;
+    });
+  });
 });


Mime
View raw message