You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by yu...@apache.org on 2012/12/09 15:34:43 UTC

svn commit: r1418976 - in /incubator/ambari/branches/AMBARI-666: AMBARI-666-CHANGES.txt ambari-web/app/controllers/wizard/step8_controller.js

Author: yusaku
Date: Sun Dec  9 14:34:42 2012
New Revision: 1418976

URL: http://svn.apache.org/viewvc?rev=1418976&view=rev
Log:
AMBARI-1035. Aggregate creation of multiple services and assignment of host to cluster. (Jaimin Jetly via yusaku)

Modified:
    incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
    incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js

Modified: incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt?rev=1418976&r1=1418975&r2=1418976&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt (original)
+++ incubator/ambari/branches/AMBARI-666/AMBARI-666-CHANGES.txt Sun Dec  9 14:34:42 2012
@@ -424,6 +424,9 @@ AMBARI-666 branch (unreleased changes)
 
   IMPROVEMENTS
 
+  AMBARI-1035. Aggregate creation of multiple services and assignment of host
+  to cluster. (Jaimin Jetly via yusaku)
+
   AMBARI-1034. Metric Charts - display local time rather than UTC.
   (Srimanth Gunturi via yusaku)
 

Modified: incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js?rev=1418976&r1=1418975&r2=1418976&view=diff
==============================================================================
--- incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js (original)
+++ incubator/ambari/branches/AMBARI-666/ambari-web/app/controllers/wizard/step8_controller.js Sun Dec  9 14:34:42 2012
@@ -192,7 +192,7 @@ App.WizardStep8Controller = Em.Controlle
           var key = _keyValue.match(/(.+)=/);
           var value = _keyValue.match(/=(.*)/);
           if (key) {
-            this.setSiteProperty(key[1], value[1],_site.filename);
+            this.setSiteProperty(key[1], value[1], _site.filename);
           }
 
         }, this);
@@ -203,17 +203,17 @@ App.WizardStep8Controller = Em.Controlle
   /**
    * Set property of the site variable
    */
