浏览代码

AMBARI-3405. NameNode HA Wizard: allow the user to exit out of the wizard with a warning pointing to manual rollback steps. (alexantonenko)

Alex Antonenko 11 年之前
父节点
当前提交
acfbca340e

+ 2 - 1
ambari-web/app/config.js

@@ -59,7 +59,8 @@ App.supports = {
   ldapGroupMapping: false,
   localRepositories: false,
   highAvailability: true,
-  deleteHost: false
+  deleteHost: false,
+  autoRollbackHA: false
 };
 
 if (App.enableExperimental) {

+ 34 - 1
ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js

@@ -124,6 +124,37 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
     task.set('status', 'PENDING');
   },
 
+  manualRollback: function () {
+    App.ModalPopup.show({
+      header: Em.I18n.t('admin.highAvailability.confirmRollbackHeader'),
+      primary: Em.I18n.t('yes'),
+      showCloseButton: false,
+      onPrimary: function () {
+        var controller = App.router.get('highAvailabilityWizardController');
+        controller.clearTasksData();
+        controller.clearStorageData();
+        controller.setCurrentStep('1');
+        App.router.get('updateController').set('isWorking', true);
+        App.clusterStatus.setClusterStatus({
+          clusterName: App.router.get('content.cluster.name'),
+          clusterState: 'HIGH_AVAILABILITY_DISABLED',
+          wizardControllerName: App.router.get('highAvailabilityRollbackController.name'),
+          localdb: App.db.data
+        });
+        this.hide();
+        App.router.transitionTo('main.admin.index');
+        location.reload();
+      },
+      secondary : Em.I18n.t('no'),
+      onSecondary: function(){
+        this.hide();
+      },
+      bodyClass: Ember.View.extend({
+        template: Ember.Handlebars.compile( Em.I18n.t('admin.highAvailability.confirmManualRollbackBody'))
+      })
+    });
+  },
+
   rollback: function () {
     var task = this.get('tasks').findProperty('status', 'FAILED');
     App.router.get(this.get('content.controllerName')).saveFailedTask(task);
@@ -159,7 +190,9 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
     } else if (this.get('tasks').someProperty('status', 'FAILED')) {
       this.set('status', 'FAILED');
       this.get('tasks').findProperty('status', 'FAILED').set('showRetry', true);
-      this.get('tasks').findProperty('status', 'FAILED').set('showRollback', true);
+      if(App.supports.autoRollbackHA){
+        this.get('tasks').findProperty('status', 'FAILED').set('showRollback', true);
+      }
     }
 
     var statuses = this.get('tasks').mapProperty('status');

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

@@ -683,6 +683,7 @@ Em.I18n.translations = {
   'admin.highAvailability.enabled':'NameNode HA is enabled',
   'admin.highAvailability.confirmRollbackHeader':'Confirm Rollback',
   'admin.highAvailability.confirmRollbackBody':'This will rollback all operations that were done in HA wizard',
+  'admin.highAvailability.confirmManualRollbackBody':'You are in the process of enabling NameNode HA. If you exit now, you must follow manual instructions to revert <i>back</i> to the non-HA setup: <a target=\"_blank\" href=\"/\">link to doc</a>. Are you sure you want to exit the wizard?',
   'admin.highAvailability.error.hostsNum':'You must have at least 3 hosts in your cluster to enable NameNode HA.',
   'admin.highAvailability.error.namenodeStarted':'NameNode must be running before you enable NameNode HA.',
   'admin.highAvailability.error.zooKeeperNum':'You must have at least 3 ZooKeeper Servers in your cluster to enable NameNode HA.',

+ 15 - 7
ambari-web/app/routes/high_availability_routes.js

@@ -40,7 +40,11 @@ module.exports = Em.Route.extend({
             case "5" :
             case "7" :
             case "9" :
-              this.set('showCloseButton', false);
+              if(App.supports.autoRollbackHA){
+                this.set('showCloseButton', false);
+              }else{
+                this.set('showCloseButton', true);
+              }
               break;
             default :
               this.set('showCloseButton', true);
@@ -50,23 +54,27 @@ module.exports = Em.Route.extend({
         onClose: function () {
           var currStep = App.router.get('highAvailabilityWizardController.currentStep');
           var highAvailabilityProgressPageController = App.router.get('highAvailabilityProgressPageController');
-          if (currStep == "6"){
+          if (currStep == "6" && App.supports.autoRollbackHA){
             highAvailabilityProgressPageController.tasks.push({
               command: "startZooKeeperServers",
               status: "FAILED"
             })
             highAvailabilityProgressPageController.rollback();
-          }else if(currStep == "8"){
+          }else if(currStep == "8" && App.supports.autoRollbackHA){
             highAvailabilityProgressPageController.tasks.push({
               command: "startSecondNameNode",
               status: "FAILED"
             })
             highAvailabilityProgressPageController.rollback();
           }else{
-            this.hide();
-            App.router.get('highAvailabilityWizardController').setCurrentStep('1');
-            App.router.get('updateController').set('isWorking', true);
-            App.router.transitionTo('main.admin.adminHighAvailability');
+            if(parseInt(currStep) > 4 && !App.supports.autoRollbackHA){
+              highAvailabilityProgressPageController.manualRollback();
+            }else {
+              this.hide();
+              App.router.get('highAvailabilityWizardController').setCurrentStep('1');
+              App.router.get('updateController').set('isWorking', true);
+              App.router.transitionTo('main.admin.adminHighAvailability');
+            }
           }
         },
         didInsertElement: function () {