ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject ambari git commit: AMBARI-8814 Rolling Upgrade: resume upgrade state after log in/out. (atkach)
Date Fri, 19 Dec 2014 10:47:15 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk bab3dbc84 -> f13beb866


AMBARI-8814 Rolling Upgrade: resume upgrade state after log in/out. (atkach)


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

Branch: refs/heads/trunk
Commit: f13beb866d227117d37271dc56e21d21d99f77b2
Parents: bab3dbc
Author: Andrii Tkach <atkach@hortonworks.com>
Authored: Fri Dec 19 11:59:12 2014 +0200
Committer: Andrii Tkach <atkach@hortonworks.com>
Committed: Fri Dec 19 11:59:12 2014 +0200

----------------------------------------------------------------------
 ambari-web/app/app.js                           |  2 +-
 .../controllers/global/cluster_controller.js    | 20 +++++++++++++----
 .../main/admin/stack_and_upgrade_controller.js  | 23 ++++++++++++--------
 ambari-web/app/router.js                        |  3 +++
 .../main/admin/stack_upgrade/upgrade_task.hbs   |  4 ++--
 ambari-web/app/utils/db.js                      |  1 +
 .../views/main/admin/stack_and_upgrade_view.js  |  4 ++--
 .../admin/stack_and_upgrade_controller_test.js  | 17 +++++++++++++--
 8 files changed, 54 insertions(+), 20 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/f13beb86/ambari-web/app/app.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/app.js b/ambari-web/app/app.js
