ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jai...@apache.org
Subject ambari git commit: Revert "AMBARI-17841. UI does not allow to delete service is some host components are in INSTALLED_FAILED state. (jaimin)"
Date Tue, 26 Jul 2016 00:33:46 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 4c193da25 -> 3867d3955


Revert "AMBARI-17841. UI does not allow to delete service is some host components are in INSTALLED_FAILED
state. (jaimin)"

This reverts commit 1e05dc2d092e0759fce60d9ad5eaaae04dc6988a.


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

Branch: refs/heads/trunk
Commit: 3867d39559868403a4c41666f6cb27f4c769c599
Parents: 4c193da
Author: Jaimin Jetly <jaimin@hortonworks.com>
Authored: Mon Jul 25 17:34:06 2016 -0700
Committer: Jaimin Jetly <jaimin@hortonworks.com>
Committed: Mon Jul 25 17:34:06 2016 -0700

----------------------------------------------------------------------
 ambari-web/app/models/client_component.js | 21 +++++++++++++++++
 ambari-web/app/models/host_component.js   | 21 +----------------
 ambari-web/app/models/service.js          | 12 +++++-----
 ambari-web/test/models/service_test.js    | 31 +++++++++++++++++++-------
 4 files changed, 51 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/3867d395/ambari-web/app/models/client_component.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/client_component.js b/ambari-web/app/models/client_component.js
