Browse Source

AMBARI-1110. After clicking the deploy button on the Add Hosts wizard, the user is always taken to the Installer Wizard Step 8 upon login. (Arun Kandregula via yusaku)

git-svn-id: https://svn.apache.org/repos/asf/incubator/ambari/trunk@1431782 13f79535-47bb-0310-9956-ffa450edef68
Yusaku Sako 12 years ago
parent
commit
ed8c183a10

+ 4 - 0
CHANGES.txt

@@ -675,6 +675,10 @@ AMBARI-666 branch (unreleased changes)
 
   BUG FIXES
 
+  AMBARI-1110. After clicking the deploy button on the Add Hosts wizard, the
+  user is always taken to the Installer Wizard Step 8 upon login.
+  (Arun Kandregula via yusaku)
+
   AMBARI-1152. Add Hosts wizard - Retry button does not trigger call to
   backend. (yusaku)
 

+ 23 - 5
ambari-web/app/controllers/wizard/step8_controller.js

@@ -748,11 +748,29 @@ App.WizardStep8Controller = Em.Controller.extend({
 
     if (App.testMode || !this.get('content.cluster.requestId')) {
       // For recovery : set the cluster status
-      App.clusterStatus.set('value', {
-        clusterName: this.get('clusterName'),
-        clusterState: 'CLUSTER_DEPLOY_PREP_2',
-        localdb: App.db.data
-      });
+
+      // 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', {
+            clusterName: this.get('clusterName'),
+            clusterState: 'CLUSTER_DEPLOY_PREP_2',
+            wizardControllerName: this.get('content.controllerName'),
+            localdb: App.db.data,
+          });
+          break;
+
+        case 'addHostController' :
+          App.clusterStatus.set('value', {
+            clusterName: this.get('clusterName'),
+            clusterState: 'ADD_HOSTS_DEPLOY_PREP_2',
+            wizardControllerName: this.get('content.controllerName'),
+            localdb: App.db.data
+          });
+          break;
+        default :
+          break;
+      }
 
       this.createCluster();
       this.createSelectedServices();

+ 85 - 73
ambari-web/app/models/cluster_states.js

@@ -15,91 +15,103 @@
  * See the License for the specific language governing permissions and
  * limitations under the License.
  */
-  var App = require('app');
+var App = require('app');
 
-  App.clusterStatus = Ember.Object.create({
-    clusterName: '',
-    validStates: ['CLUSTER_NOT_CREATED_1', 'CLUSTER_DEPLOY_PREP_2', 'CLUSTER_INSTALLING_3', 'CLUSTER_INSTALLED_4', 'CLUSTER_STARTED_5'],
-    clusterState: 'CLUSTER_NOT_CREATED_1',
-    localdb: null,
-    key: function () {
-      return 'CLUSTER_CURRENT_STATUS';
-    }.property(),
-    value: function (key, newValue) {
-      // getter
-      if (arguments.length == 1) {
+App.clusterStatus = Ember.Object.create({
+  clusterName: '',
+  validStates: ['CLUSTER_NOT_CREATED_1', 'CLUSTER_DEPLOY_PREP_2', 'CLUSTER_INSTALLING_3', 'CLUSTER_INSTALLED_4', 'CLUSTER_STARTED_5', 'ADD_HOSTS_DEPLOY_PREP_2', 'ADD_HOSTS_INSTALLING_3', 'ADD_HOSTS_INSTALLED_4', 'ADD_HOSTS_COMPLETED_5'],
+  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.localdb)
-                  this.set('localdb', newValue.localdb);
-              } else {
-                // default status already set
+      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);
               }
-            },
-            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.localdb) {
+                this.set('localdb', newValue.localdb);
               }
+            } else {
+              // default status already set
+            }
+          },
+          error: function (xhr) {
+            if (xhr.status == 404) {
+              // default status already set
+              console.log('Persist API did NOT find the key CLUSTER_CURRENT_STATUS');
             }
           }
-        );
+        }
+      );
 
-        return {
-          clusterName: this.get('clusterName'),
-          clusterState: this.get('clusterState'),
-          localdb: this.get('localdb')
-        };
+      return {
+        clusterName: this.get('clusterName'),
+        clusterState: this.get('clusterState'),
+        wizardControllerName: this.get('wizardControllerName'),
+        localdb: this.get('localdb')
+      };
 