index c45f48b..c9e19a9 100644
--- a/ambari-web/app/app.js
+++ b/ambari-web/app/app.js
@@ -41,7 +41,7 @@ module.exports = Em.Application.create({
    *  - INIT
    *  - PENDING
    *  - IN_PROGRESS
-   *  - STOPPED
+   *  - HOLDING
    *  - COMPLETED
    * @type {String}
    */

http://git-wip-us.apache.org/repos/asf/ambari/blob/f13beb86/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 bbc088c..9e4f82e 100644
--- a/ambari-web/app/controllers/global/cluster_controller.js
+++ b/ambari-web/app/controllers/global/cluster_controller.js
@@ -268,10 +268,6 @@ App.ClusterController = Em.Controller.extend({
       return;
     }
 
-    if (App.get('supports.stackUpgrade')) {
-      App.router.get('mainAdminStackAndUpgradeController').loadUpgradeData(true);
-    }
-
     var clusterUrl = this.getUrl('/data/clusters/cluster.json', '?fields=Clusters');
     var racksUrl = "/data/racks/racks.json";
 
@@ -302,6 +298,9 @@ App.ClusterController = Em.Controller.extend({
     } else {
       App.clusterStatus.updateFromServer().complete(function () {
         self.updateLoadStatus('clusterStatus');
+        if (App.get('supports.stackUpgrade')) {
+          self.restoreUpgradeState();
+        }
       });
     }
 
@@ -367,6 +366,19 @@ App.ClusterController = Em.Controller.extend({
     });
   },
 
+  /**
+   * restore upgrade status from local storage
+   * and make call to get latest status from server
+   */
+  restoreUpgradeState: function () {
+    var dbUpgradeState = App.db.get('MainAdminStackAndUpgrade', 'upgradeState');
+    if (!Em.isNone(dbUpgradeState)) {
+      App.set('upgradeState', dbUpgradeState);
+    }
+    App.router.get('mainAdminStackAndUpgradeController').initDBProperties();
+    App.router.get('mainAdminStackAndUpgradeController').loadUpgradeData(true);
+  },
+
   loadRootService: function () {
     return App.ajax.send({
       name: 'service.ambari',

http://git-wip-us.apache.org/repos/asf/ambari/blob/f13beb86/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
index 7e6a1cb..6fe806f 100644
--- a/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
+++ b/ambari-web/app/controllers/main/admin/stack_and_upgrade_controller.js
@@ -62,10 +62,14 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    */
   wizardStorageProperties: ['upgradeId', 'upgradeVersion'],
 
+  init: function () {
+    this.initDBProperties();
+  },
+
   /**
    * restore data from localStorage
    */
-  init: function () {
+  initDBProperties: function () {
     this.get('wizardStorageProperties').forEach(function (property) {
       if (this.getDBProperty(property)) {
         this.set(property, this.getDBProperty(property));
@@ -168,6 +172,7 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    */
   loadUpgradeDataSuccessCallback: function (data) {
     App.set('upgradeState', data.Upgrade.request_status);
+    this.setDBProperty('upgradeState', data.Upgrade.request_status);
     if (data.upgrade_groups) {
       this.updateUpgradeData(data);
     }
@@ -275,9 +280,10 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   upgradeSuccessCallback: function (data) {
     this.set('upgradeId', data.resources[0].Upgrade.request_id);
     this.setDBProperty('upgradeId', data.resources[0].Upgrade.request_id);
+    this.setDBProperty('upgradeState', 'PENDING');
+    App.set('upgradeState', 'PENDING');
     App.clusterStatus.setClusterStatus({
-      clusterName: App.get('clusterName'),
-      clusterState: 'DEFAULT',
+      wizardControllerName: this.get('name'),
       localdb: App.db.data
     });
     this.openUpgradeDialog();
@@ -306,17 +312,17 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
    * @param data {object}
    * @param opt {object}
    * @param params {object}
-   * @returns {App.ModalPopup|void}
+   * @returns {App.ModalPopup|undefined}
    */
-  runPreUpgradeCheckSuccess: function(data, opt, params) {
-    if (data.items.someProperty('UpgradeChecks.status',"FAIL")) {
+  runPreUpgradeCheckSuccess: function (data, opt, params) {
+    if (data.items.someProperty('UpgradeChecks.status', "FAIL")) {
       return App.ModalPopup.show({
         header: Em.I18n.t('admin.stackUpgrade.preupgradeCheck.header').format(params.label),
         primary: Em.I18n.t('common.dismiss'),
         secondary: false,
         bodyClass: Em.View.extend({
           templateName: require('templates/main/admin/stack_upgrade/pre_upgrade_check_dialog'),
-          checks: data.items.filterProperty('UpgradeChecks.status',"FAIL")
+          checks: data.items.filterProperty('UpgradeChecks.status', "FAIL")
         })
       })
     } else {
@@ -346,12 +352,11 @@ App.MainAdminStackAndUpgradeController = Em.Controller.extend(App.LocalStorage,
   finish: function () {
     this.set('upgradeId', null);
     this.setDBProperty('upgradeId', undefined);
+    this.setDBProperty('upgradeState', 'INIT');
     App.set('upgradeState', 'INIT');
     this.set('upgradeVersion', null);
     this.setDBProperty('upgradeVersion', undefined);
     App.clusterStatus.setClusterStatus({
-      clusterName: App.get('clusterName'),
-      clusterState: 'DEFAULT',
       localdb: App.db.data
     });
   },

http://git-wip-us.apache.org/repos/asf/ambari/blob/f13beb86/ambari-web/app/router.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/router.js b/ambari-web/app/router.js
index ed9d94b..5bef5b7 100644
--- a/ambari-web/app/router.js
+++ b/ambari-web/app/router.js
@@ -367,6 +367,9 @@ App.Router = Em.Router.extend({
           } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('rollbackHighAvailabilityWizardController.name')) {
             // if wizardControllerName == "highAvailabilityRollbackController", then it means
someone closed the browser or the browser was crashed when we were last in NameNode High Availability
Rollback wizard
             route = 'main.services.rollbackHighAvailability';
+          } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName
=== App.router.get('mainAdminStackAndUpgradeController.name')) {
+            // if wizardControllerName == "mainAdminStackAndUpgradeController", then it means
someone closed the browser or the browser was crashed when we were last in Rolling Upgrade
wizard
+            route = 'main.admin.stackAndUpgrade';
           }
           callback(route);
         });

http://git-wip-us.apache.org/repos/asf/ambari/blob/f13beb86/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs
index 5c9781a..4dff7ed 100644
--- a/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs
+++ b/ambari-web/app/templates/main/admin/stack_upgrade/upgrade_task.hbs
@@ -33,7 +33,7 @@
             <a title="Click to Copy" {{action copyOutLog view.content target="view"}}
class="task-detail-copy">
               <i class="icon-copy"></i> {{t common.copy}}
             </a>
-            <a title="Open in New Window" {{action openErrorLog target="view"}} class="task-detail-open-dialog">
+            <a title="Open in New Window" {{action openOutLog target="view"}} class="task-detail-open-dialog">
               <i class="icon-external-link"></i> {{t common.open}}
             </a>
           </div>
@@ -49,7 +49,7 @@
             <a title="Click to Copy" {{action copyErrLog view.content target="view"}}
class="task-detail-copy">
               <i class="icon-copy"></i> {{t common.copy}}
             </a>
-            <a title="Open in New Window" {{action openOutLog target="view"}} class="task-detail-open-dialog">
+            <a title="Open in New Window" {{action openErrorLog target="view"}} class="task-detail-open-dialog">
               <i class="icon-external-link"></i> {{t common.open}}
             </a>
           </div>

http://git-wip-us.apache.org/repos/asf/ambari/blob/f13beb86/ambari-web/app/utils/db.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/db.js b/ambari-web/app/utils/db.js
index 1cc8fde..075f59f 100644
--- a/ambari-web/app/utils/db.js
+++ b/ambari-web/app/utils/db.js
@@ -44,6 +44,7 @@ var InitialData =  {
   'HighAvailabilityWizard': {},
   'RMHighAvailabilityWizard': {},
   'RollbackHighAvailabilityWizard': {},
+  'MainAdminStackAndUpgrade': {},
   'tmp': {}
 
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/f13beb86/ambari-web/app/views/main/admin/stack_and_upgrade_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/main/admin/stack_and_upgrade_view.js b/ambari-web/app/views/main/admin/stack_and_upgrade_view.js
index 51daa6d..0cb17ea 100644
--- a/ambari-web/app/views/main/admin/stack_and_upgrade_view.js
+++ b/ambari-web/app/views/main/admin/stack_and_upgrade_view.js
@@ -152,9 +152,9 @@ App.MainAdminStackAndUpgradeView = Em.View.extend({
     }.property('controller.targetVersions'),
     btnClass: 'btn-success',
     versionName: function () {
-      if (this.get('versions.length') === 0) return Em.I18n.t('admin.stackUpgrade.state.notAvailable');
+      if (this.get('versions.length') === 0 && App.get('upgradeState') === 'INIT')
return Em.I18n.t('admin.stackUpgrade.state.notAvailable');
       return this.get('controller.upgradeVersion');
-    }.property('controller.upgradeVersion', 'showSelect'),
+    }.property('controller.upgradeVersion', 'versions.length', 'App.upgradeState'),
     showSelect: function () {
       return this.get('versions.length') > 0 && App.get('upgradeState') === 'INIT';
     }.property('versions.length', 'App.upgradeState'),

http://git-wip-us.apache.org/repos/asf/ambari/blob/f13beb86/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
----------------------------------------------------------------------
diff --git a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
index e7e5392..774d3de 100644
--- a/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
+++ b/ambari-web/test/controllers/main/admin/stack_and_upgrade_controller_test.js
@@ -282,7 +282,7 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
   });
 
-  describe("#init()", function() {
+  describe("#initDBProperties()", function() {
     before(function () {
       sinon.stub(controller, 'getDBProperty', function (prop) {
         return prop;
@@ -293,11 +293,24 @@ describe('App.MainAdminStackAndUpgradeController', function() {
     });
     it("set properties", function () {
       controller.set('wizardStorageProperties', ['prop1']);
-      controller.init();
+      controller.initDBProperties();
       expect(controller.get('prop1')).to.equal('prop1');
     });
   });
 
+  describe("#init()", function() {
+    before(function () {
+      sinon.stub(controller, 'initDBProperties', Em.K);
+    });
+    after(function () {
+      controller.initDBProperties.restore();
+    });
+    it("call initDBProperties", function () {
+      controller.init();
+      expect(controller.initDBProperties.calledOnce).to.be.true;
+    });
+  });
+
   describe("#parseVersionsData()", function() {
     it("", function() {
       var data = {


Mime
View raw message