|
@@ -18,6 +18,7 @@
|
|
|
|
|
|
var App = require('app');
|
|
|
var numberUtils = require('utils/number_utils');
|
|
|
+var lazyLoading = require('utils/lazy_loading');
|
|
|
|
|
|
App.WizardStep5Controller = Em.Controller.extend({
|
|
|
|
|
@@ -65,18 +66,38 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
*/
|
|
|
multipleComponents: ['ZOOKEEPER_SERVER', 'HBASE_MASTER'],
|
|
|
|
|
|
- /**
|
|
|
- * Define state for submit button
|
|
|
- * @type {bool}
|
|
|
- */
|
|
|
submitDisabled: false,
|
|
|
|
|
|
/**
|
|
|
- * Trigger for executing host names check for components
|
|
|
- * Should de "triggered" when host changed for some component and when new multiple component is added/removed
|
|
|
+ * Define state for submit button. Return true only for Reassign Master Wizard and if more than one master component was reassigned.
|
|
|
* @type {bool}
|
|
|
*/
|
|
|
- hostNameCheckTrigger: false,
|
|
|
+ isSubmitDisabled: function () {
|
|
|
+ if (!this.get('isReassignWizard')) {
|
|
|
+ this.set('submitDisabled', false);
|
|
|
+ } else {
|
|
|
+ App.ajax.send({
|
|
|
+ name: 'host_components.all',
|
|
|
+ sender: this,
|
|
|
+ data: {
|
|
|
+ clusterName: App.get('clusterName')
|
|
|
+ },
|
|
|
+ success: 'isSubmitDisabledSuccessCallBack'
|
|
|
+ });
|
|
|
+ }
|
|
|
+ }.observes('servicesMasters.@each.selectedHost'),
|
|
|
+
|
|
|
+ isSubmitDisabledSuccessCallBack: function (response) {
|
|
|
+ var reassigned = 0;
|
|
|
+ var arr1 = response.items.mapProperty('HostRoles').filterProperty('component_name', this.get('content.reassign.component_name')).mapProperty('host_name');
|
|
|
+ var arr2 = this.get('servicesMasters').mapProperty('selectedHost');
|
|
|
+ arr1.forEach(function (host) {
|
|
|
+ if (!arr2.contains(host)) {
|
|
|
+ reassigned++;
|
|
|
+ }
|
|
|
+ }, this);
|
|
|
+ this.set('submitDisabled', reassigned !== 1);
|
|
|
+ },
|
|
|
|
|
|
/**
|
|
|
* List of hosts
|
|
@@ -85,13 +106,11 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
hosts: [],
|
|
|
|
|
|
/**
|
|
|
- * Name of multiple component which host name was changed last
|
|
|
* @type {Object|null}
|
|
|
*/
|
|
|
componentToRebalance: null,
|
|
|
|
|
|
/**
|
|
|
- * Flag for rebalance multiple components
|
|
|
* @type {number}
|
|
|
*/
|
|
|
rebalanceComponentHostsCounter: 0,
|
|
@@ -106,12 +125,6 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
*/
|
|
|
selectedServicesMasters: [],
|
|
|
|
|
|
- /**
|
|
|
- * Is data for current step loaded
|
|
|
- * @type {bool}
|
|
|
- */
|
|
|
- isLoaded: false,
|
|
|
-
|
|
|
/**
|
|
|
* Check if HIVE_SERVER component exist (also checks if this is not reassign)
|
|
|
* @type {bool}
|
|
@@ -128,40 +141,69 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
* {
|
|
|
* host_name: '',
|
|
|
* hostInfo: {},
|
|
|
- * masterServices: [],
|
|
|
- * masterServicesToDisplay: [] // used only in template
|
|
|
+ * masterServices: []
|
|
|
* },
|
|
|
* ....
|
|
|
* ]
|
|
|
* </code>
|
|
|
* @type {Ember.Enumerable}
|
|
|
*/
|
|
|
- masterHostMapping: function () {
|
|
|
+ masterHostMapping: [],
|
|
|
+
|
|
|
+ isLoaded: false,
|
|
|
+
|
|
|
+ /**
|
|
|
+ * Check if HIVE_SERVER component exist (also checks if this is not reassign)
|
|
|
+ * @type {bool}
|
|
|
+ */
|
|
|
+ hasHiveServer: function () {
|
|
|
+ return this.get('selectedServicesMasters').someProperty('component_name', 'HIVE_SERVER') && !this.get('isReassignWizard');
|
|
|
+ }.property('selectedServicesMasters'),
|
|
|
+
|
|
|
+ masterHostMappingObserver: function () {
|
|
|
+ var requestName = this.get('content.controllerName') == 'installerController' ? 'hosts.confirmed.install' : 'hosts.confirmed'
|
|
|
+ App.ajax.send({
|
|
|
+ name: requestName,
|
|
|
+ sender: this,
|
|
|
+ data: {
|
|
|
+ clusterName: App.get('clusterName')
|
|
|
+ },
|
|
|
+ success: 'masterHostMappingSuccessCallback'
|
|
|
+ });
|
|
|
+ }.observes('selectedServicesMasters', 'selectedServicesMasters.@each.selectedHost'),
|
|
|
+
|
|
|
+ masterHostMappingSuccessCallback: function (response) {
|
|
|
var mapping = [], mappingObject, mappedHosts, hostObj;
|
|
|
//get the unique assigned hosts and find the master services assigned to them
|
|
|
- mappedHosts = this.get("selectedServicesMasters").mapProperty("selectedHost").uniq();
|
|
|
+ mappedHosts = this.get("selectedServicesMasters").mapProperty("selectedHost").uniq().without(undefined);
|
|
|
mappedHosts.forEach(function (item) {
|
|
|
- hostObj = this.get("hosts").findProperty("host_name", item);
|
|
|
- // User may input invalid host name (this is handled in hostname checker). Here we just skip it
|
|
|
- if (!hostObj) return;
|
|
|
- var masterServices = this.get("selectedServicesMasters").filterProperty("selectedHost", item),
|
|
|
- masterServicesToDisplay = [];
|
|
|
- masterServices.mapProperty('display_name').uniq().forEach(function(n) {
|
|
|
- masterServicesToDisplay.pushObject(masterServices.findProperty('display_name', n));
|
|
|
- });
|
|
|
+ var host = response.items.mapProperty('Hosts').findProperty('host_name', item);
|
|
|
+ hostObj = {
|
|
|
+ name: host.host_name,
|
|
|
+ memory: host.total_mem,
|
|
|
+ cpu: host.cpu_count
|
|
|
+ };
|
|
|
+
|
|
|
mappingObject = Em.Object.create({
|
|
|
host_name: item,
|
|
|
- hostInfo: hostObj.host_info,
|
|
|
- masterServices: masterServices,
|
|
|
- masterServicesToDisplay: masterServicesToDisplay
|
|
|
+ hostInfo: Em.I18n.t('installer.step5.hostInfo').fmt(hostObj.name, numberUtils.bytesToSize(hostObj.memory, 1, 'parseFloat', 1024), hostObj.cpu),
|
|
|
+ masterServices: this.get("selectedServicesMasters").filterProperty("selectedHost", item)
|
|
|
});
|
|
|
|
|
|
mapping.pushObject(mappingObject);
|
|
|
}, this);
|
|
|
|
|
|
- return mapping.sortProperty('host_name');
|
|
|
- }.property("selectedServicesMasters.@each.selectedHost", 'selectedServicesMasters.@each.isHostNameValid'),
|
|
|
-
|
|
|
+ this.set('masterHostMapping', []);
|
|
|
+ lazyLoading.run({
|
|
|
+ initSize: 20,
|
|
|
+ chunkSize: 50,
|
|
|
+ delay: 50,
|
|
|
+ destination: this.get('masterHostMapping'),
|
|
|
+ source: mapping.sortProperty('host_name'),
|
|
|
+ context: Em.Object.create()
|
|
|
+ });
|
|
|
+ },
|
|
|
+
|
|
|
/**
|
|
|
* Count of hosts without masters
|
|
|
* @type {number}
|
|
@@ -171,48 +213,9 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
return 0;
|
|
|
} else {
|
|
|
return (this.get("hosts.length") - this.get("masterHostMapping.length"));
|
|
|
- }
|
|
|
+ };
|
|
|
}.property('masterHostMapping.length', 'selectedServicesMasters.@each.selectedHost'),
|
|
|
|
|
|
- /**
|
|
|
- * Update submit button status
|
|
|
- * @metohd getIsSubmitDisabled
|
|
|
- */
|
|
|
- getIsSubmitDisabled: function () {
|
|
|
- if (!this.get('isReassignWizard')) {
|
|
|
- this.set('submitDisabled', this.get('servicesMasters').someProperty('isHostNameValid', false));
|
|
|
- }
|
|
|
- else {
|
|
|
- App.ajax.send({
|
|
|
- name: 'host_components.all',
|
|
|
- sender: this,
|
|
|
- data: {
|
|
|
- clusterName: App.get('clusterName')
|
|
|
- },
|
|
|
- success: 'getIsSubmitDisabledSuccessCallBack'
|
|
|
- });
|
|
|
- }
|
|
|
- }.observes('servicesMasters.@each.selectedHost', 'servicesMasters.@each.isHostNameValid'),
|
|
|
-
|
|
|
- /**
|
|
|
- * Success callback for getIsSubmitDisabled method
|
|
|
- * Set true for Reassign Master Wizard and if more than one master component was reassigned.
|
|
|
- * For installer, addHost and addService verify that provided host names for components are valid
|
|
|
- * @param {object} response
|
|
|
- * @method getIsSubmitDisabledSuccessCallBack
|
|
|
- */
|
|
|
- getIsSubmitDisabledSuccessCallBack: function (response) {
|
|
|
- var reassigned = 0;
|
|
|
- var arr1 = response.items.mapProperty('HostRoles').filterProperty('component_name', this.get('content.reassign.component_name')).mapProperty('host_name');
|
|
|
- var arr2 = this.get('servicesMasters').mapProperty('selectedHost');
|
|
|
- arr1.forEach(function (host) {
|
|
|
- if (!arr2.contains(host)) {
|
|
|
- reassigned++;
|
|
|
- }
|
|
|
- }, this);
|
|
|
- this.set('submitDisabled', reassigned !== 1);
|
|
|
- },
|
|
|
-
|
|
|
/**
|
|
|
* Clear controller data (hosts, masters etc)
|
|
|
* @method clearStep
|
|
@@ -288,7 +291,15 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
}));
|
|
|
}
|
|
|
}
|
|
|
- this.set("hosts", result);
|
|
|
+ this.set("hosts", []);
|
|
|
+ lazyLoading.run({
|
|
|
+ initSize: 20,
|
|
|
+ chunkSize: 50,
|
|
|
+ delay: 50,
|
|
|
+ destination: this.get('hosts'),
|
|
|
+ source: result,
|
|
|
+ context: Em.Object.create()
|
|
|
+ });
|
|
|
this.sortHosts(this.get('hosts'));
|
|
|
this.set('isLoaded', true);
|
|
|
},
|
|
@@ -420,7 +431,6 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
- componentObj.set('isHostNameValid', true);
|
|
|
result.push(componentObj);
|
|
|
}, this);
|
|
|
|
|
@@ -549,61 +559,18 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
- * On change callback for inputs
|
|
|
+ * On change callback for selects
|
|
|
* @param {string} componentName
|
|
|
* @param {string} selectedHost
|
|
|
* @param {number} zId
|
|
|
* @method assignHostToMaster
|
|
|
*/
|
|
|
assignHostToMaster: function (componentName, selectedHost, zId) {
|
|
|
- var flag = this.isHostNameValid(componentName, selectedHost);
|
|
|
- this.updateIsHostNameValidFlag(componentName, zId, flag);
|
|
|
- if (zId) {
|
|
|
- this.get('selectedServicesMasters').filterProperty('component_name', componentName).findProperty("zId", zId).set("selectedHost", selectedHost);
|
|
|
- }
|
|
|
- else {
|
|
|
- this.get('selectedServicesMasters').findProperty("component_name", componentName).set("selectedHost", selectedHost);
|
|
|
- }
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * Determines if hostName is valid for component:
|
|
|
- * <ul>
|
|
|
- * <li>host name shouldn't be empty</li>
|
|
|
- * <li>host should exist</li>
|
|
|
- * <li>host should have only one component with <code>componentName</code></li>
|
|
|
- * </ul>
|
|
|
- * @param {string} componentName
|
|
|
- * @param {string} selectedHost
|
|
|
- * @returns {boolean} true - valid, false - invalid
|
|
|
- * @method isHostNameValid
|
|
|
- */
|
|
|
- isHostNameValid: function(componentName, selectedHost) {
|
|
|
- return (selectedHost.trim() !== '') &&
|
|
|
- this.get('hosts').mapProperty('host_name').contains(selectedHost) &&
|
|
|
- (this.get('selectedServicesMasters').
|
|
|
- filterProperty('component_name', componentName).
|
|
|
- mapProperty('selectedHost').
|
|
|
- filter(function(h) {
|
|
|
- return h === selectedHost;
|
|
|
- }).length <= 1);
|
|
|
- },
|
|
|
-
|
|
|
- /**
|
|
|
- * Update <code>isHostNameValid</code> property with <code>flag</code> value
|
|
|
- * for component with name <code>componentName</code> and
|
|
|
- * <code>zId</code>-property equal to <code>zId</code>-parameter value
|
|
|
- * @param {string} componentName
|
|
|
- * @param {number} zId
|
|
|
- * @param {bool} flag
|
|
|
- * @method updateIsHostNameValidFlag
|
|
|
- */
|
|
|
- updateIsHostNameValidFlag: function (componentName, zId, flag) {
|
|
|
- if (componentName) {
|
|
|
+ if (selectedHost && componentName) {
|
|
|
if (zId) {
|
|
|
- this.get('selectedServicesMasters').filterProperty('component_name', componentName).findProperty("zId", zId).set("isHostNameValid", flag);
|
|
|
+ this.get('selectedServicesMasters').filterProperty('component_name', componentName).findProperty("zId", zId).set("selectedHost", selectedHost);
|
|
|
} else {
|
|
|
- this.get('selectedServicesMasters').findProperty("component_name", componentName).set("isHostNameValid", flag);
|
|
|
+ this.get('selectedServicesMasters').findProperty("component_name", componentName).set("selectedHost", selectedHost);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
@@ -681,7 +648,7 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
|
|
|
this.set('componentToRebalance', componentName);
|
|
|
this.incrementProperty('rebalanceComponentHostsCounter');
|
|
|
- this.toggleProperty('hostNameCheckTrigger');
|
|
|
+
|
|
|
return true;
|
|
|
}
|
|
|
return false;//if no more zookeepers can be added
|
|
@@ -715,7 +682,7 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
|
|
|
this.set('componentToRebalance', componentName);
|
|
|
this.incrementProperty('rebalanceComponentHostsCounter');
|
|
|
- this.toggleProperty('hostNameCheckTrigger');
|
|
|
+
|
|
|
return true;
|
|
|
},
|
|
|
|
|
@@ -724,7 +691,7 @@ App.WizardStep5Controller = Em.Controller.extend({
|
|
|
* @metohd submit
|
|
|
*/
|
|
|
submit: function () {
|
|
|
- this.getIsSubmitDisabled();
|
|
|
+ this.isSubmitDisabled();
|
|
|
if (!this.get('submitDisabled')) {
|
|
|
App.router.send('next');
|
|
|
}
|