ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dbuz...@apache.org
Subject ambari git commit: AMBARI-20059 Storm config change results in Consistency check failed (dbuzhor)
Date Fri, 17 Feb 2017 08:26:49 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.5 924f9964a -> d0eb7db6f


AMBARI-20059 Storm config change results in Consistency check failed (dbuzhor)


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

Branch: refs/heads/branch-2.5
Commit: d0eb7db6feb2993e3133bcaa633f16111630e116
Parents: 924f996
Author: Denys Buzhor <bdenys@hortonworks.com>
Authored: Fri Feb 17 00:43:52 2017 +0200
Committer: Denys Buzhor <bdenys@hortonworks.com>
Committed: Fri Feb 17 10:19:35 2017 +0200

----------------------------------------------------------------------
 .../controllers/main/service/info/configs.js    | 35 +++++++++++++--
 .../app/mixins/common/track_request_mixin.js    |  5 +++
 .../main/service/info/config_test.js            | 45 ++++++++++++++++++++
 3 files changed, 81 insertions(+), 4 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/d0eb7db6/ambari-web/app/controllers/main/service/info/configs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/info/configs.js b/ambari-web/app/controllers/main/service/info/configs.js
index 7f2c9c5..32062e8 100644
--- a/ambari-web/app/controllers/main/service/info/configs.js
+++ b/ambari-web/app/controllers/main/service/info/configs.js
@@ -279,6 +279,36 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.AddSecurityConfi
   isInit: true,
 
   /**
+   * Returns dependencies at all levels for service including dependencies for its childs,
children dependencies
+   * and so on.
+   *
+   * @param  {String} serviceName name of services to get dependencies
+   * @returns {String[]}
+   */
+  getServicesDependencies: function(serviceName) {
+    var dependencies = Em.getWithDefault(App.StackService.find(serviceName), 'dependentServiceNames',
[]);
+    var loop = function(dependentServices, allDependencies) {
+      return dependentServices.reduce(function(all, name) {
+        var service = App.StackService.find(name);
+        if (!service) {
+          return all;
+        }
+        var serviceDependencies = service.get('dependentServiceNames');
+        if (!serviceDependencies.length) {
+          return all.concat(name);
+        }
+        var missed = _.intersection(_.difference(serviceDependencies, all), serviceDependencies);
+        if (missed.length) {
+          return loop(missed, all.concat(missed));
+        }
+        return all;
+      }, allDependencies || dependentServices);
+    };
+
+    return loop(dependencies).uniq().without(serviceName).toArray();
+  },
+
+  /**
    * On load function
    * @method loadStep
    */
@@ -286,10 +316,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend(App.AddSecurityConfi
     var serviceName = this.get('content.serviceName'), self = this;
     App.router.get('mainController').stopPolling();
     this.clearStep();
-    this.set('dependentServiceNames', (App.StackService.find(serviceName).get('dependentServiceNames')
|| []).reduce(function(acc, i) {
-      acc.push(i);
-      return Array.prototype.concat.apply(acc, App.StackService.find(i).get('dependentServiceNames').toArray()).without(serviceName).uniq();
-    }, []));
+    this.set('dependentServiceNames', this.getServicesDependencies(serviceName));
     this.trackRequestChain(this.loadConfigTheme(serviceName).always(function () {
       if (self.get('preSelectedConfigVersion')) {
         self.loadPreSelectedConfigVersion();

http://git-wip-us.apache.org/repos/asf/ambari/blob/d0eb7db6/ambari-web/app/mixins/common/track_request_mixin.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/mixins/common/track_request_mixin.js b/ambari-web/app/mixins/common/track_request_mixin.js
index 4efcecb..c665253 100644
--- a/ambari-web/app/mixins/common/track_request_mixin.js
+++ b/ambari-web/app/mixins/common/track_request_mixin.js
@@ -22,6 +22,11 @@ App.TrackRequestMixin = Em.Mixin.create({
 
   requestsInProgress: [],
 
+  init: function() {
+    this.set('requestsInProgress', []);
+    this._super([].slice.call(arguments));
+  },
+
   /**
    * register request to view to track his progress
    * @param {$.ajax} request

http://git-wip-us.apache.org/repos/asf/ambari/blob/d0eb7db6/ambari-web/test/controllers/main/service/info/config_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/info/config_test.js b/ambari-web/test/controllers/main/service/info/config_test.js
index 7a70127..09772ff 100644
--- a/ambari-web/test/controllers/main/service/info/config_test.js
+++ b/ambari-web/test/controllers/main/service/info/config_test.js
@@ -1045,4 +1045,49 @@ describe("App.MainServiceInfoConfigsController", function () {
 
   });
 
+  describe('#getServicesDependencies', function() {
+    var createService = function(serviceName, dependencies) {
+      return Em.Object.create({
+        serviceName: serviceName,
+        dependentServiceNames: dependencies || []
+      });
+    };
+    var stackServices = [
+      createService('STORM', ['RANGER', 'ATLAS', 'ZOOKEEPER']),
+      createService('RANGER', ['HIVE', 'HDFS']),
+      createService('HIVE', ['YARN']),
+      createService('ZOOKEEPER', ['HDFS']),
+      createService('ATLAS'),
+      createService('HDFS', ['ZOOKEEPER']),
+      createService('YARN', ['HIVE'])
+    ];
+    beforeEach(function() {
+      sinon.stub(App.StackService, 'find', function(serviceName) {
+        return stackServices.findProperty('serviceName', serviceName);
+      });
+    });
+    afterEach(function() {
+      App.StackService.find.restore();
+    });
+
+    it('should returns all service dependencies STORM service', function() {
+      var result = mainServiceInfoConfigsController.getServicesDependencies('STORM');
+      expect(result).to.be.eql(['RANGER', 'ATLAS', 'ZOOKEEPER', 'HIVE', 'HDFS', 'YARN']);
+    });
+
+    it('should returns all service dependencies for ATLAS', function() {
+      var result = mainServiceInfoConfigsController.getServicesDependencies('ATLAS');
+      expect(result).to.be.eql([]);
+    });
+
+    it('should returns all service dependencies for RANGER', function() {
+      var result = mainServiceInfoConfigsController.getServicesDependencies('RANGER');
+      expect(result).to.be.eql(['HIVE', 'HDFS', 'YARN', 'ZOOKEEPER']);
+    });
+
+    it('should returns all service dependencies for YARN', function() {
+      var result = mainServiceInfoConfigsController.getServicesDependencies('YARN');
+      expect(result).to.be.eql(['HIVE']);
+    });
+  });
 });


Mime
View raw message