ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject [1/2] git commit: AMBARI-8061 Add host with Clients component is not including Hive Client. (ababiichuk)
Date Fri, 31 Oct 2014 16:30:51 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk 930bbaa18 -> 0af0d9b3c


AMBARI-8061 Add host with Clients component is not including Hive Client. (ababiichuk)


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

Branch: refs/heads/trunk
Commit: fb5dca7db8dc8cecae8c58dcb963841a33a5e501
Parents: 930bbaa
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Fri Oct 31 16:17:19 2014 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Fri Oct 31 18:29:22 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/main/host/add_controller.js | 40 ++++++++++-----
 .../main/host/add_controller_test.js            | 52 ++++++++++++++++++++
 2 files changed, 79 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/fb5dca7d/ambari-web/app/controllers/main/host/add_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/host/add_controller.js b/ambari-web/app/controllers/main/host/add_controller.js
index 2876b0b..d290604 100644
--- a/ambari-web/app/controllers/main/host/add_controller.js
+++ b/ambari-web/app/controllers/main/host/add_controller.js
@@ -159,26 +159,40 @@ App.AddHostController = App.WizardController.extend({
    * Generate clients list for selected services and save it to model
    */
   saveClients: function () {
-    var clients = [];
     var serviceComponents = App.StackServiceComponent.find();
-    var hosts = this.get('content.hosts');
-
-    this.get('content.services').filterProperty('isSelected').forEach(function (_service)
{
-      var client = serviceComponents.filterProperty('serviceName', _service.get('serviceName')).findProperty('isClient');
-      if (client) {
-        clients.push({
-          component_name: client.get('componentName'),
-          display_name: client.get('displayName'),
-          isInstalled: false
-        });
-      }
-    }, this);
+    var services = this.get('content.services').filterProperty('isSelected');
+    var clients = this.getClientsToInstall(services, serviceComponents);
     this.setDBProperty('clientInfo', clients);
     this.set('content.clients', clients);
     console.log("AddHostController.saveClients: saved list ", clients);
   },
 
   /**
+   * get list of clients which will be installed on host
+   * @param services {Array} of service objects
+   * @param components {Array} of component objects
+   * @returns {Array} returns array of clients
+   * @method getClientsToInstall;
+   */
+  getClientsToInstall: function(services, components) {
+    var clients = [];
+    services.forEach(function (_service) {
+      var serviceClients = components.filter(function(component) {
+        return (component.get('serviceName') == _service.get('serviceName') && component.get('isClient'));
+      });
+      if (serviceClients.length) {
+        serviceClients.forEach(function(client) {
+          clients.push({
+            component_name: client.get('componentName'),
+            display_name: client.get('displayName'),
+            isInstalled: false
+          });
+        });
+      }
+    }, this);
+    return clients;
+  },
+  /**
    *  Apply config groups from step4 Configurations
    */
   applyConfigGroup: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/fb5dca7d/ambari-web/test/controllers/main/host/add_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/host/add_controller_test.js b/ambari-web/test/controllers/main/host/add_controller_test.js
index f1ce854..284070f 100644
--- a/ambari-web/test/controllers/main/host/add_controller_test.js
+++ b/ambari-web/test/controllers/main/host/add_controller_test.js
@@ -329,4 +329,56 @@ describe('App.AddHostController', function () {
       expect(App.ajax.send.called).to.be.true;
     });
   });
+
+  describe('#getClientsToInstall', function () {
+    var services = [
+      Em.Object.create({
+        serviceName: 'service1'
+      }),
+      Em.Object.create({
+        serviceName: 'service2'
+      })
+    ];
+    var components = [
+      Em.Object.create({
+        componentName: 'comp1',
+        displayName: 'comp1',
+        serviceName: 'service1',
+        isClient: true
+      }),
+      Em.Object.create({
+        componentName: 'comp2',
+        displayName: 'comp2',
+        serviceName: 'service1',
+        isClient: true
+      }),
+      Em.Object.create({
+        componentName: 'comp3',
+        displayName: 'comp3',
+        serviceName: 'service2',
+        isClient: false
+      }),
+      Em.Object.create({
+        componentName: 'comp4',
+        displayName: 'comp4',
+        serviceName: 'service3',
+        isClient: true
+      })
+    ];
+    var clients = [
+      {
+        component_name: 'comp1',
+        display_name: 'comp1',
+        isInstalled: false
+      },
+      {
+        component_name: 'comp2',
+        display_name: 'comp2',
+        isInstalled: false
+      }
+    ];
+    it("generatel list of clients to install", function () {
+      expect(controller.getClientsToInstall(services, components)).to.eql(clients);
+    })
+  })
 });


Mime
View raw message