index 7dde68a..3902227 100644
--- a/ambari-web/app/models/client_component.js
+++ b/ambari-web/app/models/client_component.js
@@ -29,6 +29,27 @@ App.ClientComponent = DS.Model.extend({
   stackInfo: DS.belongsTo('App.StackServiceComponent'),
   hostNames: DS.attr('array'),
 
+  /**
+   * Defines if all components are in 'INSTALLED' state
+   *
+   * @type {boolean}
+   */
+  allStopped: Em.computed.equalProperties('installedCount', 'totalCount'),
+
+  /**
+   * No stated and no installed component
+   *
+   * @type {boolean}
+   */
+  noOneInstalled: Em.computed.and('!installedCount', '!startedCount'),
+
+  /**
+   * Determines if component may be deleted
+   *
+   * @type {boolean}
+   */
+  allowToDelete: Em.computed.or('allStopped', 'noOneInstalled'),
+
   summaryLabelClassName:function(){
     return 'label_for_'+this.get('componentName').toLowerCase();
   }.property('componentName'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/3867d395/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 d8962ef..91642c9 100644
--- a/ambari-web/app/models/host_component.js
+++ b/ambari-web/app/models/host_component.js
@@ -158,16 +158,7 @@ App.HostComponent = DS.Model.extend({
 
   componentTextStatus: function () {
     return App.HostComponentStatus.getTextStatus(this.get("workStatus"));
-  }.property('workStatus', 'isDecommissioning'),
-
-  /**
-   * Check if hostComponent is in a valid state in which it can be deleted
-   * @type {boolean}
-   */
-  allowToDelete: function() {
-    var workStatus = this.get('workStatus');
-    return App.HostComponent.allowDeleteStates.contains(workStatus);
-  }.property('workStatus')
+  }.property('workStatus', 'isDecommissioning')
 });
 
 App.HostComponent.FIXTURES = [];
@@ -278,16 +269,6 @@ App.HostComponentStatus = {
   }
 };
 
-/**
- * @type {String[]}
- */
-App.HostComponent.allowDeleteStates = [
-  App.HostComponentStatus.init,
-  App.HostComponentStatus.install_failed,
-  App.HostComponentStatus.stopped,
-  App.HostComponentStatus.unknown
-];
-
 App.HostComponentActionMap = {
   getMap: function(ctx) {
     var NN = ctx.get('controller.content.hostComponents').findProperty('componentName', 'NAMENODE');

http://git-wip-us.apache.org/repos/asf/ambari/blob/3867d395/ambari-web/app/models/service.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/models/service.js b/ambari-web/app/models/service.js
index 775b084..c648e93 100644
--- a/ambari-web/app/models/service.js
+++ b/ambari-web/app/models/service.js
@@ -41,17 +41,17 @@ App.Service = DS.Model.extend({
   masterComponents: DS.hasMany('App.MasterComponent'),
 
   /**
-   * Check each host component state of service
+   * Check master/slave component state of service
    * and general services state to define if it can be removed
    *
    * @type {boolean}
    */
   allowToDelete: function() {
     var workStatus = this.get('workStatus');
-    var isDeleteAllowedAtServiceLevel = App.Service.allowDeleteStates.contains(workStatus);
-    var isDeleteAllowedAtComponentLevel = this.get('hostComponents').everyProperty('allowToDelete',
true);
-    return isDeleteAllowedAtServiceLevel && isDeleteAllowedAtComponentLevel;
-  }.property('hostComponents.@each.allowToDelete', 'workStatus'),
+    return App.Service.allowUninstallStates.contains(workStatus)
+      && this.get('slaveComponents').everyProperty('allowToDelete')
+      && this.get('masterComponents').everyProperty('allowToDelete');
+  }.property('slaveComponents.@each.allowToDelete', 'masterComponents.@each.allowToDelete',
'workStatus'),
 
   /**
    * @type {bool}
@@ -205,7 +205,7 @@ App.Service.inProgressStates = [
 /**
  * @type {String[]}
  */
-App.Service.allowDeleteStates = [
+App.Service.allowUninstallStates = [
   App.Service.statesMap.init,
   App.Service.statesMap.install_failed,
   App.Service.statesMap.stopped,

http://git-wip-us.apache.org/repos/asf/ambari/blob/3867d395/ambari-web/test/models/service_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/models/service_test.js b/ambari-web/test/models/service_test.js
index 456bf51..e527e1e 100644
--- a/ambari-web/test/models/service_test.js
+++ b/ambari-web/test/models/service_test.js
@@ -200,50 +200,65 @@ describe('App.Service', function () {
     Em.A([
       {
         m: 'may be deleted (1)',
-        hostComponents: [Em.Object.create({allowToDelete: true})],
+        slaveComponents: [{allowToDelete: true}],
+        masterComponents: [{allowToDelete: true}],
         workStatus: 'INIT',
         e: true
       },
       {
         m: 'may be deleted (2)',
-        hostComponents: [Em.Object.create({allowToDelete: true})],
+        slaveComponents: [{allowToDelete: true}],
+        masterComponents: [{allowToDelete: true}],
         workStatus: 'INSTALL_FAILED',
         e: true
       },
       {
         m: 'may be deleted (3)',
-        hostComponents: [Em.Object.create({allowToDelete: true})],
+        slaveComponents: [{allowToDelete: true}],
+        masterComponents: [{allowToDelete: true}],
         workStatus: 'INSTALLED',
         e: true
       },
       {
         m: 'may be deleted (4)',
-        hostComponents: [Em.Object.create({allowToDelete: true})],
+        slaveComponents: [{allowToDelete: true}],
+        masterComponents: [{allowToDelete: true}],
         workStatus: 'UNKNOWN',
         e: true
       },
       {
         m: 'deleting is not allowed (1)',
-        hostComponents: [Em.Object.create({allowToDelete: false})],
+        slaveComponents: [{allowToDelete: false}],
+        masterComponents: [{allowToDelete: true}],
         workStatus: 'UNKNOWN',
         e: false
       },
       {
         m: 'deleting is not allowed (2)',
-        hostComponents: [Em.Object.create({allowToDelete: false})],
+        slaveComponents: [{allowToDelete: false}],
+        masterComponents: [{allowToDelete: false}],
         workStatus: 'UNKNOWN',
         e: false
       },
       {
         m: 'deleting is not allowed (3)',
-        hostComponents: [Em.Object.create({allowToDelete: true})],
+        slaveComponents: [{allowToDelete: true}],
+        masterComponents: [{allowToDelete: false}],
+        workStatus: 'UNKNOWN',
+        e: false
+      },
+      {
+        m: 'deleting is not allowed (4)',
+        slaveComponents: [{allowToDelete: true}],
+        masterComponents: [{allowToDelete: true}],
         workStatus: 'STARTED',
         e: false
       }
     ]).forEach(function (test) {
       it(test.m, function () {
         this.stub.withArgs('workStatus').returns(test.workStatus);
-        this.stub.withArgs('hostComponents').returns(test.hostComponents);
+        this.stub.withArgs('slaveComponents').returns(test.slaveComponents);
+        this.stub.withArgs('masterComponents').returns(test.masterComponents);
         expect(Em.get(service, 'allowToDelete')).to.be.equal(test.e);
       });
     });


Mime
View raw message