소스 검색

AMBARI-3352: Installer wizard: Batch create configuration calls into single call. (jaimin)

Jaimin Jetly 11 년 전
부모
커밋
0e01a8abc1
1개의 변경된 파일39개의 추가작업 그리고 24개의 파일을 삭제
  1. 39 24
      ambari-web/app/controllers/wizard/step8_controller.js

+ 39 - 24
ambari-web/app/controllers/wizard/step8_controller.js

@@ -37,6 +37,7 @@ App.WizardStep8Controller = Em.Controller.extend({
   isBackBtnDisabled: false,
   hasErrorOccurred: false,
   servicesInstalled: false,
+  serviceConfigTags: [],
   securityEnabled: false,
   /**
    * During page save time, we set the host overrides to the server.
@@ -69,6 +70,7 @@ App.WizardStep8Controller = Em.Controller.extend({
     this.get('configs').clear();
     this.get('globals').clear();
     this.get('clusterInfo').clear();
+    this.get('serviceConfigTags').clear();
     this.set('servicesInstalled', false);
   },
 
@@ -1306,57 +1308,70 @@ App.WizardStep8Controller = Em.Controller.extend({
   createConfigurations: function () {
     var selectedServices = this.get('selectedServices');
     if (this.get('content.controllerName') == 'installerController') {
-      this.applyConfigurationToSite(this.createGlobalSiteObj());
-      this.applyConfigurationToSite(this.createCoreSiteObj());
-      this.applyConfigurationToSite(this.createHdfsSiteObj());
+      this.get('serviceConfigTags').pushObject(this.createGlobalSiteObj());
+      this.get('serviceConfigTags').pushObject(this.createCoreSiteObj());
+      this.get('serviceConfigTags').pushObject(this.createHdfsSiteObj());
     }
     if (selectedServices.someProperty('serviceName', 'MAPREDUCE')) {
-      this.applyConfigurationToSite(this.createMrSiteObj());
+      this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
       if (App.supports.capacitySchedulerUi) {
-        this.applyConfigurationToSite(this.createCapacityScheduler());
-        this.applyConfigurationToSite(this.createMapredQueueAcls());
+        this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
+        this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
       }
     }
     if (selectedServices.someProperty('serviceName', 'MAPREDUCE2')) {
-      this.applyConfigurationToSite(this.createMrSiteObj());
-      this.applyConfigurationToSite(this.createMapredQueueAcls());
+      this.get('serviceConfigTags').pushObject(this.createMrSiteObj());
+      this.get('serviceConfigTags').pushObject(this.createMapredQueueAcls());
     }
     if (selectedServices.someProperty('serviceName', 'YARN')) {
-      this.applyConfigurationToSite(this.createYarnSiteObj());
-      this.applyConfigurationToSite(this.createCapacityScheduler());
+      this.get('serviceConfigTags').pushObject(this.createYarnSiteObj());
+      this.get('serviceConfigTags').pushObject(this.createCapacityScheduler());
     }
     if (selectedServices.someProperty('serviceName', 'HBASE')) {
-      this.applyConfigurationToSite(this.createHbaseSiteObj());
+      this.get('serviceConfigTags').pushObject(this.createHbaseSiteObj());
     }
     if (selectedServices.someProperty('serviceName', 'OOZIE')) {
-      this.applyConfigurationToSite(this.createOozieSiteObj('OOZIE'));
+      this.get('serviceConfigTags').pushObject(this.createOozieSiteObj('OOZIE'));
     }
     if (selectedServices.someProperty('serviceName', 'HIVE')) {
-      this.applyConfigurationToSite(this.createHiveSiteObj('HIVE'));
+      this.get('serviceConfigTags').pushObject(this.createHiveSiteObj('HIVE'));
     }
     if (selectedServices.someProperty('serviceName', 'WEBHCAT')) {
-      this.applyConfigurationToSite(this.createWebHCatSiteObj('WEBHCAT'));
+      this.get('serviceConfigTags').pushObject(this.createWebHCatSiteObj('WEBHCAT'));
     }
     if (selectedServices.someProperty('serviceName', 'HUE')) {
-      this.applyConfigurationToSite(this.createHueSiteObj('HUE'));
+      this.get('serviceConfigTags').pushObject(this.createHueSiteObj('HUE'));
     }
+    this.applyConfigurationsToCluster();
   },
 
-  applyConfigurationToSite: function (data) {
-    console.log("Inside applyConfigurationToSite");
+  applyConfigurationsToCluster: function() {
     var clusterUrl = App.apiPrefix + '/clusters/' + this.get('clusterName');
-    var clusterData = {
-      Clusters: {
-        desired_configs: data
-      }
+    var configData = [];
+    this.get('serviceConfigTags').forEach(function (_serviceConfig) {
+      var Clusters = {
+        Clusters: {
+          desired_config: {
+            type: _serviceConfig.type,
+            tag: _serviceConfig.tag,
+            properties: _serviceConfig.properties
+          }
+        }
+      };
+      configData.pushObject(JSON.stringify(Clusters));
+    }, this);
+
+    var data = {
+      configData: '[' + configData.toString() + ']'
     };
-    console.debug("applyConfigurationToSite(Step8): Applying to URL", clusterUrl, " Data:", clusterData);
+
+    console.debug("applyConfigurationsToCluster(Step8): Applying to URL", clusterUrl, " Data:", data.configData);
     this.ajax({
       type: 'PUT',
       url: clusterUrl,
-      data: JSON.stringify(clusterData),
+      data: data.configData,
       beforeSend: function () {
-        console.log("BeforeSend: Updating cluster config for " + clusterData.type);
+        console.log("BeforeSend: Updating cluster config");
       }
     });
   },