You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ab...@apache.org on 2014/05/08 18:40:44 UTC

git commit: AMBARI-5713 Add Service wizard: Hive Server fails to start. (ababiichuk)

Repository: ambari
Updated Branches:
  refs/heads/branch-1.6.0 4f5478d10 -> c41d221ca


AMBARI-5713 Add Service wizard: Hive Server fails to start. (ababiichuk)


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

Branch: refs/heads/branch-1.6.0
Commit: c41d221ca80ab6ff11a89deec1036c4314a4ba83
Parents: 4f5478d
Author: aBabiichuk <ab...@cybervisiontech.com>
Authored: Thu May 8 19:36:54 2014 +0300
Committer: aBabiichuk <ab...@cybervisiontech.com>
Committed: Thu May 8 19:36:54 2014 +0300

----------------------------------------------------------------------
 .../controllers/main/service/add_controller.js  | 33 +++++++++++++++-
 .../app/controllers/wizard/step8_controller.js  | 35 ++++++++++++++---
 .../main/service/add_controller_test.js         | 40 ++++++++++++++++++++
 3 files changed, 101 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/c41d221c/ambari-web/app/controllers/main/service/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/service/add_controller.js b/ambari-web/app/controllers/main/service/add_controller.js
index c0f5f9b..51e878a 100644
--- a/ambari-web/app/controllers/main/service/add_controller.js
+++ b/ambari-web/app/controllers/main/service/add_controller.js
@@ -52,7 +52,8 @@ App.AddServiceController = App.WizardController.extend({
     serviceConfigProperties: null,
     advancedServiceConfig: null,
     controllerName: 'addServiceController',
-    configGroups: []
+    configGroups: [],
+    additionalClients: []
   }),
 
   setCurrentStep: function (currentStep, completed) {
@@ -279,6 +280,7 @@ App.AddServiceController = App.WizardController.extend({
       case '6':
       case '5':
         this.load('cluster');
+        this.set('content.additionalClients', []);
       case '4':
         this.loadServiceConfigGroups();
         this.loadServiceConfigProperties();
@@ -319,6 +321,7 @@ App.AddServiceController = App.WizardController.extend({
     var clusterName = this.get('content.cluster.name');
     var data;
     var name;
+    this.installAdditionalClients();
     if (isRetry) {
       this.getFailedHostComponents();
       console.log('failedHostComponents', this.get('failedHostComponents'));
@@ -353,6 +356,34 @@ App.AddServiceController = App.WizardController.extend({
   },
 
   /**
+   * installs clients before install new services
+   * on host where some components require this
+   * @method installAdditionalClients
+   */
+  installAdditionalClients: function() {
+      this.get('content.additionalClients').forEach(function(c){
+        App.ajax.send({
+          name: 'host.host_component.install',
+          sender: this,
+          data: {
+            hostName: c.hostName,
+            componentName: c.componentName,
+            data: JSON.stringify({
+              RequestInfo: {
+                "context": Em.I18n.t('requestInfo.installHostComponent') + " " + c.hostName
+              },
+              Body: {
+                HostRoles: {
+                  state: 'INSTALLED'
+                }
+              }
+            })
+          }
+        });
+      }, this);
+  },
+
+  /**
    * List of failed to install HostComponents while adding Service
    */
   failedHostComponents: [],

http://git-wip-us.apache.org/repos/asf/ambari/blob/c41d221c/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index 7585476..4aadcda 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -1203,12 +1203,35 @@ App.WizardStep8Controller = Em.Controller.extend({
           hostNames = hostNames.uniq();
 
           if (_client.isInstalled) {
-            //check whether clients are already installed on selected master hosts!!!
-            _slave.hosts.filterProperty('isInstalled', true).mapProperty('hostName').forEach(function (host) {
-              if (hostNames.contains(host)) {
-                hostNames.splice(hostNames.indexOf(host), 1);
-              }
-            }, this);
+            /**
+             * check whether clients are already installed on selected master hosts!!!
+             */
+            var clientHosts = App.HostComponent.find().filterProperty("componentName",_client.component_name).filterProperty("workStatus", "INSTALLED");
+            if (clientHosts.length>0) {
+              clientHosts.mapProperty('host.hostName').forEach(function (host) {
+                if (hostNames.contains(host)) {
+                  hostNames.splice(hostNames.indexOf(host), 1);
+                }
+              }, this);
+            }
+            /**
+             * For Add Service Only
+             * if client is not added to host or is not installed add Object
+             * {
+             *    componentName: {String},
+             *    hostName: {String}
+             * }
+             * to content.additionalClients
+             * later it will be used to install client on host before istalling new services
+             */
+            if (this.get('content.controllerName') === 'addServiceController' && hostNames.length > 0) {
+                hostNames.forEach(function (hostName) {
+                this.get('content.additionalClients').push(Em.Object.create({
+                  componentName: _client.component_name, hostName: hostName
+                }))
+              }, this)
+
+            }
           }
 
           this.registerHostsToComponent(hostNames, _client.component_name);

http://git-wip-us.apache.org/repos/asf/ambari/blob/c41d221c/ambari-web/test/controllers/main/service/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/service/add_controller_test.js b/ambari-web/test/controllers/main/service/add_controller_test.js
index 2a2caaa..8b6b9b9 100644
--- a/ambari-web/test/controllers/main/service/add_controller_test.js
+++ b/ambari-web/test/controllers/main/service/add_controller_test.js
@@ -19,9 +19,14 @@
 var App = require('app');
 require('controllers/wizard');
 require('controllers/main/service/add_controller');
+var addServiceController = null;
 
 describe('App.AddServiceController', function() {
 
+  beforeEach(function () {
+    addServiceController = App.AddServiceController.create({});
+  });
+
   describe('#isServiceConfigurable', function() {
     var tests = [
       {
@@ -119,4 +124,39 @@ describe('App.AddServiceController', function() {
     });
   });
 
+  describe('#installAdditionalClients', function() {
+
+    var t = {
+      additionalClients: {
+        componentName: "TEZ_CLIENT",
+        hostName: "hostName"
+      },
+      RequestInfo: {
+        "context": Em.I18n.t('requestInfo.installHostComponent') + " hostName"
+      },
+      Body: {
+        HostRoles: {
+          state: 'INSTALLED'
+        }
+      }
+    };
+
+    beforeEach(function () {
+      sinon.spy($, 'ajax');
+    });
+
+    afterEach(function () {
+      $.ajax.restore();
+    });
+
+    it('send request to install client', function () {
+      addServiceController.set("content.additionalClients", [t.additionalClients]);
+      addServiceController.installAdditionalClients();
+      expect($.ajax.calledOnce).to.equal(true);
+
+      expect(JSON.parse($.ajax.args[0][0].data).Body).to.deep.eql(t.Body);
+      expect(JSON.parse($.ajax.args[0][0].data).RequestInfo).to.eql(t.RequestInfo);
+    });
+  });
+
 });