浏览代码

AMBARI-1212. After successful install with Ambari, the user is taken to the welcome page of the Install Wizard upon browser relaunch if the HTTP session is expired. (yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1435458 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 年之前
父节点
当前提交
f4fc600bd3

+ 4 - 0
CHANGES.txt

@@ -78,6 +78,10 @@ Trunk (unreleased changes):
 
  BUG FIXES
 
+ AMBARI-1212. After successful install with Ambari, the user is taken to the
+ welcome page of the Install Wizard upon browser relaunch if the HTTP session
+ is expired. (yusaku)
+
  AMBARI-1227. Host-level task popup is not showing the display name for
  components. (yusaku)
 

+ 2 - 2
ambari-web/app/controllers/wizard/step8_controller.js

@@ -760,7 +760,7 @@ App.WizardStep8Controller = Em.Controller.extend({
       // We need to do recovery based on whether we are in Add Host or Installer wizard
       switch (this.get('content.controllerName')) {
         case 'installerController' :
-          App.clusterStatus.set('value', {
+          App.clusterStatus.setClusterStatus({
             clusterName: this.get('clusterName'),
             clusterState: 'CLUSTER_DEPLOY_PREP_2',
             wizardControllerName: this.get('content.controllerName'),
@@ -769,7 +769,7 @@ App.WizardStep8Controller = Em.Controller.extend({
           break;
 
         case 'addHostController' :
-          App.clusterStatus.set('value', {
+          App.clusterStatus.setClusterStatus({
             clusterName: this.get('clusterName'),
             clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
             wizardControllerName: this.get('content.controllerName'),

+ 1 - 1
ambari-web/app/controllers/wizard/step9_controller.js

@@ -283,7 +283,7 @@ App.WizardStep9Controller = Em.Controller.extend({
         App.router.get(self.get('content.controllerName')).saveClusterStatus(clusterStatus);
 
         // We need to do recovery if there is a browser crash
-        App.clusterStatus.set('value', {
+        App.clusterStatus.setClusterStatus({
           clusterState: 'SERVICE_STARTING_3',
           localdb: App.db.data
         });

+ 56 - 50
ambari-web/app/models/cluster_states.js

@@ -23,55 +23,53 @@ App.clusterStatus = Ember.Object.create({
   clusterState: 'CLUSTER_NOT_CREATED_1',
   wizardControllerName: null,
   localdb: null,
-  key: function () {
-    return 'CLUSTER_CURRENT_STATUS';
-  }.property(),
-  value: function (key, newValue) {
-    // getter
-    if (arguments.length == 1) {
-
-      var url = App.apiPrefix + '/persist/' + this.get('key');
-      jQuery.ajax(
-        {
-          url: url,
-          context: this,
-          async: false,
-          success: function (response) {
-            if (response) {
-              var newValue = jQuery.parseJSON(response);
-              if (newValue.clusterState) {
-                this.set('clusterState', newValue.clusterState);
-              }
-              if (newValue.clusterName) {
-                this.set('clusterName', newValue.clusterName);
-              }
-              if (newValue.wizardControllerName) {
-                this.set('wizardControllerName', newValue.wizardControllerName);
-              }
-              if (newValue.localdb) {
-                this.set('localdb', newValue.localdb);
-              }
-            } else {
-              // default status already set
+  key: 'CLUSTER_CURRENT_STATUS',
+  /**
+   * get cluster data from server and update cluster status
+   */
+  updateFromServer: function(){
+    var url = App.apiPrefix + '/persist/' + this.get('key');
+    jQuery.ajax(
+      {
+        url: url,
+        context: this,
+        async: false,
+        success: function (response) {
+          if (response) {
+            var newValue = jQuery.parseJSON(response);
+            if (newValue.clusterState) {
+              this.set('clusterState', newValue.clusterState);
             }
-          },
-          error: function (xhr) {
-            if (xhr.status == 404) {
-              // default status already set
-              console.log('Persist API did NOT find the key CLUSTER_CURRENT_STATUS');
+            if (newValue.clusterName) {
+              this.set('clusterName', newValue.clusterName);
             }
+            if (newValue.wizardControllerName) {
+              this.set('wizardControllerName', newValue.wizardControllerName);
+            }
+            if (newValue.localdb) {
+              this.set('localdb', newValue.localdb);
+            }
+          } else {
+            // default status already set
           }
-        }
-      );
-
-      return {
-        clusterName: this.get('clusterName'),
-        clusterState: this.get('clusterState'),
-        wizardControllerName: this.get('wizardControllerName'),
-        localdb: this.get('localdb')
-      };
-
-    } else if (newValue) {
+        },
+        error: function (xhr) {
+          if (xhr.status == 404) {
+            // default status already set
+            console.log('Persist API did NOT find the key CLUSTER_CURRENT_STATUS');
+          }
+        },
+        statusCode: require('data/statusCodes')
+      }
+    );
+  },
+  /**
+   * update cluster status and post it on server
+   * @param newValue
+   * @return {*}
+   */
+  setClusterStatus: function(newValue){
+    if (newValue) {
       //setter
       if (newValue.clusterState) {
         this.set('clusterState', newValue.clusterState);
@@ -107,11 +105,19 @@ App.clusterStatus = Ember.Object.create({
           console.log('BeforeSend: persistKeyValues', keyValuePair);
         }
       });
-
       return newValue;
-
     }
-
-  }.property('clusterName', 'clusterState', 'localdb')
+  },
+  /**
+   * general info about cluster
+   */
+  value: function () {
+      return {
+        clusterName: this.get('clusterName'),
+        clusterState: this.get('clusterState'),
+        wizardControllerName: this.get('wizardControllerName'),
+        localdb: this.get('localdb')
+      };
+  }.property('clusterName', 'clusterState', 'localdb', 'wizardControllerName')
 
 });

+ 1 - 0
ambari-web/app/router.js

@@ -251,6 +251,7 @@ App.Router = Em.Router.extend({
     if (App.alwaysGoToInstaller) {
       return 'installer';
     }
+    App.clusterStatus.updateFromServer();
     var clusterStatusOnServer = App.clusterStatus.get('value');
     if (clusterStatusOnServer && (clusterStatusOnServer.clusterState === 'CLUSTER_STARTED_5' || clusterStatusOnServer.clusterState === 'ADD_HOSTS_COMPLETED_5' )) {
       return 'main.index';

+ 5 - 5
ambari-web/app/routes/add_host_routes.js

@@ -49,7 +49,7 @@ module.exports = Em.Route.extend({
           this.fitHeight();
         }
       });
-
+      App.clusterStatus.updateFromServer();
       var currentClusterStatus = App.clusterStatus.get('value');
 
       if (currentClusterStatus) {
@@ -206,7 +206,7 @@ module.exports = Em.Route.extend({
       addHostController.setInfoForStep9();
 
       // We need to do recovery based on whether we are in Add Host or Installer wizard
-      App.clusterStatus.set('value', {
+      App.clusterStatus.setClusterStatus({
         clusterName: this.get('clusterName'),
         clusterState: 'ADD_HOSTS_INSTALLING_3',
         wizardControllerName: App.router.get('addHostController.name'),
@@ -240,7 +240,7 @@ module.exports = Em.Route.extend({
           addHostController.installServices(isRetry);
           addHostController.setInfoForStep9();
           // We need to do recovery based on whether we are in Add Host or Installer wizard
-          App.clusterStatus.set('value', {
+          App.clusterStatus.setClusterStatus({
             clusterName: this.get('clusterName'),
             clusterState: 'ADD_HOSTS_INSTALLING_3',
             wizardControllerName: App.router.get('addHostController.name'),
@@ -259,7 +259,7 @@ module.exports = Em.Route.extend({
       addHostController.saveInstalledHosts(wizardStep9Controller);
 
       // We need to do recovery based on whether we are in Add Host or Installer wizard
-      App.clusterStatus.set('value', {
+      App.clusterStatus.setClusterStatus({
         clusterName: this.get('clusterName'),
         clusterState: 'ADD_HOSTS_INSTALLED_4',
         wizardControllerName: App.router.get('addHostController.name'),
@@ -291,7 +291,7 @@ module.exports = Em.Route.extend({
 
 
         // We need to do recovery based on whether we are in Add Host or Installer wizard
-        App.clusterStatus.set('value', {
+        App.clusterStatus.setClusterStatus({
           clusterName: this.get('clusterName'),
           clusterState: 'ADD_HOSTS_COMPLETED_5',
           wizardControllerName: App.router.get('addHostController.name'),

+ 5 - 4
ambari-web/app/routes/installer.js

@@ -38,6 +38,7 @@ module.exports = Em.Route.extend({
         Ember.run.next(function () {
           var installerController = router.get('installerController');
 
+            App.clusterStatus.updateFromServer();
             var currentClusterStatus = App.clusterStatus.get('value');
 
             if (currentClusterStatus) {
@@ -287,7 +288,7 @@ module.exports = Em.Route.extend({
       installerController.installServices();
       installerController.setInfoForStep9();
       // We need to do recovery based on whether we are in Add Host or Installer wizard
-      App.clusterStatus.set('value', {
+      App.clusterStatus.setClusterStatus({
         clusterName: this.get('clusterName'),
         clusterState: 'CLUSTER_INSTALLING_3',
         wizardControllerName: App.router.get('installerController.name'),
@@ -319,7 +320,7 @@ module.exports = Em.Route.extend({
           installerController.installServices(isRetry);
           installerController.setInfoForStep9();
           // We need to do recovery based on whether we are in Add Host or Installer wizard
-          App.clusterStatus.set('value', {
+          App.clusterStatus.setClusterStatus({
             clusterName: this.get('clusterName'),
             clusterState: 'CLUSTER_INSTALLING_3',
             wizardControllerName: App.router.get('installerController.name'),
@@ -337,7 +338,7 @@ module.exports = Em.Route.extend({
       var wizardStep9Controller = router.get('wizardStep9Controller');
       installerController.saveInstalledHosts(wizardStep9Controller);
 
-      App.clusterStatus.set('value', {
+      App.clusterStatus.setClusterStatus({
         clusterName: this.get('clusterName'),
         clusterState: 'CLUSTER_INSTALLED_4',
         wizardControllerName: App.router.get('installerController.name'),
@@ -366,7 +367,7 @@ module.exports = Em.Route.extend({
         controller.finish();
 
         // We need to do recovery based on whether we are in Add Host or Installer wizard
-        App.clusterStatus.set('value', {
+        App.clusterStatus.setClusterStatus({
           clusterName: this.get('clusterName'),
           clusterState: 'CLUSTER_STARTED_5',
           wizardControllerName: App.router.get('installerController.name'),

+ 1 - 0
ambari-web/app/routes/main.js

@@ -149,6 +149,7 @@ module.exports = Em.Route.extend({
 
     addHost:function (router) {
       if(App.clusterStatus){
+        App.clusterStatus.updateFromServer();
         var currentClusterStatus = App.clusterStatus.get('value');
         if(currentClusterStatus && currentClusterStatus.clusterState=="ADD_HOSTS_COMPLETED_5"){
           // The last time add hosts ran, it left the status