You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2014/02/27 16:10:59 UTC

git commit: AMBARI-4867 Add Host: deleted hosts handled as installed. (atkach)

Repository: ambari
Updated Branches:
  refs/heads/trunk 30c81a603 -> 9eef77a0e


AMBARI-4867 Add Host: deleted hosts handled as installed. (atkach)


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

Branch: refs/heads/trunk
Commit: 9eef77a0e2c1af62c356abac343eaec642bf702f
Parents: 30c81a6
Author: atkach <at...@hortonworks.com>
Authored: Thu Feb 27 17:06:55 2014 +0200
Committer: atkach <at...@hortonworks.com>
Committed: Thu Feb 27 17:10:56 2014 +0200

----------------------------------------------------------------------
 .../app/controllers/main/host/add_controller.js | 64 +-------------
 .../controllers/main/service/add_controller.js  | 88 --------------------
 ambari-web/app/controllers/wizard.js            | 65 +++++++++++++++
 ambari-web/app/utils/helper.js                  |  3 +-
 4 files changed, 69 insertions(+), 151 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/9eef77a0/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 68459ff..fd034c9 100644
--- a/ambari-web/app/controllers/main/host/add_controller.js
+++ b/ambari-web/app/controllers/main/host/add_controller.js
@@ -199,69 +199,9 @@ App.AddHostController = App.WizardController.extend({
    * @return {Array}
    */
   getSlaveComponentHosts: function () {
-    var components = [
-      {
-        name: 'DATANODE',
-        service: 'HDFS'
-      },
-      {
-        name: 'TASKTRACKER',
-        service: 'MAPREDUCE'
-      },
-      {
-        name: 'HBASE_REGIONSERVER',
-        service: 'HBASE'
-      }
-    ];
-
-    var result = [];
-    var services = App.Service.find();
-    var selectedServices = this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName');
-    for (var index = 0; index < components.length; index++) {
-      var comp = components[index];
-      if (!selectedServices.contains(comp.service)) {
-        continue;
-      }
-
-
-      var service = services.findProperty('id', comp.service);
-      var hosts = [];
-
-      service.get('hostComponents').filterProperty('componentName', comp.name).forEach(function (host_component) {
-        hosts.push({
-          group: "Default",
-          hostName: host_component.get('host.id'),
-          isInstalled: true
-        });
-      }, this);
-
-      result.push({
-        componentName: comp.name,
-        displayName: App.format.role(comp.name),
-        hosts: hosts,
-        isInstalled: true
-      })
-    }
-
-    var clientsHosts = App.HostComponent.find().filterProperty('componentName', 'HDFS_CLIENT');
-    var hosts = [];
-
-    clientsHosts.forEach(function (host_component) {
-      hosts.push({
-        group: "Default",
-        hostName: host_component.get('host.id'),
-        isInstalled: true
-      });
-    }, this);
-
-    result.push({
-      componentName: 'CLIENT',
-      displayName: 'client',
-      hosts: hosts,
-      isInstalled: true
+    return this._super().filter(function(component){
+      return component.isInstalled;
     });
-
-    return result;
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/9eef77a0/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 325a520..8b1ce05 100644
--- a/ambari-web/app/controllers/main/service/add_controller.js
+++ b/ambari-web/app/controllers/main/service/add_controller.js
@@ -249,94 +249,6 @@ App.AddServiceController = App.WizardController.extend({
   },
 
   /**
-   * return slaveComponents bound to hosts
-   * @return {Array}
-   */
-  getSlaveComponentHosts: function () {
-    var components = [{
-      name : 'DATANODE',
-      service : 'HDFS'
-    },
-    {
-      name: 'TASKTRACKER',
-      service: 'MAPREDUCE'
-    },
-    {
-      name: 'HBASE_REGIONSERVER',
-      service: 'HBASE'
-    },
-    {
-      name: 'SUPERVISOR',
-      service: 'STORM'
-    }];
-
-    if (App.get('isHadoop2Stack')) {
-      components.push({
-        name: 'NODEMANAGER',
-        service: 'YARN'
-      });
-    }
-
-    var result = [];
-    var services = App.Service.find();
-    var selectedServices = this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName');
-    for(var index=0; index < components.length; index++){
-      var comp = components[index];
-      if(!selectedServices.contains(comp.service)){
-        continue;
-      }
-
-
-      var service = services.findProperty('id', comp.service);
-      var hosts = [];
-
-      if(!service){
-        service = services.findProperty('id', 'HDFS');
-        service.get('hostComponents').filterProperty('componentName', 'DATANODE').forEach(function (host_component) {
-          hosts.push({
-            group: "Default",
-            hostName: host_component.get('host.id'),
-            isInstalled: false
-          });
-        }, this);
-      } else {
-        service.get('hostComponents').filterProperty('componentName', comp.name).forEach(function (host_component) {
-          hosts.push({
-            group: "Default",
-            hostName: host_component.get('host.id'),
-            isInstalled: true
-          });
-        }, this);
-      }
-
-      result.push({
-        componentName: comp.name,
-        displayName: App.format.role(comp.name),
-        hosts: hosts
-      })
-    }
-
-    var clientsHosts = App.HostComponent.find().filterProperty('componentName', 'HDFS_CLIENT');
-    var hosts = [];
-
-    clientsHosts.forEach(function (host_component) {
-        hosts.push({
-          group: "Default",
-          hostName: host_component.get('host.id'),
-          isInstalled: true
-        });
-    }, this);
-
-    result.push({
-      componentName: 'CLIENT',
-      displayName: 'client',
-      hosts: hosts
-    });
-
-    return result;
-  },
-
-  /**
    * Load master component hosts data for using in required step controllers
    */
   loadSlaveComponentHosts: function () {

http://git-wip-us.apache.org/repos/asf/ambari/blob/9eef77a0/ambari-web/app/controllers/wizard.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard.js b/ambari-web/app/controllers/wizard.js
index 900c875..28de25c 100644
--- a/ambari-web/app/controllers/wizard.js
+++ b/ambari-web/app/controllers/wizard.js
@@ -38,6 +38,13 @@ App.WizardController = Em.Controller.extend({
     }
   },
 
+  slaveComponents: function () {
+    return require('data/service_components').filter(function (component) {
+      return !(component.isClient || component.isMaster ||
+        ["GANGLIA_MONITOR", "DASHBOARD", "MYSQL_SERVER"].contains(component.component_name));
+    });
+  }.property(),
+
   dbNamespace: function(){
     return this.get('name').capitalize().replace('Controller', "");
   }.property('name'),
@@ -785,5 +792,63 @@ App.WizardController = Em.Controller.extend({
     }, this);
     this.setDBProperty('serviceConfigGroups', serviceConfigGroups);
     this.set('content.configGroups', serviceConfigGroups);
+  },
+  /**
+   * return slaveComponents bound to hosts
+   * @return {Array}
+   */
+  getSlaveComponentHosts: function () {
+    var components = this.get('slaveComponents');
+    var result = [];
+    var installedServices = App.Service.find().mapProperty('serviceName');
+    var selectedServices = this.get('content.services').filterProperty('isSelected', true).mapProperty('serviceName');
+    var installedComponentsMap = {};
+    var uninstalledComponents = [];
+
+    components.forEach(function (component) {
+      if (installedServices.contains(component.service_name)) {
+        installedComponentsMap[component.component_name] = [];
+      } else if (selectedServices.contains(component.service_name)) {
+        uninstalledComponents.push(component);
+      }
+    }, this);
+    installedComponentsMap['HDFS_CLIENT'] = [];
+
+    App.HostComponent.find().forEach(function (hostComponent) {
+      if (installedComponentsMap[hostComponent.get('componentName')]) {
+        installedComponentsMap[hostComponent.get('componentName')].push(hostComponent.get('host.id'));
+      }
+    }, this);
+
+    for (var componentName in installedComponentsMap) {
+      var name = (componentName === 'HDFS_CLIENT') ? 'CLIENT' : componentName;
+      var component = {
+        componentName: name,
+        displayName: App.format.role(name),
+        hosts: [],
+        isInstalled: true
+      };
+      installedComponentsMap[componentName].forEach(function (hostName) {
+        component.hosts.push({
+          group: "Default",
+          hostName: hostName,
+          isInstalled: true
+        });
+      }, this);
+      result.push(component);
+    }
+
+    uninstalledComponents.forEach(function (component) {
+      var hosts = jQuery.extend(true, [], result.findProperty('componentName', 'DATANODE').hosts);
+      hosts.setEach('isInstalled', false);
+      result.push({
+        componentName: component.component_name,
+        displayName: App.format.role(component.component_name),
+        hosts: hosts,
+        isInstalled: false
+      })
+    });
+
+    return result;
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/9eef77a0/ambari-web/app/utils/helper.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/helper.js b/ambari-web/app/utils/helper.js
index 0815d61..17958f1 100644
--- a/ambari-web/app/utils/helper.js
+++ b/ambari-web/app/utils/helper.js
@@ -220,7 +220,8 @@ App.format = {
     'ZOOKEEPER_CLIENT': 'ZooKeeper Client',
     'ZOOKEEPER_QUORUM_SERVICE_CHECK': 'ZK Quorum Service Check',
     'ZOOKEEPER_SERVER': 'ZooKeeper Server',
-    'ZOOKEEPER_SERVICE_CHECK': 'ZooKeeper Service Check'
+    'ZOOKEEPER_SERVICE_CHECK': 'ZooKeeper Service Check',
+    'CLIENT': 'client'
   },
 
   /**