ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ababiic...@apache.org
Subject ambari git commit: AMBARI-9818 Rolling Upgrade wizard: redundant update calls. (ababiichuk)
Date Thu, 26 Feb 2015 20:22:40 GMT
Repository: ambari
Updated Branches:
  refs/heads/branch-2.0.0 e653e3a3c -> 562719f5e


AMBARI-9818 Rolling Upgrade wizard: redundant update calls. (ababiichuk)


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/562719f5
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/562719f5
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/562719f5

Branch: refs/heads/branch-2.0.0
Commit: 562719f5ebd3e20faeb98a9498cbf969e5bc842d
Parents: e653e3a
Author: aBabiichuk <ababiichuk@cybervisiontech.com>
Authored: Thu Feb 26 18:01:22 2015 +0200
Committer: aBabiichuk <ababiichuk@cybervisiontech.com>
Committed: Thu Feb 26 22:22:34 2015 +0200

----------------------------------------------------------------------
 .../main/alerts/alert_instances_controller.js   |  5 +--
 .../admin/stack_upgrade/upgrade_task_view.js    | 37 ++++++++++++--------
 .../admin/stack_upgrade/upgrade_wizard_view.js  |  7 ++--
 .../stack_upgrade/upgrade_task_view_test.js     | 13 +++++--
 .../stack_upgrade/upgrade_wizard_view_test.js   |  8 ++++-
 5 files changed, 46 insertions(+), 24 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/562719f5/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/alerts/alert_instances_controller.js b/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
index 024887a..9df59e2 100644
--- a/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
+++ b/ambari-web/app/controllers/main/alerts/alert_instances_controller.js
@@ -142,8 +142,9 @@ App.MainAlertInstancesController = Em.Controller.extend({
     var self = this;
     if (this.get('isUpdating')) {
       this.set('updateTimer', setTimeout(function () {
-        self.fetchAlertInstances();
-        self.scheduleUpdate();
+        self.fetchAlertInstances().complete(function() {
+          self.scheduleUpdate();
+        });
       }, App.get('alertInstancesUpdateInterval')));
     }
     else {

http://git-wip-us.apache.org/repos/asf/ambari/blob/562719f5/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
index ee67f79..412004c 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_task_view.js
@@ -106,10 +106,11 @@ App.upgradeTaskView = Em.View.extend({
     var self = this;
 
     if (this.get('content.isExpanded') || this.get('outsideView')) {
-      this.getTaskDetails();
-      this.set('timer', setTimeout(function () {
-        self.doPolling();
-      }, App.bgOperationsUpdateInterval));
+      this.getTaskDetails().done(function() {
+        self.set('timer', setTimeout(function () {
+          self.doPolling();
+        }, App.bgOperationsUpdateInterval));
+      });
     } else {
       clearTimeout(this.get('timer'));
     }
@@ -117,19 +118,25 @@ App.upgradeTaskView = Em.View.extend({
 
   /**
    * request task details from server
-   * @return {$.ajax|null}
+   * @return {$.Deferred}
    */
   getTaskDetails: function () {
-    if (Em.isNone(this.get('content'))) return null;
-    return App.ajax.send({
-      name: 'admin.upgrade.task',
-      sender: this,
-      data: {
-        upgradeId: this.get('content.request_id'),
-        taskId: this.get('content.id')
-      },
-      success: 'getTaskDetailsSuccessCallback'
-    });
+    var deferred = $.Deferred();
+
+    if (Em.isNone(this.get('content'))) {
+      deferred.resolve();
+    } else {
+      App.ajax.send({
+        name: 'admin.upgrade.task',
+        sender: this,
+        data: {
+          upgradeId: this.get('content.request_id'),
+          taskId: this.get('content.id')
+        },
+        success: 'getTaskDetailsSuccessCallback'
+      }).then(deferred.resolve);
+    }
+    return deferred.promise();
   },
 
   /**

http://git-wip-us.apache.org/repos/asf/ambari/blob/562719f5/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
index 64187fa..5506f4c 100644
--- a/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
+++ b/ambari-web/app/views/main/admin/stack_upgrade/upgrade_wizard_view.js
@@ -217,8 +217,8 @@ App.upgradeWizardView = Em.View.extend({
     if (App.get('clusterName')) {
       this.get('controller').loadUpgradeData().done(function () {
         self.set('isLoaded', true);
+        self.doPolling();
       });
-      this.doPolling();
     }
   }.observes('App.clusterName'),
 
@@ -243,8 +243,9 @@ App.upgradeWizardView = Em.View.extend({
   doPolling: function () {
     var self = this;
     this.set('updateTimer', setTimeout(function () {
-      self.get('controller').loadUpgradeData();
-      self.doPolling();
+      self.get('controller').loadUpgradeData().done(function() {
+        self.doPolling();
+      });
     }, App.bgOperationsUpdateInterval));
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/562719f5/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
index 30035bf..92fd3d6 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_task_view_test.js
@@ -66,7 +66,13 @@ describe('App.upgradeTaskView', function () {
 
   describe("#doPolling()", function () {
     beforeEach(function () {
-      sinon.stub(view, 'getTaskDetails', Em.K);
+      sinon.stub(view, 'getTaskDetails', function() {
+        return {
+          done: function (callback) {
+            callback();
+          }
+        }
+      });
       sinon.spy(view, 'doPolling');
       this.clock = sinon.useFakeTimers();
     });
@@ -120,8 +126,9 @@ describe('App.upgradeTaskView', function () {
 
   describe("#getTaskDetails()", function () {
     beforeEach(function () {
-      sinon.stub(App.ajax, 'send', Em.K);
-
+      sinon.stub(App.ajax, 'send').returns({
+        then: Em.K
+      });
     });
     afterEach(function () {
       App.ajax.send.restore();

http://git-wip-us.apache.org/repos/asf/ambari/blob/562719f5/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
index 06de5ca..46ce13d 100644
--- a/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
+++ b/ambari-web/test/views/main/admin/stack_upgrade/upgrade_wizard_view_test.js
@@ -139,7 +139,13 @@ describe('App.upgradeWizardView', function () {
 
   describe("#doPolling()", function () {
     beforeEach(function () {
-      sinon.stub(view.get('controller'), 'loadUpgradeData', Em.K);
+      sinon.stub(view.get('controller'), 'loadUpgradeData', function () {
+        return {
+          done: function (callback) {
+            callback();
+          }
+        }
+      });
       sinon.spy(view, 'doPolling');
       this.clock = sinon.useFakeTimers();
     });


Mime
View raw message