-      } else if (newValue) {
-        //setter
-        if (newValue.clusterState) {
-          this.set('clusterState', newValue.clusterState);
-        }
-        if (newValue.clusterName) {
-          this.set('clusterName', newValue.clusterName);
-        }
-        if (newValue.localdb) {
-          this.set('localdb', newValue.localdb);
-        }
+    } else if (newValue) {
+      //setter
+      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);
+      }
 
-        var url = App.apiPrefix + '/persist/';
-        var keyValuePair = {};
-        var val = {
-          clusterName: this.get('clusterName'),
-          clusterState: this.get('clusterState'),
-          localdb: this.get('localdb')
-        };
-        keyValuePair[this.get('key')] = JSON.stringify(val);
+      var url = App.apiPrefix + '/persist/';
+      var keyValuePair = {};
+      var val = {
+        clusterName: this.get('clusterName'),
+        clusterState: this.get('clusterState'),
+        wizardControllerName: this.get('wizardControllerName'),
+        localdb: this.get('localdb')
+      };
+      keyValuePair[this.get('key')] = JSON.stringify(val);
 
 
-        jQuery.ajax({
-          async: false,
-          context: this,
-          type: "POST",
-          url: url,
-          data: JSON.stringify(keyValuePair),
-          beforeSend: function () {
-            console.log('BeforeSend: persistKeyValues', keyValuePair);
-          }
-        });
+      jQuery.ajax({
+        async: false,
+        context: this,
+        type: "POST",
+        url: url,
+        data: JSON.stringify(keyValuePair),
+        beforeSend: function () {
+          console.log('BeforeSend: persistKeyValues', keyValuePair);
+        }
+      });
 
-        return newValue;
+      return newValue;
 
-      }
+    }
 
-    }.property('clusterName', 'clusterState', 'localdb')
+  }.property('clusterName', 'clusterState', 'localdb')
 
-  });
+});

+ 5 - 0
ambari-web/app/models/service_config.js

@@ -243,6 +243,11 @@ App.ServiceConfigProperty = Ember.Object.extend({
         break;
     }
 
+    // In Add Host Wizard, if we did not select this slave component for any host, then we don't process any further.
+    if (setOfHostNames.length === 0) {
+      return;
+    }
+
     var allMountPoints = [];
     for (var i = 0; i < setOfHostNames.length; i++) {
       hostname = setOfHostNames[i];

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

@@ -252,9 +252,13 @@ App.Router = Em.Router.extend({
       return 'installer';
     }
     var clusterStatusOnServer = App.clusterStatus.get('value');
-    if (clusterStatusOnServer && clusterStatusOnServer.clusterState === 'CLUSTER_STARTED_5') {
+    if (clusterStatusOnServer && (clusterStatusOnServer.clusterState === 'CLUSTER_STARTED_5' || clusterStatusOnServer.clusterState === 'ADD_HOSTS_COMPLETED_5' )) {
       return 'main.index';
+    } else if (clusterStatusOnServer && clusterStatusOnServer.wizardControllerName === App.router.get('addHostController.name')) {
+      // if wizardControllerName == "addHostController", then it means someone closed the browser or the browser was crashed when we were last in Add Hosts wizard
+      return 'main.hostAdd';
     } else {
+      // if wizardControllerName == "installerController", then it means someone closed the browser or the browser was crashed when we were last in Installer wizard
       return 'installer';
     }
   },

+ 59 - 0
ambari-web/app/routes/add_host_routes.js

@@ -46,6 +46,31 @@ module.exports = Em.Route.extend({
           router.transitionTo('hosts.index');
         }
       });
+
+      var currentClusterStatus = App.clusterStatus.get('value');
+
+      if (currentClusterStatus) {
+        switch (currentClusterStatus.clusterState) {
+          case 'ADD_HOSTS_DEPLOY_PREP_2' :
+            addHostController.setCurrentStep('4');
+            App.db.data = currentClusterStatus.localdb;
+            break;
+          case 'ADD_HOSTS_INSTALLING_3' :
+            addHostController.setCurrentStep('5');
+            App.db.data = currentClusterStatus.localdb;
+            break;
+          case 'ADD_HOSTS_INSTALLED_4' :
+            addHostController.setCurrentStep('6');
+            App.db.data = currentClusterStatus.localdb;
+            break;
+          case 'ADD_HOSTS_COMPLETED_5' :
+            router.transitionTo('main.index');
+            break;
+          default:
+            break;
+        }
+      }
+
       router.transitionTo('step' + addHostController.get('currentStep'));
     });
 
