Переглянути джерело

AMBARI-5286 Long time loading of Customize Services step. (atkach)

atkach 11 роки тому
батько
коміт
3dd56eb442

+ 71 - 0
ambari-web/app/controllers/installer.js

@@ -110,6 +110,77 @@ App.InstallerController = App.WizardController.extend({
    }
   },
 
+  /**
+   * total set of hosts registered to cluster, analog of App.Host model,
+   * used in Installer wizard until hosts are installed
+   */
+  allHosts: function () {
+    var rawHosts = this.get('content.hosts');
+    var masterComponents = this.get('content.masterComponentHosts');
+    var slaveComponents = this.get('content.slaveComponentHosts');
+    var hosts = [];
+    masterComponents.forEach(function (component) {
+      var host = rawHosts[component.hostName];
+      if (host.hostComponents) {
+        host.hostComponents.push(Em.Object.create({
+          componentName: component.component,
+          displayName: component.display_name
+        }));
+      } else {
+        rawHosts[component.hostName].hostComponents = [
+          Em.Object.create({
+            componentName: component.component,
+            displayName: component.display_name
+          })
+        ]
+      }
+    });
+    slaveComponents.forEach(function (component) {
+      component.hosts.forEach(function (rawHost) {
+        var host = rawHosts[rawHost.hostName];
+        if (host.hostComponents) {
+          host.hostComponents.push(Em.Object.create({
+            componentName: component.componentName,
+            displayName: component.displayName
+          }));
+        } else {
+          rawHosts[rawHost.hostName].hostComponents = [
+            Em.Object.create({
+              componentName: component.componentName,
+              displayName: component.displayName
+            })
+          ]
+        }
+      });
+    });
+
+    for (var hostName in rawHosts) {
+      var host = rawHosts[hostName];
+      var disksOverallCapacity = 0;
+      var diskFree = 0;
+      host.disk_info.forEach(function (disk) {
+        disksOverallCapacity += parseFloat(disk.size);
+        diskFree += parseFloat(disk.available);
+      });
+      hosts.pushObject(Em.Object.create({
+          id: host.name,
+          ip: host.ip,
+          osType: host.os_type,
+          osArch: host.os_arch,
+          hostName: host.name,
+          publicHostName: host.name,
+          cpu: host.cpu,
+          memory: host.memory,
+          diskInfo: host.disk_info,
+          diskTotal: disksOverallCapacity / (1024 * 1024),
+          diskFree: diskFree / (1024 * 1024),
+          hostComponents: host.hostComponents
+        }
+      ))
+    }
+    return hosts;
+  }.property('content.hosts'),
+
   stacks: [],
 
   /**

+ 0 - 4
ambari-web/app/controllers/main/service/info/configs.js

@@ -1642,10 +1642,6 @@ App.MainServiceInfoConfigsController = Em.Controller.extend({
     return validComponents;
   }.property('content'),
 
-  getAllHosts: function () {
-    return App.router.get('mainHostController.content');
-  }.property('App.router.mainHostController.content'),
-
   doCancel: function () {
     this.loadStep();
   },

+ 2 - 0
ambari-web/app/controllers/wizard.js

@@ -65,6 +65,8 @@ App.WizardController = Em.Controller.extend({
     App.db.set(this.get('dbNamespace'), key, value);
   },
 
+  allHosts: App.Host.find(),
+
   setStepsEnable: function () {
     for (var i = 1; i <= this.totalSteps; i++) {
       var step = this.get('isStepDisabled').findProperty('step', i);

+ 3 - 64
ambari-web/app/controllers/wizard/step7_controller.js

@@ -125,7 +125,7 @@ App.WizardStep7Controller = Em.Controller.extend({
     var serviceName = params.serviceName;
     var service = this.get('stepConfigs').findProperty('serviceName', serviceName);
     // Create default configuration group
-    var defaultConfigGroupHosts = App.Host.find().mapProperty('hostName');
+    var defaultConfigGroupHosts = this.get('wizardController.allHosts').mapProperty('hostName');
     var selectedConfigGroup;
     var siteToTagMap = {};
     for (var site in data.Clusters.desired_configs) {
@@ -492,7 +492,7 @@ App.WizardStep7Controller = Em.Controller.extend({
    */
   loadConfigGroups: function (serviceConfigGroups) {
     var services = this.get('stepConfigs');
-    var hosts = this.get('getAllHosts').mapProperty('hostName');
+    var hosts = this.get('wizardController.allHosts').mapProperty('hostName');
     services.forEach(function (service) {
       if (service.get('serviceName') === 'MISC') return;
       var serviceRawGroups = serviceConfigGroups.filterProperty('service.id', service.serviceName);
@@ -662,67 +662,6 @@ App.WizardStep7Controller = Em.Controller.extend({
       }
     });
     return validComponents;
-  }.property('content'),
-
-
-  getAllHosts: function () {
-    if (App.Host.find().content.length > 0) {
-      return App.Host.find();
-    }
-    var hosts = this.get('content.hosts');
-    var masterComponents = this.get('content.masterComponentHosts');
-    var slaveComponents = this.get('content.slaveComponentHosts');
-    masterComponents.forEach(function (component) {
-      App.HostComponent.createRecord({
-        id: component.component + '_' + component.hostName,
-        componentName: component.component,
-        host_id: component.hostName
-      });
-      if (!hosts[component.hostName].hostComponents) {
-        hosts[component.hostName].hostComponents = [];
-      }
-      hosts[component.hostName].hostComponents.push(component.component + '_' + component.hostName);
-    });
-    slaveComponents.forEach(function (component) {
-      component.hosts.forEach(function (host) {
-        App.HostComponent.createRecord({
-          id: component.componentName + '_' + host.hostName,
-          componentName: component.componentName,
-          host_id: host.hostName
-        });
-        if (!hosts[host.hostName].hostComponents) {
-          hosts[host.hostName].hostComponents = [];
-        }
-        hosts[host.hostName].hostComponents.push(component.componentName + '_' + host.hostName);
-      });
-    });
-
-    for (var hostName in hosts) {
-      var host = hosts[hostName];
-      var disksOverallCapacity = 0;
-      var diskFree = 0;
-      host.disk_info.forEach(function(disk) {
-        disksOverallCapacity += parseFloat(disk.size);
-        diskFree += parseFloat(disk.available);
-      });
-      App.store.load(App.Host,
-        {
-          id: host.name,
-          ip: host.ip,
-          os_type: host.os_type,
-          os_arch: host.os_arch,
-          host_name: host.name,
-          public_host_name: host.name,
-          cpu: host.cpu,
-          memory: host.memory,
-          disk_info: host.disk_info,
-          disk_total: disksOverallCapacity / (1024 * 1024),
-          disk_free: diskFree / (1024 * 1024),
-          host_components: host.hostComponents
-        }
-      )
-    }
-    return App.Host.find();
-  }.property('content.hosts')
+  }.property('content')
 
 });

