Browse Source

AMBARI-6165 Change calls which download configs to asynchronous. (atkach)

atkach 11 years ago
parent
commit
ae8a71f27e

+ 40 - 35
ambari-web/app/controllers/main/mirroring_controller.js

@@ -242,31 +242,32 @@ App.MainMirroringController = Em.ArrayController.extend({
         });
       }, this);
     } else {
-      var defaultFS = this.loadDefaultFS();
-      var clusterName = App.get('clusterName');
-      var sourceCluster = Ember.Object.create({
-        name: clusterName,
-        execute: App.HostComponent.find().findProperty('componentName', 'RESOURCEMANAGER').get('hostName') + ':8050',
-        readonly: 'hftp://' + App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('hostName') + ':50070',
-        workflow: 'http://' + App.HostComponent.find().findProperty('componentName', 'OOZIE_SERVER').get('hostName') + ':11000/oozie',
-        write: defaultFS,
-        staging: '/apps/falcon/' + clusterName + '/staging',
-        working: '/apps/falcon/' + clusterName + '/working',
-        temp: '/tmp'
-      });
-      var sourceClusterData = App.router.get('mainMirroringManageClustersController').formatClusterXML(sourceCluster);
-      App.ajax.send({
-        name: 'mirroring.submit_entity',
-        sender: this,
-        data: {
-          type: 'cluster',
-          entity: sourceClusterData,
-          falconServer: App.get('falconServerURL')
-        },
-        success: 'onSourceClusterCreateSuccess',
-        error: 'onSourceClusterCreateError'
+      this.loadDefaultFS(function (defaultFS) {
+        var clusterName = App.get('clusterName');
+        var sourceCluster = Ember.Object.create({
+          name: clusterName,
+          execute: App.HostComponent.find().findProperty('componentName', 'RESOURCEMANAGER').get('hostName') + ':8050',
+          readonly: 'hftp://' + App.HostComponent.find().findProperty('componentName', 'NAMENODE').get('hostName') + ':50070',
+          workflow: 'http://' + App.HostComponent.find().findProperty('componentName', 'OOZIE_SERVER').get('hostName') + ':11000/oozie',
+          write: defaultFS,
+          staging: '/apps/falcon/' + clusterName + '/staging',
+          working: '/apps/falcon/' + clusterName + '/working',
+          temp: '/tmp'
+        });
+        var sourceClusterData = App.router.get('mainMirroringManageClustersController').formatClusterXML(sourceCluster);
+        App.ajax.send({
+          name: 'mirroring.submit_entity',
+          sender: this,
+          data: {
+            type: 'cluster',
+            entity: sourceClusterData,
+            falconServer: App.get('falconServerURL')
+          },
+          success: 'onSourceClusterCreateSuccess',
+          error: 'onSourceClusterCreateError'
+        });
+        clustersData.items.push(sourceCluster);
       });
-      clustersData.items.push(sourceCluster);
     }
   },
 
@@ -274,31 +275,35 @@ App.MainMirroringController = Em.ArrayController.extend({
    * Return fs.defaultFS config property loaded from server
    * @return {String}
    */
-  loadDefaultFS: function () {
+  loadDefaultFS: function (callback) {
     App.ajax.send({
-      name: 'config.tags.sync',
+      name: 'config.tags',
       sender: this,
+      data: {
+        callback: callback
+      },
       success: 'onLoadConfigTagsSuccess',
       error: 'onLoadConfigTagsError'
     });
-    var configs = App.router.get('configurationController').getConfigsByTags([
-      {
-        siteName: "core-site",
-        tagName: this.get('tag')
-      }
-    ]);
-    return configs[0].properties['fs.defaultFS'];
   },
 
   // Loaded core-site tag version
   tag: null,
 
-  onLoadConfigTagsSuccess: function (data) {
+  onLoadConfigTagsSuccess: function (data, opt, params) {
     this.set('tag', data.Clusters.desired_configs['core-site'].tag);
+    var configs = App.router.get('configurationController').getConfigsByTags([
+      {
+        siteName: "core-site",
+        tagName: this.get('tag')
+      }
+    ]);
+    params.callback(configs[0].properties['fs.defaultFS']);
   },
 
-  onLoadConfigTagsError: function () {
+  onLoadConfigTagsError: function (request, ajaxOptions, error, opt, params) {
     console.error('Error in loading fs.defaultFS');
+    params.callback(null);
   },
 
   onLoadClustersListError: function () {

+ 19 - 31
ambari-web/app/controllers/main/service/info/configs.js

@@ -240,6 +240,20 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
    * Loads service configurations
    */
   loadServiceConfigs: function () {
+    var advancedConfigs = [];
+    var self = this;
+
+    App.config.loadAdvancedConfig(this.get('content.serviceName'), function (properties) {
+      advancedConfigs.pushObjects(properties);
+      self.set('advancedConfigs', advancedConfigs);
+      self.loadServiceTags();
+    });
+  },
+
+  /**
+   * load config tags of service
+   */
+  loadServiceTags: function () {
     App.ajax.send({
       name: 'config.tags_and_groups',
       sender: this,
@@ -302,21 +316,13 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
           }
         }, this);
       }
-      this.set('configGroups', []);
-      lazyLoading.run({
-        initSize: 20,
-        chunkSize: 50,
-        delay: 50,
-        destination: this.get('configGroups'),
-        source: configGroups,
-        context: this
-      });
+      this.set('configGroups', configGroups);
     }
     var defaultConfigGroup = App.ConfigGroup.create({
       name: App.Service.DisplayNames[serviceName] + " Default",
       description: "Default cluster level " + serviceName + " configuration",
       isDefault: true,
-      hosts: [],
+      hosts: defaultConfigGroupHosts,
       parentConfigGroup: null,
       service: this.get('content'),
       serviceName: serviceName,
@@ -324,14 +330,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     });
     if (!selectedConfigGroup) {
       selectedConfigGroup = defaultConfigGroup;
-      lazyLoading.run({
-        initSize: 20,
-        chunkSize: 50,
-        delay: 50,
-        destination: selectedConfigGroup.get('hosts'),
-        source: defaultConfigGroupHosts,
-        context: Em.Object.create()
-      });
     }
 
     this.get('configGroups').sort(function(configGroupA, configGroupB){
@@ -360,11 +358,8 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     }
     //STEP 2: Create an array of objects defining tag names to be polled and new tag names to be set after submit
     this.setServiceConfigTags(this.loadedClusterSiteToTagMap);
-    //STEP 3: Load advanced configs from server
-    var advancedConfigs = [];
-    App.config.loadAdvancedConfig(serviceName, function (properties) {
-      advancedConfigs.pushObjects(properties);
-    }, true);
+    //STEP 3: Load advanced configs
+    var advancedConfigs = this.get('advancedConfigs');
     //STEP 4: Load on-site config by service from server
     var configGroups = App.router.get('configurationController').getConfigsByTags(this.get('serviceConfigTags'));
     //STEP 5: Merge global and on-site configs with pre-defined
@@ -1158,14 +1153,7 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
       var overridenConfigs = [];
       var groupHosts = [];
       configs.filterProperty('isOverridden', true).forEach(function (config) {
-        lazyLoading.run({
-          initSize: 20,
-          chunkSize: 50,
-          delay: 50,
-          destination: overridenConfigs,
-          source: config.get('overrides'),
-          context: Em.Object.create()
-        });
+        overridenConfigs = overridenConfigs.concat(config.get('overrides'));
       });
       this.formatConfigValues(overridenConfigs);
       selectedConfigGroup.get('hosts').forEach(function(hostName){

+ 1 - 1
ambari-web/app/controllers/main/service/reassign_controller.js

@@ -70,7 +70,7 @@ App.ReassignMasterController = App.WizardController.extend({
     } else {
       //get Security Status From Server
       App.ajax.send({
-        name: 'config.tags.sync',
+        name: 'config.tags',
         sender: this,
         success: 'getSecurityStatusSuccessCallback',
         error: 'errorCallback'

+ 9 - 2
ambari-web/app/controllers/wizard/step7_controller.js

@@ -611,6 +611,12 @@ App.WizardStep7Controller = Em.Controller.extend({
     }
   },
 
+  checkConfigLoad: function() {
+    if (this.get('wizardController.name') === 'addServiceController') {
+      this.set('isAdvancedConfigLoaded', false);
+    }
+  },
+
   /**
    * On load function
    * @method loadStep
@@ -618,6 +624,7 @@ App.WizardStep7Controller = Em.Controller.extend({
   loadStep: function () {
     console.log("TRACE: Loading step7: Configure Services");
     if (!this.get('isAdvancedConfigLoaded')) {
+      this.getConfigTags();
       return;
     }
     this.clearStep();
@@ -643,7 +650,6 @@ App.WizardStep7Controller = Em.Controller.extend({
     this.set('groupsToDelete', this.get('wizardController').getDBProperty('groupsToDelete') || []);
 
     if (this.get('wizardController.name') === 'addServiceController') {
-      this.getConfigTags();
       this.setInstalledServiceConfigs(this.get('serviceConfigTags'), configs);
     }
     if (this.get('allSelectedServiceNames').contains('STORM') || this.get('installedServiceNames').contains('STORM')) {
@@ -732,7 +738,7 @@ App.WizardStep7Controller = Em.Controller.extend({
    */
   getConfigTags: function () {
     return App.ajax.send({
-      name: 'config.tags.sync',
+      name: 'config.tags',
       sender: this,
       success: 'getConfigTagsSuccess'
     });
@@ -765,6 +771,7 @@ App.WizardStep7Controller = Em.Controller.extend({
       }
     }
     this.set('serviceConfigTags', serviceConfigTags);
+    this.set('isAdvancedConfigLoaded', true);
   },
 
   /**

+ 1 - 38
ambari-web/app/utils/ajax/ajax.js

@@ -265,7 +265,6 @@ var urls = {
     'type': 'PUT',
     'format': function (data) {
       return {
-        async: false,
         data: JSON.stringify({
           Clusters: {
             desired_config: {
@@ -314,21 +313,7 @@ var urls = {
 
   'config.advanced': {
     'real': '{stackVersionUrl}/services/{serviceName}/configurations?fields=*',
-    'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json',
-    'format': function (data) {
-      return {
-        async: !data.sync
-      };
-    }
-  },
-  'config.advanced.global': {
-    'real': '{stackVersionUrl}/services?fields=configurations/StackConfigurations/type',
-    'mock': '/data/wizard/stack/hdp/version1.3.0/global.json',
-    'format': function() {
-      return {
-        async: false
-      };
-    }
+    'mock': '/data/wizard/stack/hdp/version{stackVersion}/{serviceName}.json'
   },
   'config.tags': {
     'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
@@ -338,15 +323,6 @@ var urls = {
     'real': '/clusters/{clusterName}?fields=Clusters/desired_configs,config_groups/*{urlParams}',
     'mock': '/data/clusters/tags_and_groups.json'
   },
-  'config.tags.sync': {
-    'real': '/clusters/{clusterName}?fields=Clusters/desired_configs',
-    'mock': '/data/clusters/cluster.json',
-    'format': function() {
-      return {
-        async: false
-      };
-    }
-  },
   'config.ambari.database.info': {
     'real': '/services/AMBARI/components/AMBARI_SERVER?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database,hostComponents/RootServiceHostComponents/properties/server.jdbc.url',
     'mock': '',
@@ -1291,7 +1267,6 @@ var urls = {
     'type': 'PUT',
     'format': function (data) {
       return {
-        async: true,
         data: JSON.stringify(data.data)
       }
     }
@@ -1416,7 +1391,6 @@ var urls = {
     'format': function () {
       return {
         type: 'GET',
-        async: true,
         dataType: 'text'
       };
     }
@@ -1448,7 +1422,6 @@ var urls = {
     'format': function(data) {
       return {
         type: 'POST',
-        async: true,
         dataType: 'text',
         data: data.data
       }
@@ -1461,7 +1434,6 @@ var urls = {
     'format': function(data) {
       return {
         type: 'POST',
-        async: true,
         dataType: 'text',
         data: data.data
       }
@@ -1474,7 +1446,6 @@ var urls = {
     'format': function(data) {
       return {
         type: 'POST',
-        async: true,
         dataType: 'text',
         data: data.data
       }
@@ -1487,7 +1458,6 @@ var urls = {
     'format': function(data) {
       return {
         type: 'POST',
-        async: true,
         dataType: 'text',
         data: data.data
       }
@@ -1500,7 +1470,6 @@ var urls = {
     'format': function(data) {
       return {
         type: 'POST',
-        async: true,
         dataType: 'text',
         data: data.data
       }
@@ -1513,7 +1482,6 @@ var urls = {
     'format': function(data) {
       return {
         type: 'PUT',
-        async: true,
         dataType: 'text',
         data: data.data
       }
@@ -1526,7 +1494,6 @@ var urls = {
     'format': function(data) {
       return {
         type: 'POST',
-        async: true,
         dataType: 'text',
         data: data.data
       }
@@ -1539,7 +1506,6 @@ var urls = {
     'format': function(data) {
       return {
         type: 'PUT',
-        async: true,
         dataType: 'text',
         data: data.data
       }
@@ -1729,7 +1695,6 @@ var urls = {
     'mock': '',
     'format': function (data) {
       return {
-        async: true,
         type: 'PUT',
         data: JSON.stringify(data.data)
       }
@@ -2160,7 +2125,6 @@ var urls = {
       $.extend(true, requestInfo, data.requestInfo)
       return {
         type: 'POST',
-        async: true,
         data: JSON.stringify({
           'RequestInfo': requestInfo,
           'Requests/resource_filters': [{
@@ -2175,7 +2139,6 @@ var urls = {
     'mock': '',
     'format': function(data) {
       return {
-        async: true,
         requestId: data.requestId,
         taskId: data.taskId || ''
       }

+ 5 - 5
ambari-web/app/utils/config.js

@@ -783,18 +783,18 @@ App.config = Em.Object.create({
    * called form stepController step6WizardController
    *
    * @param serviceName
-   * @return {*}
+   * @param callback
+   * @return {object|null}
    */
-  loadAdvancedConfig: function (serviceName, callback, sync) {
-    App.ajax.send({
+  loadAdvancedConfig: function (serviceName, callback) {
+    return App.ajax.send({
       name: 'config.advanced',
       sender: this,
       data: {
         serviceName: serviceName,
         stackVersionUrl: App.get('stackVersionURL'),
         stackVersion: App.get('currentStackVersionNumber'),
-        callback: callback,
-        sync: sync
+        callback: callback
       },
       success: 'loadAdvancedConfigSuccess',
       error: 'loadAdvancedConfigError'

+ 22 - 13
ambari-web/app/views/common/quick_view_link_view.js

@@ -25,9 +25,10 @@ App.QuickViewLinks = Em.View.extend({
 
   loadTags: function () {
     App.ajax.send({
-      name: 'config.tags.sync',
+      name: 'config.tags',
       sender: this,
-      success: 'loadTagsSuccess'
+      success: 'loadTagsSuccess',
+      error: 'loadTagsError'
     });
   },
 
@@ -41,6 +42,24 @@ App.QuickViewLinks = Em.View.extend({
     }
     this.set('actualTags', tags);
     this.setConfigProperties();
+    this.getQuickLinksHosts();
+  },
+
+  loadTagsError: function() {
+    this.getQuickLinksHosts();
+  },
+
+  getQuickLinksHosts: function () {
+    App.ajax.send({
+      name: 'hosts.for_quick_links',
+      sender: this,
+      data: {
+        clusterName: App.get('clusterName'),
+        masterComponents: App.StackServiceComponent.find().filterProperty('isMaster', true).mapProperty('componentName').join(','),
+        urlParams: ',host_components/metrics/hbase/master/IsActiveMaster'
+      },
+      success: 'setQuickLinksSuccessCallback'
+    });
   },
 
   actualTags: [],
@@ -82,20 +101,10 @@ App.QuickViewLinks = Em.View.extend({
   },
 
   setQuickLinks: function () {
-    App.ajax.send({
-      name: 'hosts.for_quick_links',
-      sender: this,
-      data: {
-        clusterName: App.get('clusterName'),
-        masterComponents: App.StackServiceComponent.find().filterProperty('isMaster', true).mapProperty('componentName').join(','),
-        urlParams: ',host_components/metrics/hbase/master/IsActiveMaster'
-      },
-      success: 'setQuickLinksSuccessCallback'
-    });
+    this.loadTags();
   }.observes('App.currentStackVersionNumber', 'App.singleNodeInstall'),
 
   setQuickLinksSuccessCallback: function (response) {
-    this.loadTags();
     var serviceName = this.get('content.serviceName');
     var hosts = [];
     var self = this;

+ 5 - 1
ambari-web/app/views/wizard/step7_view.js

@@ -21,6 +21,10 @@ var App = require('app');
 
 App.WizardStep7View = Em.View.extend({
 
-  templateName: require('templates/wizard/step7')
+  templateName: require('templates/wizard/step7'),
+
+  willInsertElement: function () {
+    this.get('controller').checkConfigLoad();
+  }
 
 });