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 2018/05/14 10:25:43 UTC

[ambari] branch trunk updated: AMBARI-23813 Service actions (Stop, Start) not enabled when individual components are stopped

This is an automated email from the ASF dual-hosted git repository.

atkach pushed a commit to branch trunk
in repository https://gitbox.apache.org/repos/asf/ambari.git


The following commit(s) were added to refs/heads/trunk by this push:
     new 5bdad16  AMBARI-23813 Service actions (Stop, Start) not enabled when individual components are stopped
5bdad16 is described below

commit 5bdad16355d4c12f078ec09f0e5f18f7759c683c
Author: Andrii Tkach <at...@apache.org>
AuthorDate: Fri May 11 15:49:26 2018 +0300

    AMBARI-23813 Service actions (Stop, Start) not enabled when individual components are stopped
---
 .../app/controllers/global/update_controller.js    |  2 +-
 ambari-web/app/controllers/main/service/item.js    | 14 +----
 ambari-web/app/mappers/components_state_mapper.js  |  1 -
 ambari-web/app/models/client_component.js          |  1 -
 .../test/controllers/main/service/item_test.js     | 69 +++-------------------
 5 files changed, 11 insertions(+), 76 deletions(-)

diff --git a/ambari-web/app/controllers/global/update_controller.js b/ambari-web/app/controllers/global/update_controller.js
index 9cbb6b9..9068117 100644
--- a/ambari-web/app/controllers/global/update_controller.js
+++ b/ambari-web/app/controllers/global/update_controller.js
@@ -620,7 +620,7 @@ App.UpdateController = Em.Controller.extend({
   updateComponentsState: function (callback) {
     var testUrl = '/data/services/HDP2/components_state.json';
     var realUrl = '/components/?fields=ServiceComponentInfo/service_name,' +
-      'ServiceComponentInfo/category,ServiceComponentInfo/installed_count,ServiceComponentInfo/installed_and_maintenance_off_count,ServiceComponentInfo/started_count,ServiceComponentInfo/init_count,ServiceComponentInfo/install_failed_count,ServiceComponentInfo/unknown_count,ServiceComponentInfo/total_count,ServiceComponentInfo/display_name,host_components/HostRoles/host_name&minimal_response=true';
+      'ServiceComponentInfo/category,ServiceComponentInfo/installed_count,ServiceComponentInfo/started_count,ServiceComponentInfo/init_count,ServiceComponentInfo/install_failed_count,ServiceComponentInfo/unknown_count,ServiceComponentInfo/total_count,ServiceComponentInfo/display_name,host_components/HostRoles/host_name&minimal_response=true';
     var url = this.getUrl(testUrl, realUrl);
 
     App.HttpClient.get(url, App.componentsStateMapper, {
diff --git a/ambari-web/app/controllers/main/service/item.js b/ambari-web/app/controllers/main/service/item.js
index f5c62b3..1bc8410 100644
--- a/ambari-web/app/controllers/main/service/item.js
+++ b/ambari-web/app/controllers/main/service/item.js
@@ -1176,15 +1176,7 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     return App.MasterComponent.find().toArray().concat(App.SlaveComponent.find().toArray()).filterProperty('service.serviceName', this.get('content.serviceName'));
   }.property('content.serviceName'),
 
-  isStartDisabled: function () {
-    if(this.get('isPending')) return true;
-
-    var isDisabled = true;
-    this.get('nonClientServiceComponents').forEach(function(component) {
-      isDisabled = isDisabled ? !(component.get('installedAndMaintenanceOffCount') > 0) : false;
-    });
-    return isDisabled;
-  }.property('isPending', 'nonClientServiceComponents'),
+  isStartDisabled: Em.computed.or('isPending', 'content.isStarted'),
 
   isStopDisabled: function () {
     if(this.get('isPending')) return true;
@@ -1197,8 +1189,8 @@ App.MainServiceItemController = Em.Controller.extend(App.SupportClientConfigsDow
     if (this.get('content.serviceName') == 'PXF' && App.HostComponent.find().filterProperty('componentName', 'PXF').someProperty('workStatus', App.HostComponentStatus.started)) {
       return false;
     }
-    return (this.get('content.healthStatus') != 'green');
-  }.property('content.healthStatus','isPending', 'App.isHaEnabled'),
+    return !this.get('content.isStarted');
+  }.property('content.isStarted','isPending', 'App.isHaEnabled'),
 
   isSmokeTestDisabled: function () {
     if (this.get('isClientsOnlyService')) return false;
diff --git a/ambari-web/app/mappers/components_state_mapper.js b/ambari-web/app/mappers/components_state_mapper.js
index 771b5de..db7a7f3 100644
--- a/ambari-web/app/mappers/components_state_mapper.js
+++ b/ambari-web/app/mappers/components_state_mapper.js
@@ -31,7 +31,6 @@ App.componentsStateMapper = App.QuickDataMapper.create({
     display_name: 'ServiceComponentInfo.display_name',
     service_name: 'ServiceComponentInfo.service_name',
     installed_count: 'ServiceComponentInfo.installed_count',
-    installed_and_maintenance_off_count: 'ServiceComponentInfo.installed_and_maintenance_off_count',
     install_failed_count: 'ServiceComponentInfo.install_failed_count',
     init_count: 'ServiceComponentInfo.init_count',
     unknown_count: 'ServiceComponentInfo.unknown_count',
diff --git a/ambari-web/app/models/client_component.js b/ambari-web/app/models/client_component.js
index f802f76..23a8925 100644
--- a/ambari-web/app/models/client_component.js
+++ b/ambari-web/app/models/client_component.js
@@ -24,7 +24,6 @@ App.ClientComponent = DS.Model.extend({
   componentName: DS.attr('string'),
   displayName: DS.attr('string'),
   installedCount: DS.attr('number', {defaultValue: 0}),
-  installedAndMaintenanceOffCount: DS.attr('number', {defaultValue: 0}),
   installFailedCount: DS.attr('number', {defaultValue: 0}),
   initCount: DS.attr('number', {defaultValue: 0}),
   unknownCount: DS.attr('number', {defaultValue: 0}),
diff --git a/ambari-web/test/controllers/main/service/item_test.js b/ambari-web/test/controllers/main/service/item_test.js
index bac09b7..35d31a8 100644
--- a/ambari-web/test/controllers/main/service/item_test.js
+++ b/ambari-web/test/controllers/main/service/item_test.js
@@ -53,6 +53,10 @@ var stackServiceModel = {
 
 describe('App.MainServiceItemController', function () {
 
+  App.TestAliases.testAsComputedOr(App.MainServiceItemController.create({
+    content: Em.Object.create({serviceName: 'S1'})
+  }), 'isStartDisabled', ['isPending', 'content.isStarted']);
+
   describe('#setStartStopState', function () {
     var tests = [
       {
@@ -886,71 +890,12 @@ describe('App.MainServiceItemController', function () {
     });
   });
 
-  describe("#isStartDisabled", function () {
-    var tests = [
-      {
-        nonClientServiceComponents: [
-          Em.Object.create({
-            installedAndMaintenanceOffCount: 0,
-            installedCount: 0,
-            componentName: 'C1',
-          })
-        ],
-        isPending: true,
-        disabled: true,
-        m: "disabled because of pending"
-      },
-      {
-        nonClientServiceComponents: [
-          Em.Object.create({
-            installedAndMaintenanceOffCount: 0,
-            installedCount: 0,
-            componentName: 'C2',
-          })
-        ],
-        isPending: false,
-        disabled: true,
-        m: "disabled because no components stopped"
-      },
-      {
-        nonClientServiceComponents: [
-          Em.Object.create({
-            installedAndMaintenanceOffCount: 0,
-            installedCount: 1,
-            componentName: 'C3',
-          })
-        ],
-        isPending: false,
-        disabled: true,
-        m: "disabled because although component stopped but in maintenance mode"
-      },
-      {
-        nonClientServiceComponents: [
-          Em.Object.create({
-            installedAndMaintenanceOffCount: 2,
-            installedCount: 3,
-            componentName: 'C4',
-          })
-        ],
-        isPending: false,
-        disabled: false,
-        m: "enabled because some components stopped which are not in maintenance mode"
-      }
-    ];
-
-    tests.forEach(function (test) {
-      it(test.m, function () {
-        var mainServiceItemController = App.MainServiceItemController.create({nonClientServiceComponents: test.nonClientServiceComponents, isPending: test.isPending});
-        expect(mainServiceItemController.get('isStartDisabled')).to.equal(test.disabled);
-      });
-    });
-  });
 
   describe("#isStopDisabled", function () {
     var tests = [
       {
         content: {
-          healthStatus: 'red'
+          isStarted: false
         },
         isPending: true,
         disabled: true,
@@ -958,7 +903,7 @@ describe('App.MainServiceItemController', function () {
       },
       {
         content: {
-          healthStatus: 'green'
+          isStarted: true
         },
         isPending: false,
         disabled: false,
@@ -966,7 +911,7 @@ describe('App.MainServiceItemController', function () {
       },
       {
         content: {
-          healthStatus: 'red'
+          isStarted: false
         },
         isPending: false,
         disabled: true,

-- 
To stop receiving notification emails like this one, please contact
atkach@apache.org.