ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From srima...@apache.org
Subject svn commit: r1466289 - in /incubator/ambari/trunk: CHANGES.txt ambari-web/app/controllers/main/service/info/configs.js ambari-web/app/controllers/wizard/step8_controller.js
Date Tue, 09 Apr 2013 23:32:04 GMT
Author: srimanth
Date: Tue Apr  9 23:32:04 2013
New Revision: 1466289

URL: http://svn.apache.org/r1466289
Log:
AMBARI-1847. Make single PUT call for multiple host overrides. (srimanth)

Modified:
    incubator/ambari/trunk/CHANGES.txt
    incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js
    incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js

Modified: incubator/ambari/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1466289&r1=1466288&r2=1466289&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Tue Apr  9 23:32:04 2013
@@ -12,6 +12,8 @@ Trunk (unreleased changes):
 
  NEW FEATURES
 
+ AMBARI-1847. Make single PUT call for multiple host overrides. (srimanth)
+
  AMBARI-1857. Capacity Scheduler: field order for Add/Edit popup. (srimanth)
 
  AMBARI-1855. Capacity Scheduler: when adding a new queue, populate 

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js?rev=1466289&r1=1466288&r2=1466289&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/service/info/configs.js Tue Apr
 9 23:32:04 2013
@@ -1011,14 +1011,18 @@ App.MainServiceInfoConfigsController = E
    * 
    */
   doPUTHostOverridesConfigurationSites: function(){
-    var result = true;
+    var singlePUTHostData = [];
     var savedHostSiteArray = [];
     for ( var host in this.savedHostToOverrideSiteToTagMap) {
       for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
         var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
         var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
         savedHostSiteArray.push(host+"///"+siteName);
-        var hostOverridenServerData = {
+        singlePUTHostData.push({
+          RequestInfo: {
+            query: 'Hosts/host_name='+host
+          },
+          Body: {
             Hosts: {
               desired_config: {
                 type: siteName,
@@ -1026,32 +1030,8 @@ App.MainServiceInfoConfigsController = E
                 properties: map
               }
             }
-        };
-        console.log("createHostOverrideConfigSites(): PUTting host-override config for host="+host+",
site="+siteName+", tag="+tagName+". Data=",hostOverridenServerData);
-        var url = this.getUrl('', '/hosts/'+host);
-        var hostOverrideResult = true;
-        $.ajax({
-          type: 'PUT',
-          url: url,
-          data: JSON.stringify(hostOverridenServerData),
-          async: false,
-          dataType: 'text',
-          timeout: 5000,
-          success: function (data) {
-            var jsonData = jQuery.parseJSON(data);
-            hostOverrideResult = true;
-            console.log("createHostOverrideConfigSites(): SUCCESS:", url, ". RESPONSE:",jsonData);
-          },
-          error: function (request, ajaxOptions, error) {
-            hostOverrideResult = false;
-            console.log("createHostOverrideConfigSites(): ERROR:", url, ". RESPONSE:",request.responseText);
-          },
-          statusCode: require('data/statusCodes')
+          }
         });
-        result = result && hostOverrideResult;
-        if(!result){
-          return result;
-        }
       }
     }
     // Now cleanup removed overrides
@@ -1060,7 +1040,11 @@ App.MainServiceInfoConfigsController = E
         if (!(savedHostSiteArray.contains(loadedHost + "///" + loadedSiteName))) {
           // This host-site combination was loaded, but not saved.
           // Meaning it is not needed anymore. Hence send a DELETE command.
-          var hostOverridenServerData = {
+          singlePUTHostData.push({
+            RequestInfo: {
+              query: 'Hosts/host_name='+loadedHost
+            },
+            Body: {
               Hosts: {
                 desired_config: {
                   type: loadedSiteName,
@@ -1068,31 +1052,36 @@ App.MainServiceInfoConfigsController = E
                   selected: false
                 }
               }
-          };
-          var url = this.getUrl('', '/hosts/'+loadedHost);
-          $.ajax({
-            type: 'PUT',
-            url: url,
-            data: JSON.stringify(hostOverridenServerData),
-            async: false,
-            dataType: 'text',
-            timeout: 5000,
-            success: function (data) {
-              var jsonData = jQuery.parseJSON(data);
-              hostOverrideResult = true;
-              console.log("createHostOverrideConfigSites(): SUCCESS:", url, ". RESPONSE:",jsonData);
-            },
-            error: function (request, ajaxOptions, error) {
-              hostOverrideResult = false;
-              console.log("createHostOverrideConfigSites(): ERROR:", url, ". RESPONSE:",request.responseText);
-            },
-            statusCode: require('data/statusCodes')
+            }
           });
-          result = result && hostOverrideResult;
         }
       }
     }
-    return result;
+    console.debug("createHostOverrideConfigSites(): PUTting host-overrides. Data=",singlePUTHostData);
+    if(singlePUTHostData.length>0){
+      var url = this.getUrl('', '/hosts');
+      var hostOverrideResult = true;
+      $.ajax({
+        type: 'PUT',
+        url: url,
+        data: JSON.stringify(singlePUTHostData),
+        async: false,
+        dataType: 'text',
+        timeout: 5000,
+        success: function (data) {
+          var jsonData = jQuery.parseJSON(data);
+          hostOverrideResult = true;
+          console.log("createHostOverrideConfigSites(): SUCCESS:", url, ". RESPONSE:",jsonData);
+        },
+        error: function (request, ajaxOptions, error) {
+          hostOverrideResult = false;
+          console.log("createHostOverrideConfigSites(): ERROR:", url, ". RESPONSE:",request.responseText);
+        },
+        statusCode: require('data/statusCodes')
+      });
+      return hostOverrideResult;
+    }
+    return true;
   },
    
   /**

Modified: incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js?rev=1466289&r1=1466288&r2=1466289&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/wizard/step8_controller.js Tue Apr 
9 23:32:04 2013
@@ -1474,34 +1474,42 @@ App.WizardStep8Controller = Em.Controlle
    * 
    */
   createHostOverrideConfigurations: function () {
+    var singlePUTHostData = [];
     var savedHostSiteArray = [];
     for ( var host in this.savedHostToOverrideSiteToTagMap) {
       for ( var siteName in this.savedHostToOverrideSiteToTagMap[host]) {
         var tagName = this.savedHostToOverrideSiteToTagMap[host][siteName].tagName;
         var map = this.savedHostToOverrideSiteToTagMap[host][siteName].map;
         savedHostSiteArray.push(host + "///" + siteName);
-        var hostOverridenServerData = {
-          Hosts: {
-            desired_config: {
-              type: siteName,
-              tag: tagName,
-              properties: map
+        singlePUTHostData.push({
+          RequestInfo: {
+            query: 'Hosts/host_name='+host
+          },
+          Body: {
+            Hosts: {
+              desired_config: {
+                type: siteName,
+                tag: tagName,
+                properties: map
+              }
             }
           }
-        };
-        console.log("createHostOverrideConfigSites(): PUTting host-override config for host="
+ host + ", site=" + siteName + ", tag=" + tagName + ". Data=", hostOverridenServerData);
-        var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts/' + host;
-        this.ajax({
-          type: 'PUT',
-          url: url,
-          data: JSON.stringify(hostOverridenServerData),
-          dataType: 'text',
-          beforeSend: function () {
-            console.log("createHostOverrideConfigSites("+host+") override=", hostOverridenServerData);
-          }
         });
       }
     }
+    console.log("createHostOverrideConfigSites(): PUTting host-overrides. Data=", singlePUTHostData);
+    if(singlePUTHostData.length>0){
+      var url = App.apiPrefix + '/clusters/' + this.get('clusterName') + '/hosts';
+      this.ajax({
+        type: 'PUT',
+        url: url,
+        data: JSON.stringify(singlePUTHostData),
+        dataType: 'text',
+        beforeSend: function () {
+          console.log("createHostOverrideConfigSites() PUT override=", singlePUTHostData);
+        }
+      });
+    }
   },
 
   /**



Mime
View raw message