You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by am...@apache.org on 2018/08/07 11:29:36 UTC

[ambari] branch trunk updated: AMBARI-24286. Enabling Hive Server Interactive doesn't work with ONEFS (amagyar) (#1895)

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

amagyar 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 ab1dbe0  AMBARI-24286. Enabling Hive Server Interactive doesn't work with ONEFS (amagyar) (#1895)
ab1dbe0 is described below

commit ab1dbe0b665e864d16bf184f10aabca2c6d90799
Author: Attila Magyar <m....@gmail.com>
AuthorDate: Tue Aug 7 13:29:34 2018 +0200

    AMBARI-24286. Enabling Hive Server Interactive doesn't work with ONEFS (amagyar) (#1895)
---
 ambari-web/app/controllers/main/host/details.js    |  4 +++-
 .../wizard/step7/assign_master_controller.js       | 12 +++++-----
 .../configs/component_actions_by_configs.js        |  6 +++--
 ambari-web/app/models/stack_service_component.js   | 26 +++++++++++++++++++++-
 .../test/controllers/main/host/details_test.js     | 10 +++++++++
 .../wizard/step7/assign_master_controller_test.js  | 11 ++++++---
 .../configs/component_actions_by_configs_test.js   | 20 +++++++++++------
 7 files changed, 70 insertions(+), 19 deletions(-)

diff --git a/ambari-web/app/controllers/main/host/details.js b/ambari-web/app/controllers/main/host/details.js
index fe08664..2c5ebee 100644
--- a/ambari-web/app/controllers/main/host/details.js
+++ b/ambari-web/app/controllers/main/host/details.js
@@ -3001,7 +3001,9 @@ App.MainHostDetailsController = Em.Controller.extend(App.SupportClientConfigsDow
         break;
     }
     var component = App.StackServiceComponent.find(componentName);
-    return component.missingDependencies(installedComponents, opt);
+    return component.missingDependencies(installedComponents, opt).map(function(componentDependency) {
+      return componentDependency.chooseCompatible();
+    });
   },
 
   /**
diff --git a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
index 6d5b46d..0fca8c6 100644
--- a/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
+++ b/ambari-web/app/controllers/wizard/step7/assign_master_controller.js
@@ -354,12 +354,14 @@ App.AssignMasterOnStep7Controller = Em.Controller.extend(App.BlueprintMixin, App
   getAllMissingDependentServices: function () {
     var configActionComponentName = this.get('configActionComponent').componentName;
     var componentStackService = App.StackServiceComponent.find(configActionComponentName).get('stackService');
-    var dependentServices = componentStackService.get('requiredServices');
+    var missing = [];
+    componentStackService.collectMissingDependencies(this.installedStackServices(), App.StackService.find(), missing);
+    return missing.mapProperty('displayName');
+  },
 
-    return dependentServices.filter(function (item) {
-      return !App.Service.find().findProperty('serviceName', item);
-    }).map(function (item) {
-      return App.StackService.find(item).get('displayName');
+  installedStackServices: function() {
+    return App.Service.find().map(function(each) {
+      return App.StackService.find(each.get('serviceName'));
     });
   },
 
diff --git a/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js b/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js
index 9efeb97..dd056b3 100644
--- a/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js
+++ b/ambari-web/app/mixins/main/service/configs/component_actions_by_configs.js
@@ -315,9 +315,11 @@ App.ComponentActionsByConfigs = Em.Mixin.create({
     var dependentComponents = [];
 
     componentsToAdd.forEach(function (_component) {
-      var dependencies = App.StackServiceComponent.find(_component.componentName).get('dependencies').filterProperty('scope', 'host').map(function (_dependency) {
+      var componentToAdd = App.StackServiceComponent.find(_component.componentName);
+      var installedComponents = App.HostComponent.find().filterProperty('hostName', _component.hostName).mapProperty('componentName').uniq();
+      var dependencies = componentToAdd.missingDependencies(installedComponents, {'scope': 'host'}).map(function (_dependency) {
         return {
-          componentName: _dependency.componentName,
+          componentName: _dependency.chooseCompatible(),
           hostName: _component.hostName,
           isClient: App.StackServiceComponent.find(_dependency.componentName).get('isClient')
         }
diff --git a/ambari-web/app/models/stack_service_component.js b/ambari-web/app/models/stack_service_component.js
index 8d72edb..efd473e 100644
--- a/ambari-web/app/models/stack_service_component.js
+++ b/ambari-web/app/models/stack_service_component.js
@@ -18,6 +18,22 @@
 
 var App = require('app');
 var numberUtils = require('utils/number_utils');
+
+var ComponentDependency = Ember.Object.extend({
+  componentName: null,
+  compatibleComponents: [],
+
+  /**
+   * Find the first compatible component which belongs to a service that is installed
+   */
+  chooseCompatible: function() {
+    var compatibleComponent = this.get('compatibleComponents').find(function(component) {
+      return App.Service.find().someProperty('serviceName', component.get('serviceName'))
+    });
+    return (compatibleComponent ? compatibleComponent : this.get('compatibleComponents')[0]).get('componentName');
+  }
+});
+
 /**
  * This model loads all serviceComponents supported by the stack
  * @type {*}
@@ -87,11 +103,19 @@ App.StackServiceComponent = DS.Model.extend({
     dependencies = opt.scope === '*' ? dependencies : dependencies.filterProperty('scope', opt.scope);
     if (dependencies.length === 0) return [];
     installedComponents = installedComponents.map(function(each) { return App.StackServiceComponent.find(each); });
-    return dependencies.filter(function (dependency) {
+    var missingComponents = dependencies.filter(function (dependency) {
       return !installedComponents.some(function(each) {
         return each.compatibleWith(App.StackServiceComponent.find(dependency.componentName));
       });
     }).mapProperty('componentName');
+    return missingComponents.map(function (missingComponentName) {
+      return ComponentDependency.create({
+        'componentName': missingComponentName,
+        'compatibleComponents': App.StackServiceComponent.find().filter(function (each) {
+          return each.compatibleWith(App.StackServiceComponent.find(missingComponentName));
+        })
+      });
+    });
   },
 
   /** @property {Boolean} isRequired - component required to install **/
