You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by at...@apache.org on 2014/07/10 17:16:50 UTC
git commit: AMBARI-6454 Calls to load general cluster data should be
asynchronous. (atkach)
Repository: ambari
Updated Branches:
refs/heads/trunk 30a41aca3 -> 05630b232
AMBARI-6454 Calls to load general cluster data should be asynchronous. (atkach)
Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/05630b23
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/05630b23
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/05630b23
Branch: refs/heads/trunk
Commit: 05630b23244b970bcc3645af02ac56e193125262
Parents: 30a41ac
Author: atkach <at...@hortonworks.com>
Authored: Thu Jul 10 18:14:11 2014 +0300
Committer: atkach <at...@hortonworks.com>
Committed: Thu Jul 10 18:14:11 2014 +0300
----------------------------------------------------------------------
.../controllers/global/cluster_controller.js | 28 ++++----
.../highAvailability/progress_controller.js | 63 ++++++++--------
.../main/admin/highAvailability_controller.js | 20 +-----
.../app/controllers/wizard/step8_controller.js | 21 +++---
.../app/controllers/wizard/step9_controller.js | 41 ++++++-----
ambari-web/app/router.js | 28 --------
ambari-web/app/routes/main.js | 19 ++---
ambari-web/app/utils/ajax/ajax.js | 76 ++------------------
ambari-web/app/utils/db.js | 13 ----
.../info/metrics/flume/flume_metric_graphs.js | 1 -
10 files changed, 103 insertions(+), 207 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/controllers/global/cluster_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/cluster_controller.js b/ambari-web/app/controllers/global/cluster_controller.js
index 2d91d94..6a48028 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -84,20 +84,24 @@ App.ClusterController = Em.Controller.extend({
* load cluster name
*/
loadClusterName: function (reload) {
- if (this.get('clusterName') && !reload) {
- return false;
- }
-
- App.ajax.send({
- name: 'cluster.load_cluster_name',
- sender: this,
- success: 'loadClusterNameSuccessCallback',
- error: 'loadClusterNameErrorCallback'
- });
+ var dfd = $.Deferred();
- if (!App.get('currentStackVersion')) {
- App.set('currentStackVersion', App.defaultStackVersion);
+ if (this.get('clusterName') && !reload) {
+ dfd.resolve();
+ } else {
+ App.ajax.send({
+ name: 'cluster.load_cluster_name',
+ sender: this,
+ success: 'loadClusterNameSuccessCallback',
+ error: 'loadClusterNameErrorCallback'
+ }).complete(function () {
+ if (!App.get('currentStackVersion')) {
+ App.set('currentStackVersion', App.defaultStackVersion);
+ }
+ dfd.resolve();
+ });
}
+ return dfd.promise()
},
loadClusterNameSuccessCallback: function (data) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js b/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js
index a1aa2ad..8aa58cd 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js
@@ -232,12 +232,10 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
* check whether component installed on specified hosts
* @param componentName
* @param hostNames
- * @return {Array}
+ * @return {$.ajax}
*/
checkInstalledComponents: function (componentName, hostNames) {
- var result = [];
-
- App.ajax.send({
+ return App.ajax.send({
name: 'host_component.installed.on_hosts',
sender: this,
data: {
@@ -246,14 +244,6 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
},
success: 'checkInstalledComponentsSuccessCallback'
});
- hostNames.forEach(function (hostName) {
- result.push({
- componentName: componentName,
- hostName: hostName,
- hasComponent: installedComponents.someProperty('HostRoles.host_name', hostName)
- });
- });
- return result;
},
checkInstalledComponentsSuccessCallback: function (data, opt, params) {
@@ -262,26 +252,39 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
createComponent: function (componentName, hostName, serviceName) {
var hostNames = (Array.isArray(hostName)) ? hostName : [hostName];
+ var self = this;
+
+ this.checkInstalledComponents(componentName, hostNames).complete(function () {
+ var result = [];
- this.checkInstalledComponents(componentName, hostNames).forEach(function (host, index, array) {
- if (!host.hasComponent) {
- App.ajax.send({
- name: 'admin.high_availability.create_component',
- sender: this,
- data: {
- hostName: host.hostName,
- componentName: host.componentName,
- serviceName: serviceName,
- taskNum: array.length
- },
- success: 'onCreateComponent',
- error: 'onCreateComponentError'
+ hostNames.forEach(function (hostName) {
+ result.push({
+ componentName: componentName,
+ hostName: hostName,
+ hasComponent: installedComponents.someProperty('HostRoles.host_name', hostName)
});
- } else {
- // Simulates format returned from ajax.send
- this.onCreateComponent(null, null, {hostName: host.hostName, componentName: host.componentName, taskNum: array.length});
- }
- }, this)
+ });
+
+ result.forEach(function (host, index, array) {
+ if (!host.hasComponent) {
+ App.ajax.send({
+ name: 'admin.high_availability.create_component',
+ sender: this,
+ data: {
+ hostName: host.hostName,
+ componentName: host.componentName,
+ serviceName: serviceName,
+ taskNum: array.length
+ },
+ success: 'onCreateComponent',
+ error: 'onCreateComponentError'
+ });
+ } else {
+ // Simulates format returned from ajax.send
+ this.onCreateComponent(null, null, {hostName: host.hostName, componentName: host.componentName, taskNum: array.length});
+ }
+ }, self)
+ });
},
onCreateComponent: function () {
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/controllers/main/admin/highAvailability_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/highAvailability_controller.js b/ambari-web/app/controllers/main/admin/highAvailability_controller.js
index cb06002..91b6d61 100644
--- a/ambari-web/app/controllers/main/admin/highAvailability_controller.js
+++ b/ambari-web/app/controllers/main/admin/highAvailability_controller.js
@@ -47,7 +47,7 @@ App.MainAdminHighAvailabilityController = Em.Controller.extend({
message.push(Em.I18n.t('admin.highAvailability.error.zooKeeperNum'));
}
- if (this.getTotalHosts() < 3) {
+ if (App.router.get('mainHostController.hostsCountMap.TOTAL') < 3) {
message.push(Em.I18n.t('admin.highAvailability.error.hostsNum'));
}
if (message.length > 0) {
@@ -59,24 +59,6 @@ App.MainAdminHighAvailabilityController = Em.Controller.extend({
return true;
},
- /**
- * get total hosts count from cluster API
- * @return {Number}
- */
- getTotalHosts: function () {
- App.ajax.send({
- name: 'hosts.total_count',
- data: {},
- sender: this,
- success: 'getTotalHostsSuccessCallback'
- });
- return totalHosts;
- },
-
- getTotalHostsSuccessCallback: function (data, opt, params) {
- totalHosts = data.Clusters.total_hosts;
- },
-
disableHighAvailability: function () {
App.router.transitionTo('main.admin.rollbackHighAvailability');
},
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/controllers/wizard/step8_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step8_controller.js b/ambari-web/app/controllers/wizard/step8_controller.js
index f58c602..8af8cd2 100644
--- a/ambari-web/app/controllers/wizard/step8_controller.js
+++ b/ambari-web/app/controllers/wizard/step8_controller.js
@@ -863,6 +863,7 @@ App.WizardStep8Controller = Em.Controller.extend({
* @method submitProceed
*/
submitProceed: function () {
+ var self = this;
this.set('isSubmitDisabled', true);
this.set('isBackBtnDisabled', true);
if (this.get('content.controllerName') == 'addHostController') {
@@ -901,30 +902,30 @@ App.WizardStep8Controller = Em.Controller.extend({
// delete any existing clusters to start from a clean slate
// before creating a new cluster in install wizard
// TODO: modify for multi-cluster support
- var clusterNames = this.getExistingClusterNames();
- if (this.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
- this.deleteClusters(clusterNames);
- } else {
- this.deleteClustersCallback(null, null, {isLast: true});
- }
+ this.getExistingClusterNames().complete(function () {
+ var clusterNames = self.get('clusterNames');
+ if (self.get('content.controllerName') == 'installerController' && (!App.get('testMode')) && clusterNames.length) {
+ self.deleteClusters(clusterNames);
+ } else {
+ self.deleteClustersCallback(null, null, {isLast: true});
+ }
+ });
},
/**
* Get list of existing cluster names
- * @returns {string[]}
+ * @returns {object|null}
* returns an array of existing cluster names.
* returns an empty array if there are no existing clusters.
* @method getExistingClusterNames
*/
getExistingClusterNames: function () {
- App.ajax.send({
+ return App.ajax.send({
name: 'wizard.step8.existing_cluster_names',
sender: this,
success: 'getExistingClusterNamesSuccessCallBack',
error: 'getExistingClusterNamesErrorCallback'
});
-
- return this.get('clusterNames');
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/controllers/wizard/step9_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js
index d7e39ea..2575085 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/ambari-web/app/controllers/wizard/step9_controller.js
@@ -811,6 +811,8 @@ App.WizardStep9Controller = Em.Controller.extend({
*/
setIsServicesInstalled: function (polledData) {
var clusterStatus = {};
+ var self = this;
+
if (!polledData.someProperty('Tasks.status', 'PENDING') && !polledData.someProperty('Tasks.status', 'QUEUED') && !polledData.someProperty('Tasks.status', 'IN_PROGRESS')) {
clusterStatus = {
status: 'PENDING',
@@ -824,16 +826,19 @@ App.WizardStep9Controller = Em.Controller.extend({
this.get('hosts').forEach(function (host) {
host.set('progress', '100');
});
- this.isAllComponentsInstalled();
+ this.isAllComponentsInstalled().done(function(){
+ self.changeParseHostInfo(false);
+ });
+ return;
} else {
this.set('progress', '34');
if (this.get('content.controllerName') === 'installerController') {
- this.isAllComponentsInstalled();
- this.saveInstalledHosts(this);
- this.changeParseHostInfo(true);
+ this.isAllComponentsInstalled().done(function(){
+ self.saveInstalledHosts(self);
+ self.changeParseHostInfo(true);
+ });
return;
} else {
- var self = this;
this.launchStartServices(function () {
self.saveInstalledHosts(self);
self.changeParseHostInfo(true);
@@ -1071,19 +1076,23 @@ App.WizardStep9Controller = Em.Controller.extend({
* @return {$.ajax|null}
*/
isAllComponentsInstalled: function () {
+ var dfd = $.Deferred();
if (this.get('content.controllerName') !== 'installerController') {
- return null;
+ dfd.resolve();
+ } else {
+ App.ajax.send({
+ name: 'wizard.step9.installer.get_host_status',
+ sender: this,
+ data: {
+ cluster: this.get('content.cluster.name')
+ },
+ success: 'isAllComponentsInstalledSuccessCallback',
+ error: 'isAllComponentsInstalledErrorCallback'
+ }).complete(function(){
+ dfd.resolve();
+ });
}
- var name = 'wizard.step9.installer.get_host_status';
- return App.ajax.send({
- name: name,
- sender: this,
- data: {
- cluster: this.get('content.cluster.name')
- },
- success: 'isAllComponentsInstalledSuccessCallback',
- error: 'isAllComponentsInstalledErrorCallback'
- });
+ return dfd.promise()
},
/**
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/router.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js
index 2e4f87b..ef33669 100644
--- a/ambari-web/app/router.js
+++ b/ambari-web/app/router.js
@@ -248,34 +248,6 @@ App.Router = Em.Router.extend({
console.log("Server not responding: " + req.statusCode);
},
- setAmbariStacks: function () {
- App.ajax.send({
- name: 'router.set_ambari_stacks',
- sender: this,
- success: 'setAmbariStacksSuccessCallback',
- error: 'setAmbariStacksErrorCallback'
- });
- },
-
- setAmbariStacksSuccessCallback: function (jsonData) {
- console.log("TRACE: In success function for the setAmbariStacks call");
- var stacks = [];
- jsonData.forEach(function (_stack) {
- stacks.pushObject({
- name: _stack.name,
- version: _stack.version
- });
- }, this);
- App.db.setAmbariStacks(stacks);
- console.log('TRACEIINNGG: ambaristacks: ' + JSON.stringify(App.db.getAmbariStacks()));
- },
-
- setAmbariStacksErrorCallback: function (request, ajaxOptions, error) {
- console.log("TRACE: In error function for the setAmbariStacks call");
- console.log("TRACE: error code status is: " + request.status);
- console.log('Error message is: ' + request.responseText);
- },
-
getSection: function (callback) {
if (App.testMode) {
if (App.alwaysGoToInstaller) {
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/routes/main.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/routes/main.js b/ambari-web/app/routes/main.js
index 6b46d19..1ce5add 100644
--- a/ambari-web/app/routes/main.js
+++ b/ambari-web/app/routes/main.js
@@ -26,16 +26,17 @@ module.exports = Em.Route.extend({
console.log('in /main:enter');
if (router.getAuthenticated()) {
App.router.get('mainAdminAccessController').loadShowJobsForUsers().done(function () {
- App.router.get('clusterController').loadClusterName(false);
- if (App.get('testMode')) {
- router.get('mainController').initialize();
- } else {
- App.router.get('mainController').checkServerClientVersion().done(function () {
- App.router.get('clusterController').loadClientServerClockDistance().done(function () {
- router.get('mainController').initialize();
+ App.router.get('clusterController').loadClusterName(false).done(function () {
+ if (App.get('testMode')) {
+ router.get('mainController').initialize();
+ } else {
+ App.router.get('mainController').checkServerClientVersion().done(function () {
+ App.router.get('clusterController').loadClientServerClockDistance().done(function () {
+ router.get('mainController').initialize();
+ });
});
- });
- }
+ }
+ });
});
// TODO: redirect to last known state
} else {
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 90824db..b759c4a 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/ambari-web/app/utils/ajax/ajax.js
@@ -325,12 +325,7 @@ var urls = {
},
'config.ambari.database.info': {
'real': '/services/AMBARI/components/AMBARI_SERVER?fields=hostComponents/RootServiceHostComponents/properties/server.jdbc.database,hostComponents/RootServiceHostComponents/properties/server.jdbc.url',
- 'mock': '',
- 'format': function() {
- return {
- async: false
- };
- }
+ 'mock': ''
},
'config_groups.all_fields': {
'real': '/clusters/{clusterName}/config_groups?fields=*',
@@ -458,15 +453,6 @@ var urls = {
'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}?fields=host_components/{metricName}',
'mock': '/data/cluster_metrics/cpu_1hr.json'
},
- 'service.service_component': {
- 'real': '/clusters/{clusterName}/services/{serviceName}/components/{componentName}',
- 'mock': '',
- 'format': function(data) {
- return {
- async: data.async
- };
- }
- },
'service.metrics.flume.channel_fill_percent': {
'real': '/clusters/{clusterName}/services/FLUME/components/FLUME_HANDLER?fields=host_components/metrics/flume/flume/CHANNEL/*/ChannelFillPercentage[{fromSeconds},{toSeconds},{stepSeconds}]',
'mock': '/data/services/metrics/flume/channelFillPct.json',
@@ -765,21 +751,11 @@ var urls = {
},
'cluster.load_cluster_name': {
'real': '/clusters',
- 'mock': '/data/clusters/info.json',
- 'format': function() {
- return {
- async: false
- };
- }
+ 'mock': '/data/clusters/info.json'
},
'cluster.update_upgrade_version': {
'real': '/stacks/HDP/versions?fields=stackServices/StackServices,Versions',
- 'mock': '/data/wizard/stack/stacks.json',
- 'format': function() {
- return {
- async: false
- };
- }
+ 'mock': '/data/wizard/stack/stacks.json'
},
'cluster.load_repositories': {
'real': '/stacks/{stackName}/versions/{stackVersion}/operating_systems?fields=repositories/*',
@@ -946,12 +922,7 @@ var urls = {
},
'wizard.step9.installer.get_host_status': {
'real': '/clusters/{cluster}/hosts?fields=Hosts/host_state,host_components/HostRoles/state',
- 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json',
- 'format': function () {
- return {
- async: false
- };
- }
+ 'mock': '/data/wizard/deploy/5_hosts/get_host_state.json'
},
'wizard.step9.load_log': {
'real': '/clusters/{cluster}/requests/{requestId}?fields=tasks/Tasks/command,tasks/Tasks/exit_code,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
@@ -965,12 +936,7 @@ var urls = {
'wizard.step8.existing_cluster_names': {
'real': '/clusters',
- 'mock': '',
- 'format': function() {
- return {
- async: false
- };
- }
+ 'mock': ''
},
'wizard.step8.create_cluster': {
@@ -1193,15 +1159,6 @@ var urls = {
'real': '/logout',
'mock': ''
},
- 'router.set_ambari_stacks': {
- 'real': '/stacks',
- 'mock': '/data/wizard/stack/stacks.json',
- 'format': function() {
- return {
- async: false
- };
- }
- },
'router.authentication': {
'real': '/clusters',
'mock': '/data/clusters/info.json',
@@ -1547,12 +1504,7 @@ var urls = {
},
'host.host_component.flume.metrics': {
'real': '/clusters/{clusterName}/hosts/{hostName}/host_components/FLUME_HANDLER?fields=metrics/flume/flume/{flumeComponent}/*',
- 'mock': '',
- 'format': function(data) {
- return {
- async: data.async
- }
- }
+ 'mock': ''
},
'host.host_component.flume.metrics.timeseries': {
'real': '',
@@ -1658,15 +1610,6 @@ var urls = {
}
}
},
- 'hosts.total_count': {
- 'real': '/clusters/{clusterName}?fields=Clusters/total_hosts&minimal_response=true',
- 'mock': '',
- 'format': function() {
- return {
- async: false
- }
- }
- },
'hosts.high_availability.wizard': {
'real': '/clusters/{clusterName}/hosts?fields=Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem&minimal_response=true',
'mock': ''
@@ -1677,12 +1620,7 @@ var urls = {
},
'host_component.installed.on_hosts': {
'real': '/clusters/{clusterName}/host_components?HostRoles/component_name={componentName}&HostRoles/host_name.in({hostNames})&fields=HostRoles/host_name&minimal_response=true',
- 'mock': '',
- 'format': function() {
- return {
- async: false
- }
- }
+ 'mock': ''
},
'hosts.by_component.one': {
'real': '/clusters/{clusterName}/hosts?host_components/HostRoles/component_name.in({componentNames})&fields=host_components,Hosts/cpu_count,Hosts/disk_info,Hosts/total_mem,Hosts/ip,Hosts/os_type,Hosts/os_arch,Hosts/public_host_name&page_size=1&minimal_response=true',
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/utils/db.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/db.js b/ambari-web/app/utils/db.js
index 4193960..b77ee1a 100644
--- a/ambari-web/app/utils/db.js
+++ b/ambari-web/app/utils/db.js
@@ -144,13 +144,6 @@ App.db.setLoginName = function (name) {
localStorage.setObject('ambari', App.db.data);
};
-App.db.setAmbariStacks = function (stacks) {
- console.log('TRACE: Entering db:setAmbariStacks function');
- App.db.data = localStorage.getObject('ambari');
- App.db.data.app.stacks = stacks;
- localStorage.setObject('ambari', App.db.data);
-};
-
/**
* Set user model to db
* @param user
@@ -558,12 +551,6 @@ App.db.getAuthenticated = function () {
return App.db.data.app.authenticated;
};
-App.db.getAmbariStacks = function () {
- console.log('TRACE: Entering db:setAmbariStacks function');
- App.db.data = localStorage.getObject('ambari');
- return App.db.data.app.stacks;
-};
-
App.db.getFilterConditions = function(name) {
console.log('TRACE: Entering db:getFilterConditions function');
App.db.data = localStorage.getObject('ambari');
http://git-wip-us.apache.org/repos/asf/ambari/blob/05630b23/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js b/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js
index b677567..3c4efb0 100644
--- a/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js
+++ b/ambari-web/app/views/main/service/info/metrics/flume/flume_metric_graphs.js
@@ -33,7 +33,6 @@ App.MainServiceInfoFlumeGraphsView = App.MainServiceInfoSummaryMetricGraphsView.
'sender': this,
'success': 'onLoadMetricsSuccess',
'data': {
- async: false,
hostName: hostName,
flumeComponent: metricType
}