+ 9 - 2
ambari-web/app/models/config_group.js

@@ -113,12 +113,19 @@ App.ConfigGroup = Ember.Object.extend({
     if (this.get('isDefault')) return [];
     var unusedHostsMap = {};
     var availableHosts = [];
+    var sharedHosts = [];
+    //if cluster is not installed then get hosts from installerController instead of model
+    if (App.clusterStatus.get('isInstalled')) {
+      sharedHosts = App.Host.find();
+    } else {
+      sharedHosts = App.router.get('installerController.allHosts');
+    }
     // parentConfigGroup.hosts(hosts from default group) - are available hosts, which don't belong to any group
     this.get('parentConfigGroup.hosts').forEach(function (hostName) {
       unusedHostsMap[hostName] = true;
     });
-    App.Host.find().forEach(function (host) {
-      if(unusedHostsMap[host.get('id')]) {
+    sharedHosts.forEach(function (host) {
+      if (unusedHostsMap[host.get('id')]) {
         availableHosts.pushObject(Ember.Object.create({
           selected: false,
           host: host,

+ 0 - 6
ambari-web/app/routes/installer.js

@@ -173,9 +173,6 @@ module.exports = Em.Route.extend({
       var controller = router.get('installerController');
       controller.setCurrentStep('2');
       controller.loadAllPriorSteps();
-      if (App.Host.find().content.length) {
-        App.Host.find().clear();
-      }
       controller.connectOutlet('wizardStep2', controller.get('content'));
     },
     back: Em.Router.transitionTo('step1'),
@@ -321,9 +318,6 @@ module.exports = Em.Route.extend({
       if (App.supports.hostOverridesInstaller) {
         installerController.saveServiceConfigGroups(wizardStep7Controller);
       }
-      if (App.Host.find().content.length) {
-        App.Host.find().clear();
-      }
       router.transitionTo('step8');
     }
   }),

+ 0 - 5
ambari-web/app/views/common/configs/overriddenProperty_view.js

@@ -24,11 +24,6 @@ App.ServiceConfigView.SCPOverriddenRowsView = Ember.View.extend({
   // we are declaring this from configs.hbs ( we are initializing this from UI )
   categoryConfigs: null, // just declared as viewClass need it
   
-  showOverrideWindow: function (event) {
-    // App.ServiceConfigsByCategoryView in which the current view is nested
-    this.get('parentView').showOverrideWindow(event);
-  },
-
   removeOverride: function (event) {
     // arg 1 SCP means ServiceConfigProperty
     var scpToBeRemoved = event.contexts[0];

+ 0 - 56
ambari-web/app/views/common/configs/services_config.js

@@ -580,62 +580,6 @@ App.ServiceConfigsByCategoryView = Ember.View.extend({
     } else {
       serviceConfigController.addOverrideProperty(serviceConfigProperty);
     }
-  },
-
-  showOverrideWindow: function (event) {
-    // argument 1
-    var serviceConfigProperty = event.contexts[0];
-    var parentServiceConfigProperty = serviceConfigProperty.get('parentSCP');
-    var alreadyOverriddenHosts = [];
-    parentServiceConfigProperty.get('overrides').forEach(function (override) {
-      if (override != null && override != serviceConfigProperty && override.get('selectedHostOptions') != null) {
-        alreadyOverriddenHosts = alreadyOverriddenHosts.concat(override.get('selectedHostOptions'))
-      }
-    });
-    var selectedHosts = serviceConfigProperty.get('selectedHostOptions');
-    /**
-     * Get all the hosts available for selection. Since data is dependent on
-     * controller, we ask it, instead of doing regular Ember's App.Host.find().
-     * This should be an array of App.Host.
-     */
-    var allHosts = this.get('controller.getAllHosts');
-    var availableHosts = Ember.A([]);
-    allHosts.forEach(function (host) {
-      var hostId = host.get('id');
-      if (alreadyOverriddenHosts.indexOf(hostId) < 0) {
-        availableHosts.pushObject(Ember.Object.create({
-          selected: selectedHosts.indexOf(hostId) > -1,
-          host: host
-        }));
-      }
-    });
-    /**
-     * From the currently selected service we want the service-components.
-     * We only need an array of objects which have the 'componentName' and
-     * 'displayName' properties. Since each controller has its own objects,
-     * we ask for a normalized array back.
-     */
-    var validComponents = this.get('controller.getCurrentServiceComponents');
-    var popupDescription = {
-      header: Em.I18n.t('hosts.selectHostsDialog.title'),
-      dialogMessage: Em.I18n.t('hosts.selectHostsDialog.message').format(App.Service.DisplayNames[this.get('service.serviceName')])
-    };
-    hostsUtils.launchHostsSelectionDialog(availableHosts, selectedHosts,
-        false, validComponents, function(newSelectedHosts){
-      if (newSelectedHosts!=null) {
-        serviceConfigProperty.set('selectedHostOptions', newSelectedHosts);
-        serviceConfigProperty.validate();
-      } else {
-        // Dialog cancelled
-        // If property has no hosts already, then remove it from the parent.
-        var hostCount = serviceConfigProperty.get('selectedHostOptions.length');
-        if (hostCount < 1) {
-          var parentSCP = serviceConfigProperty.get('parentSCP');
-          var overrides = parentSCP.get('overrides');
-          overrides.removeObject(serviceConfigProperty);
-        }
-      }
-    }, popupDescription);
   }
 });