瀏覽代碼

AMBARI-11194. UI calls to /validations fails due to empty host-to-component mappings on large clusters. (srimanth via yusaku)

Yusaku Sako 10 年之前
父節點
當前提交
45f0cd3f87
共有 2 個文件被更改,包括 43 次插入1 次删除
  1. 38 1
      ambari-web/app/mixins/common/serverValidator.js
  2. 5 0
      ambari-web/app/utils/ajax/ajax.js

+ 38 - 1
ambari-web/app/mixins/common/serverValidator.js

@@ -152,16 +152,53 @@ App.ServerValidatorMixin = Em.Mixin.create({
 
   serverSideValidation: function () {
     var deferred = $.Deferred();
+    var self = this;
     this.set('configValidationFailed', false);
     this.set('configValidationGlobalMessage', []);
     if (this.get('configValidationFailed')) {
       this.warnUser(deferred);
     } else {
-      this.runServerSideValidation(deferred);
+      if (this.get('isInstaller')) {
+        this.runServerSideValidation(deferred);
+      } else {
+        // on Service Configs page we need to load all hosts with componnets
+        this.getAllHostsWithComponents().then(function(data) {
+          self.set('content.recommendationsHostGroups', blueprintUtils.generateHostGroups(App.get('allHostNames'), self.mapHostsToComponents(data.items)));
+          self.runServerSideValidation(deferred);
+        });
+      }
     }
     return deferred;
   },
 
+  getAllHostsWithComponents: function() {
+    return App.ajax.send({
+      sender: this,
+      name: 'common.hosts.all',
+      data: {
+        urlParams: 'fields=HostRoles/component_name,HostRoles/host_name'
+      }
+    });
+  },
+
+  /**
+   * Generate array similar to App.HostComponent which will be used to
+   * create blueprint hostGroups object as well.
+   *
+   * @param {Object[]} jsonData
+   * @returns {Em.Object[]}
+   */
+  mapHostsToComponents: function(jsonData) {
+    var result = [];
+    jsonData.forEach(function(item) {
+      result.push(Em.Object.create({
+        componentName: Em.get(item, 'HostRoles.component_name'),
+        hostName: Em.get(item, 'HostRoles.host_name')
+      }));
+    });
+    return result;
+  },
+
   /**
    * @method serverSideValidation
    * send request to validate configs

+ 5 - 0
ambari-web/app/utils/ajax/ajax.js

@@ -159,6 +159,11 @@ var urls = {
     }
   },
 
+  'common.hosts.all': {
+    'real': '/clusters/{clusterName}/host_components?{urlParams}&minimal_response=true',
+    'mock': ''
+  },
+
   'common.service.configurations': {
     'real':'/clusters/{clusterName}',
     'mock':'',