@@ -175,6 +200,14 @@ module.exports = Em.Route.extend({
       var wizardStep8Controller = router.get('wizardStep8Controller');
       addHostController.installServices();
       addHostController.setInfoForStep9();
+
+      // We need to do recovery based on whether we are in Add Host or Installer wizard
+      App.clusterStatus.set('value', {
+        clusterName: this.get('clusterName'),
+        clusterState: 'ADD_HOSTS_INSTALLING_3',
+        wizardControllerName: App.router.get('addHostController.name'),
+        localdb: App.db.data
+      });
       router.transitionTo('step5');
     }
   }),
@@ -202,6 +235,13 @@ module.exports = Em.Route.extend({
           var isRetry = true;
           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', {
+            clusterName: this.get('clusterName'),
+            clusterState: 'ADD_HOSTS_INSTALLING_3',
+            wizardControllerName: App.router.get('addHostController.name'),
+            localdb: App.db.data
+          });
         }
         wizardStep9Controller.navigateStep();
       }
@@ -213,6 +253,15 @@ module.exports = Em.Route.extend({
       var addHostController = router.get('addHostController');
       var wizardStep9Controller = router.get('wizardStep9Controller');
       addHostController.saveInstalledHosts(wizardStep9Controller);
+
+      // We need to do recovery based on whether we are in Add Host or Installer wizard
+      App.clusterStatus.set('value', {
+        clusterName: this.get('clusterName'),
+        clusterState: 'ADD_HOSTS_INSTALLED_4',
+        wizardControllerName: App.router.get('addHostController.name'),
+        localdb: App.db.data
+      });
+
       router.transitionTo('step6');
     }
   }),
@@ -235,6 +284,16 @@ module.exports = Em.Route.extend({
         App.router.get('updateController').updateAllWrapper();
         addHostController.finish();
         $(context.currentTarget).parents("#modal").find(".close").trigger('click');
+
+
+        // We need to do recovery based on whether we are in Add Host or Installer wizard
+        App.clusterStatus.set('value', {
+          clusterName: this.get('clusterName'),
+          clusterState: 'ADD_HOSTS_COMPLETED_5',
+          wizardControllerName: App.router.get('addHostController.name'),
+          localdb: App.db.data
+        });
+
         router.transitionTo('main.index');
       } else {
         console.log('cluster installation failure');

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

@@ -274,13 +274,13 @@ module.exports = Em.Route.extend({
       // invoke API call to install selected services
       installerController.installServices();
       installerController.setInfoForStep9();
-      // For recovery : set the cluster status
+      // We need to do recovery based on whether we are in Add Host or Installer wizard
       App.clusterStatus.set('value', {
         clusterName: this.get('clusterName'),
         clusterState: 'CLUSTER_INSTALLING_3',
+        wizardControllerName: App.router.get('installerController.name'),
         localdb: App.db.data
       });
-
       router.transitionTo('step9');
     }
   }),
@@ -306,6 +306,13 @@ module.exports = Em.Route.extend({
           var isRetry = true;
           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', {
+            clusterName: this.get('clusterName'),
+            clusterState: 'CLUSTER_INSTALLING_3',
+            wizardControllerName: App.router.get('installerController.name'),
+            localdb: App.db.data
+          });
         }
         wizardStep9Controller.navigateStep();
       }
@@ -318,13 +325,12 @@ module.exports = Em.Route.extend({
       var wizardStep9Controller = router.get('wizardStep9Controller');
       installerController.saveInstalledHosts(wizardStep9Controller);
 
-      // For recovery : set the cluster status
       App.clusterStatus.set('value', {
         clusterName: this.get('clusterName'),
         clusterState: 'CLUSTER_INSTALLED_4',
+        wizardControllerName: App.router.get('installerController.name'),
         localdb: App.db.data
       });
-
       router.transitionTo('step10');
     }
   }),
@@ -344,10 +350,11 @@ module.exports = Em.Route.extend({
         var controller = router.get('installerController');
         controller.finish();
 
-        // For recovery : set the cluster status
+        // We need to do recovery based on whether we are in Add Host or Installer wizard
         App.clusterStatus.set('value', {
           clusterName: this.get('clusterName'),
           clusterState: 'CLUSTER_STARTED_5',
+          wizardControllerName: App.router.get('installerController.name'),
           localdb: App.db.data
         });