Repository: ambari
Updated Branches:
  refs/heads/trunk f1bc1bdad -> 326238b84


AMBARI-9417. Incorrect target hosts values allowable for moving HiveServer2 via 
service actions (alexantonenko)


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

Branch: refs/heads/trunk
Commit: 326238b8444a1389100fb44f1107518bb49a64b6
Parents: f1bc1bd
Author: Alex Antonenko <hiv...@gmail.com>
Authored: Fri Jan 30 18:12:28 2015 +0200
Committer: Alex Antonenko <hiv...@gmail.com>
Committed: Fri Jan 30 20:51:04 2015 +0200

----------------------------------------------------------------------
 .../main/service/reassign/step2_controller.js   |  8 ++---
 .../main/host/details/host_component.hbs        |  2 +-
 .../main/host/details/host_component_view.js    |  8 +++++
 ambari-web/app/views/main/service/item.js       |  6 ++--
 .../service/reassign/step2_controller_test.js   | 36 +++++++++-----------
 ambari-web/test/views/main/service/item_test.js | 30 ++++++++++++++--
 6 files changed, 61 insertions(+), 29 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/326238b8/ambari-web/app/controllers/main/service/reassign/step2_controller.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/app/controllers/main/service/reassign/step2_controller.js 
b/ambari-web/app/controllers/main/service/reassign/step2_controller.js
index 3902d8a..e2ed854 100644
--- a/ambari-web/app/controllers/main/service/reassign/step2_controller.js
+++ b/ambari-web/app/controllers/main/service/reassign/step2_controller.js
@@ -88,16 +88,16 @@ App.ReassignMasterWizardStep2Controller = 
App.WizardStep5Controller.extend({
       availableComponentHosts = [];
 
     this.get("hosts").forEach(function (item) {
-      if (this.get('currentHostId') !== item.get('host_name')) {
+      if ( (this.get('currentHostId') !== item.get('host_name')) && 
!(currentComponents.mapProperty("selectedHost").contains(item.get('host_name'))))
 {
         availableComponentHosts.pushObject(item);
       }
     }, this);
 
     if (availableComponentHosts.length > 0) {
-      currentComponents.forEach(function (item) {
-        var preparedAvailableHosts = availableComponentHosts.slice(0);
+      var preparedAvailableHosts = availableComponentHosts.slice(0);
 
-        if (item.get('selectedHost') === this.get('currentHostId') && 
item.get('component_name') === this.get('content.reassign.component_name')) {
+      currentComponents.forEach(function (item) {
+        if (item.get('selectedHost') === this.get('currentHostId') && 
item.get('component_name') === componentName) {
           item.set('selectedHost', 
preparedAvailableHosts.objectAt(0).host_name);
         }
         item.set("availableHosts", 
preparedAvailableHosts.sortProperty('host_name'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/326238b8/ambari-web/app/templates/main/host/details/host_component.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/host/details/host_component.hbs 
b/ambari-web/app/templates/main/host/details/host_component.hbs
index 5a2a040..419d794 100644
--- a/ambari-web/app/templates/main/host/details/host_component.hbs
+++ b/ambari-web/app/templates/main/host/details/host_component.hbs
@@ -94,7 +94,7 @@
             </li>
           {{/if}}
           {{#if view.isReassignable}}
-            <li {{bindAttr class="view.noActionAvailable"}}>
+            <li {{bindAttr class="view.noActionAvailable 
view.isMoveComponentDisabled:disabled"}}>
               <a href="javascript:void(null)" data-toggle="modal" {{action 
"moveComponent" view.content target="controller"}}>
                 {{t common.move}}
               </a>

http://git-wip-us.apache.org/repos/asf/ambari/blob/326238b8/ambari-web/app/views/main/host/details/host_component_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/host/details/host_component_view.js 
b/ambari-web/app/views/main/host/details/host_component_view.js
index 190c95c..8d7e102 100644
--- a/ambari-web/app/views/main/host/details/host_component_view.js
+++ b/ambari-web/app/views/main/host/details/host_component_view.js
@@ -193,6 +193,14 @@ App.HostComponentView = Em.View.extend({
   }.property('content'),
 
   /**
+   * Host component with some <code>workStatus</code> can't be moved (so, 
disable such action in the dropdown list)
+   * @type {bool}
+   */
+  isMoveComponentDisabled: function () {
+    return App.allHostNames.length === 
App.HostComponent.find().filterProperty('componentName', 
this.get('content.componentName')).mapProperty('hostName').length;
+  }.property('content'),
+
+  /**
    * Host component with some <code>workStatus</code> can't be deleted (so, 
disable such action in the dropdown list)
    * @type {bool}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/326238b8/ambari-web/app/views/main/service/item.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/item.js 
b/ambari-web/app/views/main/service/item.js
index 4143d03..779f45a 100644
--- a/ambari-web/app/views/main/service/item.js
+++ b/ambari-web/app/views/main/service/item.js
@@ -103,8 +103,7 @@ App.MainServiceItemView = Em.View.extend({
         action: 'reassignMaster',
         context: '',
         label: Em.I18n.t('services.service.actions.reassign.master'),
-        cssClass: 'icon-share-alt',
-        disabled: App.get('isSingleNode')
+        cssClass: 'icon-share-alt'
       },
       STARTDEMOLDAP: {
         action: 'startLdapKnox',
@@ -238,7 +237,8 @@ App.MainServiceItemView = Em.View.extend({
       }).forEach(function(master) {
         options.push(self.createOption(actionMap.MOVE_COMPONENT, {
           context: master,
-          label: actionMap.MOVE_COMPONENT.label.format(App.format.role(master))
+          label: 
actionMap.MOVE_COMPONENT.label.format(App.format.role(master)),
+          disabled: App.allHostNames.length === 
App.HostComponent.find().filterProperty('componentName', 
master).mapProperty('hostName').length
         }));
       });
       if (service.get('serviceTypes').contains('HA_MODE')) {

http://git-wip-us.apache.org/repos/asf/ambari/blob/326238b8/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
----------------------------------------------------------------------
diff --git 
a/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js 
b/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
index 8b5d8d5..15b11c3 100644
--- a/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
+++ b/ambari-web/test/controllers/main/service/reassign/step2_controller_test.js
@@ -190,28 +190,24 @@ describe('App.ReassignMasterWizardStep2Controller', 
function () {
 
     var testCases = [
       {
-        title: 'selectedHost = currentHostId and component_name = 
content.reassign.component_name',
+        title: 'selectedHost = currentHostId',
         arguments: {
-          selectedHost: 'host1',
-          reassignComponentName: 'COMP1'
+          selectedHost: 'host1'
         },
-        result: 'host3'
-      },
-      {
-        title: 'selectedHost not equal to currentHostId and component_name = 
content.reassign.component_name',
-        arguments: {
-          selectedHost: 'host2',
-          reassignComponentName: 'COMP1'
-        },
-        result: 'host2'
+        result: {
+          selectedHost: 'host3',
+          availableHosts: ['host2', 'host3']
+        }
       },
       {
-        title: 'selectedHost = currentHostId and component_name not equal to 
content.reassign.component_name',
+        title: 'selectedHost not equal to currentHostId',
         arguments: {
-          selectedHost: 'host1',
-          reassignComponentName: 'COMP2'
+          selectedHost: 'host2'
         },
-        result: 'host1'
+        result: {
+          selectedHost: 'host2',
+          availableHosts: ['host3']
+        }
       }
     ];
 
@@ -219,6 +215,9 @@ describe('App.ReassignMasterWizardStep2Controller', 
function () {
       it(test.title, function () {
         controller.set('hosts', [
           Em.Object.create({
+            host_name: 'host1'
+          }),
+          Em.Object.create({
             host_name: 'host3'
           }),
           Em.Object.create({
@@ -226,15 +225,14 @@ describe('App.ReassignMasterWizardStep2Controller', 
function () {
           })
         ]);
         controller.set('currentHostId', 'host1');
-        controller.set('content.reassign.component_name', 
test.arguments.reassignComponentName);
         controller.set('selectedServicesMasters', [Em.Object.create({
           component_name: 'COMP1',
           selectedHost: test.arguments.selectedHost
         })]);
 
         expect(controller.rebalanceSingleComponentHosts('COMP1')).to.be.true;
-        
expect(controller.get('selectedServicesMasters')[0].get('selectedHost')).to.equal(test.result);
-        
expect(controller.get('selectedServicesMasters')[0].get('availableHosts').mapProperty('host_name')).to.eql(['host2',
 'host3']);
+        
expect(controller.get('selectedServicesMasters')[0].get('selectedHost')).to.equal(test.result.selectedHost);
+        
expect(controller.get('selectedServicesMasters')[0].get('availableHosts').mapProperty('host_name')).to.eql(test.result.availableHosts);
       });
     });
   });

http://git-wip-us.apache.org/repos/asf/ambari/blob/326238b8/ambari-web/test/views/main/service/item_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/service/item_test.js 
b/ambari-web/test/views/main/service/item_test.js
index ef133db..81a9bf9 100644
--- a/ambari-web/test/views/main/service/item_test.js
+++ b/ambari-web/test/views/main/service/item_test.js
@@ -106,8 +106,8 @@ describe('App.MainServiceItemView', function () {
           result: [
             {"action": "restartAllHostComponents", "context": "HDFS", "label": 
"Restart All", "cssClass": "icon-repeat", "disabled": false},
             {"action": "rollingRestart", "label": "Restart DataNodes", 
"cssClass": "icon-time", "disabled": false, "context": "DATANODE"},
-            {"action": "reassignMaster", "context": "NAMENODE", "label": "Move 
NameNode", "cssClass": "icon-share-alt", "disabled": true},
-            {"action": "reassignMaster", "context": "SECONDARY_NAMENODE", 
"label": "Move SNameNode", "cssClass": "icon-share-alt", "disabled": true},
+            {"action": "reassignMaster", "context": "NAMENODE", "label": "Move 
NameNode", "cssClass": "icon-share-alt", "disabled": false},
+            {"action": "reassignMaster", "context": "SECONDARY_NAMENODE", 
"label": "Move SNameNode", "cssClass": "icon-share-alt", "disabled": false},
             {"action": "enableHighAvailability", "label": "Enable NameNode 
HA", "cssClass": "icon-arrow-up", "isHidden": false, "disabled": true},
             {"action": "runSmokeTest", "label": "Run Service Check", 
"cssClass": "icon-thumbs-up-alt"},
             {"action": "turnOnOffPassive", "context": "Turn On Maintenance 
Mode for HDFS", "label": "Turn On Maintenance Mode", "cssClass": "icon-medkit", 
"disabled": false},
@@ -366,6 +366,31 @@ describe('App.MainServiceItemView', function () {
         }
       });
 
+      sinon.stub(App.HostComponent, 'find', function () {
+        return [
+          Em.Object.create({
+            hostName: 'host1',
+            componentName: 'NAMENODE'
+          }),
+          Em.Object.create({
+            hostName: 'host1',
+            componentName: 'SECONDARY_NAMENODE'
+          }),
+          Em.Object.create({
+            hostName: 'host1',
+            componentName: 'APP_TIMELINE_SERVER'
+          }),
+          Em.Object.create({
+            hostName: 'host1',
+            componentName: 'RESOURCEMANAGER'
+          }),
+          Em.Object.create({
+            hostName: 'host1',
+            componentName: 'OOZIE_SERVER'
+          })
+        ];
+      });
+
       sinon.stub(App.StackServiceComponent, 'find', function () {
         switch (arguments[0]) {
           case 'NAMENODE':
@@ -400,6 +425,7 @@ describe('App.MainServiceItemView', function () {
 
     afterEach(function () {
       App.get.restore();
+      App.HostComponent.find.restore();
       App.StackServiceComponent.find.restore();
     });
 

Reply via email to