-  setSiteProperty: function(key,value,filename) {
-     if(this.get('configs').someProperty('name',key)) {
-       this.get('configs').findProperty('name',key).value = value;
-     } else {
-       this.get('configs').pushObject({
-         "id": "site property",
-         "name": key,
-         "value": value,
-         "filename": filename
-       });
-     }
+  setSiteProperty: function (key, value, filename) {
+    if (this.get('configs').someProperty('name', key)) {
+      this.get('configs').findProperty('name', key).value = value;
+    } else {
+      this.get('configs').pushObject({
+        "id": "site property",
+        "name": key,
+        "value": value,
+        "filename": filename
+      });
+    }
   },
 
   /**
@@ -597,11 +597,11 @@ App.WizardStep8Controller = Em.Controlle
   submit: function () {
 
     if (App.testMode) {
-      // App.router.send('next');
-      //return;
+      App.router.send('next');
+      return;
     }
 
-    if(!this.get('content.cluster.requestId')){
+    if (!this.get('content.cluster.requestId')) {
       this.createCluster();
       this.createSelectedServices();
       this.createConfigurations();
@@ -619,7 +619,7 @@ App.WizardStep8Controller = Em.Controlle
 
   createCluster: function () {
 
-    if (this.get('content.isWizard')){
+    if (this.get('content.isWizard')) {
       return false;
     }
 
@@ -651,20 +651,15 @@ App.WizardStep8Controller = Em.Controlle
 
   },
 
-  // TODO: aggregate create calls.  doesn't seem like backend supports creating multiple services at the same time yet.
-  createSelectedServices: function () {
-    var services = this.get('selectedServices').mapProperty('serviceName');
-    services.forEach(function (_service) {
-      this.createService(_service, 'POST');
-    }, this);
-  },
-
-  createService: function (service, httpMethod) {
+  createSelectedServices: function (service, httpMethod) {
     var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/services/' + service;
+    var url = App.apiPrefix + '/clusters/' + clusterName + '/services';
+    var data = this.createServiceData();
+    var httpMethod = 'POST';
     $.ajax({
       type: httpMethod,
       url: url,
+      data: JSON.stringify(data),
       async: false,
       dataType: 'text',
       timeout: App.timeout,
@@ -685,13 +680,22 @@ App.WizardStep8Controller = Em.Controlle
     });
   },
 
+  createServiceData: function () {
+    var services = this.get('selectedServices').mapProperty('serviceName');
+    var data = [];
+    services.forEach(function (_service) {
+      data.pushObject({"ServiceInfo": { "service_name": _service }});
+    }, this);
+    return data;
+  },
+
   createComponents: function () {
 
     var serviceComponents = require('data/service_components');
     var services = this.get('selectedServices').mapProperty('serviceName');
     services.forEach(function (_service) {
       var components = serviceComponents.filterProperty('service_name', _service);
-      var componentsData = components.map(function(_component) {
+      var componentsData = components.map(function (_component) {
         return { "ServiceComponentInfo": { "component_name": _component.component_name } };
       });
       var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
@@ -726,21 +730,14 @@ App.WizardStep8Controller = Em.Controlle
 
   },
 
-  registerHostsToCluster: function() {
-    var allHosts = this.get('content.hostsInfo');
-    for(var hostName in allHosts){
-      if(!allHosts[hostName].isInstalled){
-        this.registerHostToCluster(hostName);
-      }
-    }
-  },
-
-  registerHostToCluster: function (hostName) {
+  registerHostsToCluster: function (hostName) {
     var clusterName = this.get('clusterInfo').findProperty('config_name', 'cluster').config_value;
-    var url = App.apiPrefix + '/clusters/' + clusterName + '/hosts/' + hostName;
+    var url = App.apiPrefix + '/clusters/' + clusterName + '/hosts';
+    var data = this.createRegisterHostData();
     $.ajax({
       type: 'POST',
       url: url,
+      data: JSON.stringify(data),
       async: false,
       dataType: 'text',
       timeout: App.timeout,
@@ -761,6 +758,17 @@ App.WizardStep8Controller = Em.Controlle
     });
   },
 
+  createRegisterHostData: function () {
+    var allHosts = this.get('content.hostsInfo');
+    var data = [];
+    for (var hostName in allHosts) {
+      if (!allHosts[hostName].isInstalled) {
+        data.pushObject({"Hosts": { "host_name": hostName}});
+      }
+    }
+    return data;
+  },
+
   createHostComponents: function () {
     //TODO: Uncomment following after hooking up with all services.
 
@@ -809,7 +817,7 @@ App.WizardStep8Controller = Em.Controlle
 
 
     slaveHosts.filterProperty('componentName', "HBASE_REGIONSERVER").forEach(function (slave) {
-      slave.hosts.forEach(function(_slaveHost){
+      slave.hosts.forEach(function (_slaveHost) {
         var hosts = slaveClient.hosts.filterProperty('hostName', _slaveHost.hostName);
         if (!hosts.length) {
           var slaveObj = {};
@@ -853,7 +861,7 @@ App.WizardStep8Controller = Em.Controlle
   },
 
   createHostComponent: function (hostComponent) {
-    console.log('try to install', hostComponent.component, 'on host',  hostComponent.hostName, 'isInstalled', hostComponent.isInstalled);
+    console.log('try to install', hostComponent.component, 'on host', hostComponent.hostName, 'isInstalled', hostComponent.isInstalled);
     if (hostComponent.isInstalled) {
       return false;
     }
@@ -885,7 +893,7 @@ App.WizardStep8Controller = Em.Controlle
 
   createConfigurations: function () {
     var selectedServices = this.get('selectedServices');
-    if (!this.get('content.isWizard')){
+    if (!this.get('content.isWizard')) {
       this.createConfigSite(this.createGlobalSiteObj());
       this.createConfigSite(this.createCoreSiteObj());
       this.createConfigSite(this.createHdfsSiteObj('HDFS'));
@@ -1009,7 +1017,7 @@ App.WizardStep8Controller = Em.Controlle
     }, this);
     var baseUrl = oozieProperties['oozie.base.url'];
     oozieProperties = {
-      "oozie.service.JPAService.jdbc.password" : " ", "oozie.db.schema.name" : "oozie", "oozie.service.JPAService.jdbc.url" : "jdbc:derby:/var/data/oozie/oozie-db;create=true", "oozie.service.JPAService.jdbc.driver" : "org.apache.derby.jdbc.EmbeddedDriver", "oozie.service.WorkflowAppService.system.libpath" : "/user/oozie/share/lib", "oozie.service.JPAService.jdbc.username" : "sa", "oozie.service.SchemaService.wf.ext.schemas" : "shell-action-0.1.xsd,email-action-0.1.xsd,hive-action-0.2.xsd,sqoop-action-0.2.xsd,ssh-action-0.1.xsd,distcp-action-0.1.xsd", "oozie.service.JPAService.create.db.schema" : "false",   "use.system.libpath.for.mapreduce.and.pig.jobs" : "false", "oozie.service.ActionService.executor.ext.classes" : "org.apache.oozie.action.email.EmailActionExecutor,org.apache.oozie.action.hadoop.HiveActionExecutor,org.apache.oozie.action.hadoop.ShellActionExecutor,org.apache.oozie.action.hadoop.SqoopActionExecutor,org.apache.oozie.action.hadoop.DistcpActionExecutor", "oozi
 e.service.HadoopAccessorService.hadoop.configurations" : "*=/etc/hadoop/conf"
+      "oozie.service.JPAService.jdbc.password": " ", "oozie.db.schema.name": "oozie", "oozie.service.JPAService.jdbc.url": "jdbc:derby:/var/data/oozie/oozie-db;create=true", "oozie.service.JPAService.jdbc.driver": "org.apache.derby.jdbc.EmbeddedDriver", "oozie.service.WorkflowAppService.system.libpath": "/user/oozie/share/lib", "oozie.service.JPAService.jdbc.username": "sa", "oozie.service.SchemaService.wf.ext.schemas": "shell-action-0.1.xsd,email-action-0.1.xsd,hive-action-0.2.xsd,sqoop-action-0.2.xsd,ssh-action-0.1.xsd,distcp-action-0.1.xsd", "oozie.service.JPAService.create.db.schema": "false", "use.system.libpath.for.mapreduce.and.pig.jobs": "false", "oozie.service.ActionService.executor.ext.classes": "org.apache.oozie.action.email.EmailActionExecutor,org.apache.oozie.action.hadoop.HiveActionExecutor,org.apache.oozie.action.hadoop.ShellActionExecutor,org.apache.oozie.action.hadoop.SqoopActionExecutor,org.apache.oozie.action.hadoop.DistcpActionExecutor", "oozie.service.Ha
 doopAccessorService.hadoop.configurations": "*=/etc/hadoop/conf"
     };
     oozieProperties['oozie.base.url'] = baseUrl;
     return {type: 'oozie-site', tag: 'version1', properties: oozieProperties};