Author: yusaku
Date: Fri Feb 22 08:09:15 2013
New Revision: 1448925
URL: http://svn.apache.org/r1448925
Log:
AMBARI-1467. UI should block on cluster metric api call before making
subsequent one. (yusaku)
Modified:
incubator/ambari/trunk/CHANGES.txt
incubator/ambari/trunk/ambari-web/app/controllers/global/update_controller.js
incubator/ambari/trunk/ambari-web/app/routes/add_host_routes.js
incubator/ambari/trunk/ambari-web/app/utils/http_client.js
Modified: incubator/ambari/trunk/CHANGES.txt
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/CHANGES.txt?rev=1448925&r1=1448924&r2=1448925&view=diff
==============================================================================
--- incubator/ambari/trunk/CHANGES.txt (original)
+++ incubator/ambari/trunk/CHANGES.txt Fri Feb 22 08:09:15 2013
@@ -348,6 +348,9 @@ Trunk (unreleased changes):
BUG FIXES
+ AMBARI-1467. UI should block on cluster metric api call before making
+ subsequent one. (yusaku)
+
AMBARI-1462. PB (petabytes) is shown as "undefined". (yusaku)
AMBARI-1455. Setting App.testMode=true, alwaysGoToInstaller=true does not
Modified:
incubator/ambari/trunk/ambari-web/app/controllers/global/update_controller.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/global/update_controller.js?rev=1448925&r1=1448924&r2=1448925&view=diff
==============================================================================
---
incubator/ambari/trunk/ambari-web/app/controllers/global/update_controller.js
(original)
+++
incubator/ambari/trunk/ambari-web/app/controllers/global/update_controller.js
Fri Feb 22 08:09:15 2013
@@ -32,34 +32,65 @@ App.UpdateController = Em.Controller.ext
return (App.testMode) ? testUrl : App.apiPrefix + '/clusters/' +
this.get('clusterName') + url;
},
+ /**
+ * Wrapper for all updates
+ */
updateAll:function(){
- var timeIntervalId = this.get('timeIntervalId');
- var self = this;
- if(this.get('isWorking')){
- if(timeIntervalId) return;
- this.set('timeIntervalId', setInterval(function(){
- self.updateAllWrapper();
- }, App.contentUpdateInterval));
- } else {
- clearInterval(timeIntervalId);
- this.set('timeIntervalId', null);
+ if(this.get('isWorking')) {
+ this.update('updateHost');
+ this.update('updateServiceMetric');
+ this.update('graphsUpdate');
}
}.observes('isWorking'),
- updateAllWrapper: function() {
- this.updateHost();
- this.updateServiceMetric();
- this.graphsUpdate();
+ /**
+ * States for each update method (each field - method name)
+ */
+ states: {
+ 'updateHost': null,
+ 'updateServiceMetric': null,
+ 'graphsUpdate': null
+ },
+
+ /**
+ * Callback for each update method
+ * @param {String} name - state name
+ * @return {Function}
+ */
+ updateCallback: function(name) {
+ var self = this;
+ return function() {
+ self.update(name);
+ }
+ },
+
+ /**
+ * Common method that executes provided by name update method (name from
states object)
+ * @param {String} name - key in the states object
+ * @return {Boolean}
+ */
+ update: function(name) {
+ if(!this.get('isWorking')) {
+ return false;
+ }
+ clearTimeout(this.states[name]);
+ var self = this;
+ this.states[name] = setTimeout(function() {
+ self[name](self.updateCallback(name));
+ }, App.contentUpdateInterval);
},
- updateHost:function(){
+ updateHost:function(callback) {
+ var self = this;
var hostsUrl = this.getUrl('/data/hosts/hosts.json',
'/hosts?fields=Hosts/host_name,Hosts/public_host_name,Hosts/cpu_count,Hosts/total_mem,Hosts/host_status,Hosts/last_heartbeat_time,Hosts/os_arch,Hosts/os_type,Hosts/ip,host_components,metrics/disk,metrics/cpu,metrics/load,metrics/memory');
App.HttpClient.get(hostsUrl, App.hostsMapper, {
- complete:function (jqXHR, textStatus) {}
+ complete:function (jqXHR, textStatus) {
+ callback();
+ }
});
},
graphs: [],
- graphsUpdate: function () {
+ graphsUpdate: function (callback) {
var existedGraphs = [];
this.get('graphs').forEach(function (_graph) {
var view = Em.View.views[_graph.id];
@@ -73,12 +104,14 @@ App.UpdateController = Em.Controller.ext
}
}
});
- this.set('graphs', existedGraphs);
+ callback();
+ this.set('graphs', existedGraphs);
},
-
+
/**
* Updates the services information.
- *
+ *
+ * @param callback
* @param isInitialLoad If true, only basic information is loaded.
*/
updateServiceMetric: function (callback, isInitialLoad) {
@@ -90,9 +123,11 @@ App.UpdateController = Em.Controller.ext
var callback = callback || function (jqXHR, textStatus) {
self.set('isUpdated', true);
};
- App.HttpClient.get(servicesUrl, App.servicesMapper, {
- complete: callback
- });
+ App.HttpClient.get(servicesUrl, App.servicesMapper, {
+ complete: function() {
+ callback();
+ }
+ });
}
Modified: incubator/ambari/trunk/ambari-web/app/routes/add_host_routes.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/routes/add_host_routes.js?rev=1448925&r1=1448924&r2=1448925&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/routes/add_host_routes.js (original)
+++ incubator/ambari/trunk/ambari-web/app/routes/add_host_routes.js Fri Feb 22
08:09:15 2013
@@ -291,7 +291,7 @@ module.exports = Em.Route.extend({
complete: function (router, context) {
if (true) { // this function will be moved to installerController
where it will validate
var addHostController = router.get('addHostController');
- App.router.get('updateController').updateAllWrapper();
+ App.router.get('updateController').updateAll();
addHostController.finish();
$(context.currentTarget).parents("#modal").find(".close").trigger('click');
Modified: incubator/ambari/trunk/ambari-web/app/utils/http_client.js
URL:
http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/http_client.js?rev=1448925&r1=1448924&r2=1448925&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/http_client.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/http_client.js Fri Feb 22
08:09:15 2013
@@ -74,7 +74,7 @@ App.HttpClient = Em.Object.create({
* @param {App.ServerDataMapper} mapper - json processor
* @param {Object} data - ajax data property
* @param {function} errorHandler
- * @param {number} interval - frequecy request
+ * @param {number} interval - frequency request
*/
get: function (url, mapper, data, errorHandler, interval) {
var eHandler = data.complete