diff --git a/ambari-web/test/controllers/main/host/details_test.js b/ambari-web/test/controllers/main/host/details_test.js
index 845c811..2838f79 100644
--- a/ambari-web/test/controllers/main/host/details_test.js
+++ b/ambari-web/test/controllers/main/host/details_test.js
@@ -3711,6 +3711,11 @@ describe('App.MainHostDetailsController', function () {
     });
     it("dependecies should be added", function () {
       var opt = {scope: '*', installedComponents: ['C2']};
+      this.mock.returns([
+        App.StackServiceComponent.createRecord({componentName: 'C1'}),
+        App.StackServiceComponent.createRecord({componentName: 'C2'}),
+        App.StackServiceComponent.createRecord({componentName: 'C3'})
+      ]);
       this.mock.withArgs('C1').returns(App.StackServiceComponent.createRecord({
         dependencies: [{componentName: 'C3'}]
       }));
@@ -3729,6 +3734,11 @@ describe('App.MainHostDetailsController', function () {
     });
     it("scope is host", function () {
       var opt = {scope: 'host', hostName: 'host1'};
+      this.mock.returns([
+        App.StackServiceComponent.createRecord({componentName: 'C1'}),
+        App.StackServiceComponent.createRecord({componentName: 'C2'}),
+        App.StackServiceComponent.createRecord({componentName: 'C3'})
+      ]);
       this.mock.withArgs('C1').returns(App.StackServiceComponent.createRecord({
         dependencies: [{componentName: 'C3', scope: 'host'}]
       }));
diff --git a/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
index d6aa55c..16c9681 100644
--- a/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
+++ b/ambari-web/test/controllers/wizard/step7/assign_master_controller_test.js
@@ -299,15 +299,20 @@ describe('App.AssignMasterOnStep7Controller', function () {
 
     beforeEach(function() {
       sinon.stub(App.StackServiceComponent, 'find').returns(Em.Object.create({
-        stackService: Em.Object.create({
+        stackService: App.StackService.createRecord({
           requiredServices: ['S1', 'S2']
         })
       }));
       sinon.stub(App.Service, 'find').returns([
-        {serviceName: 'S1'}
+        App.Service.createRecord({serviceName: 'S1'})
       ]);
       sinon.stub(App.StackService, 'find', function(input) {
-        return Em.Object.create({displayName: input});
+        return input
+          ? Em.Object.create({displayName: input, serviceName: input})
+          : [
+              App.StackService.createRecord({serviceName: 'S1', displayName: 'S1'}),
+              App.StackService.createRecord({serviceName: 'S2', displayName: 'S2'})
+            ]
       });
     });
 
diff --git a/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js b/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js
index 7c58b62..b19d20f 100644
--- a/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js
+++ b/ambari-web/test/mixins/main/service/configs/component_actions_by_configs_test.js
@@ -298,13 +298,19 @@ describe('App.ComponentActionsByConfigs', function () {
   describe("#getDependentComponents()", function () {
 
     beforeEach(function() {
-      sinon.stub(App.StackServiceComponent, 'find').returns(Em.Object.create({
-        dependencies: [{
-          scope: 'host',
-          componentName: 'C2'
-        }],
-        isClient: false
-      }));
+      var mock = sinon.stub(App.StackServiceComponent, 'find');
+      mock.returns([
+        App.StackServiceComponent.createRecord({componentName: 'C1'}),
+        App.StackServiceComponent.createRecord({componentName: 'C2'})
+      ]);
+      mock.withArgs('C1').returns(
+        App.StackServiceComponent.createRecord({
+          componentName: 'C1',
+          dependencies: [{ scope: 'host', componentName: 'C2' }],
+          isClient: false
+        })
+      );
+      mock.withArgs('C2').returns(App.StackServiceComponent.createRecord({componentName: 'C2'}));
       sinon.stub(App.HostComponent, 'find').returns([]);
     });