Browse Source

AMBARI-5024. NameNode HA Wizard can get stuck on the Finalize page. (Buzhor Denys via onechiporenko)

Oleg Nechiporenko 11 years ago
parent
commit
bf741836dc

+ 2 - 2
ambari-web/app/controllers/main/admin/highAvailability/wizard_controller.js

@@ -313,8 +313,8 @@ App.HighAvailabilityWizardController = App.WizardController.extend({
    * Clear all temporary data
    * Clear all temporary data
    */
    */
   finish: function () {
   finish: function () {
-    this.setCurrentStep('1');
-    this.clearAllSteps();
+    App.db.data.HighAvailabilityWizard = {};
+    App.db.data.Installer = {};
     App.router.get('updateController').updateAll();
     App.router.get('updateController').updateAll();
   }
   }
 });
 });

+ 3 - 1
ambari-web/app/models/cluster_states.js

@@ -86,7 +86,9 @@ App.clusterStatus = Ember.Object.create({
             }
             }
             if (newValue.localdb) {
             if (newValue.localdb) {
               this.set('localdb', newValue.localdb);
               this.set('localdb', newValue.localdb);
-              if (overrideLocaldb) {
+              // restore HAWizard data if process was started
+              var isHAWizardStarted = App.get('isAdmin') && !App.isEmptyObject(newValue.localdb.HighAvailabilityWizard);
+              if (overrideLocaldb || isHAWizardStarted) {
                 App.db.data = newValue.localdb;
                 App.db.data = newValue.localdb;
                 App.db.setLocalStorage();
                 App.db.setLocalStorage();
                 App.db.setUser(user);
                 App.db.setUser(user);

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

@@ -311,7 +311,6 @@ module.exports = App.WizardRoute.extend({
       var controller = router.get('highAvailabilityWizardController');
       var controller = router.get('highAvailabilityWizardController');
       controller.clearTasksData();
       controller.clearTasksData();
       controller.finish();
       controller.finish();
-      controller.clearStorageData();
       controller.get('popup').hide();
       controller.get('popup').hide();
       App.clusterStatus.setClusterStatus({
       App.clusterStatus.setClusterStatus({
         clusterName: controller.get('content.cluster.name'),
         clusterName: controller.get('content.cluster.name'),

+ 13 - 0
ambari-web/app/utils/helper.js

@@ -152,6 +152,19 @@ App.parseJSON = function (value) {
   }
   }
   return value;
   return value;
 };
 };
+/**
+ * Check for empty <code>Object</code>, built in Em.isEmpty()
+ * doesn't support <code>Object</code> type
+ *
+ * @params obj {Object}
+ *
+ * @return {Boolean}
+ */
+App.isEmptyObject = function(obj) {
+  var empty = true;
+  for (var prop in obj) { if (obj.hasOwnProperty(prop)) {empty = false; break;} }
+  return empty;
+}
 
 
 App.format = {
 App.format = {
 
 

+ 1 - 1
ambari-web/test/app_test.js

@@ -63,7 +63,7 @@ describe('#App', function() {
     var reviewConfigs = require('data/review_configs');
     var reviewConfigs = require('data/review_configs');
     var disableResult;
     var disableResult;
 
 
-    App.set('currentStackVersion', 'HDP-2.1.1');
+    App.set('currentStackVersion', 'HDP-2.1');
     App.set('handleStackDependencyTest', true);
     App.set('handleStackDependencyTest', true);
 
 
     describe('#disableComponent()', function() {
     describe('#disableComponent()', function() {

+ 1 - 1
ambari-web/test/controllers/main/admin/security/add/step3_test.js

@@ -31,7 +31,7 @@ describe('App.MainAdminSecurityAddStep3Controller', function () {
   describe('#getSecurityUsers', function() {
   describe('#getSecurityUsers', function() {
     it('no hosts, just check users (testMode = true)', function() {
     it('no hosts, just check users (testMode = true)', function() {
       App.testMode = true;
       App.testMode = true;
-      expect(mainAdminSecurityAddStep3Controller.getSecurityUsers().length).to.equal(10);
+      expect(mainAdminSecurityAddStep3Controller.getSecurityUsers().length).to.equal(11);
     });
     });
   });
   });
 
 

+ 44 - 32
ambari-web/test/controllers/main/admin/security/add/step4_test.js

@@ -30,9 +30,9 @@ describe('App.MainAdminSecurityAddStep4Controller', function () {
    */
    */
   var controller = App.MainAdminSecurityAddStep4Controller.create();
   var controller = App.MainAdminSecurityAddStep4Controller.create();
 
 
-  describe('#moveToNextStage()', function () {
+  describe('#moveToNextCommand()', function () {
     controller.reopen({
     controller.reopen({
-      saveStages: function(){},
+      saveCommands: function(){},
       enableSubmit: function(){},
       enableSubmit: function(){},
       loadClusterConfigs: function(){}
       loadClusterConfigs: function(){}
     });
     });
@@ -40,29 +40,29 @@ describe('App.MainAdminSecurityAddStep4Controller', function () {
       setClusterStatus: function(){}
       setClusterStatus: function(){}
     });
     });
 
 
-    controller.set('stages', [
-      App.Poll.create({stage: 'stage2', isStarted: false, isPolling: true, isCompleted: false, start: function(){}}),
-      App.Poll.create({stage: 'stage3', isStarted: false, isPolling: false, isCompleted: false, name: 'APPLY_CONFIGURATIONS', start: function(){}}),
-      App.Poll.create({stage: 'stage4', isStarted: false, isPolling: true, isCompleted: false, start: function(){}})
+    controller.set('commands', [
+      App.Poll.create({name: 'STOP_SERVICES', isStarted: false, isPolling: true, isCompleted: false, start: function(){}}),
+      App.Poll.create({name: 'APPLY_CONFIGURATIONS', isStarted: false, isPolling: false, isCompleted: false, start: function(){}}),
+      App.Poll.create({name: 'START_SERVICES', isStarted: false, isPolling: true, isCompleted: false, start: function(){}})
     ]);
     ]);
 
 
-    it('stage2 is started', function(){
-      controller.moveToNextStage(controller.get('stages').findProperty('stage', 'stage2'));
-      expect(controller.get('stages').findProperty('stage', 'stage2').get('isStarted')).to.equal(true);
+    it('STOP_SERVICES is started', function(){
+      controller.moveToNextCommand(controller.get('commands').findProperty('name', 'STOP_SERVICES'));
+      expect(controller.get('commands').findProperty('name', 'STOP_SERVICES').get('isStarted')).to.equal(true);
     });
     });
 
 
-    it('stage3 is started', function(){
-      controller.moveToNextStage(controller.get('stages').findProperty('stage', 'stage3'));
-      expect(controller.get('stages').findProperty('stage', 'stage3').get('isStarted')).to.equal(true);
+    it('APPLY_CONFIGURATIONS is started', function(){
+      controller.moveToNextCommand(controller.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS'));
+      expect(controller.get('commands').findProperty('name', 'APPLY_CONFIGURATIONS').get('isStarted')).to.equal(true);
     });
     });
 
 
-    it('stage4 is started', function(){
-      controller.moveToNextStage(controller.get('stages').findProperty('stage', 'stage4'));
-      expect(controller.get('stages').findProperty('stage', 'stage4').get('isStarted')).to.equal(true);
+    it('START_SERVICES is started', function(){
+      controller.moveToNextCommand(controller.get('commands').findProperty('name', 'START_SERVICES'));
+      expect(controller.get('commands').findProperty('name', 'START_SERVICES').get('isStarted')).to.equal(true);
     });
     });
   });
   });
 
 
-  describe('#loadStages()', function() {
+  describe('#loadCommands()', function() {
     describe('YARN installed with ATS', function() {
     describe('YARN installed with ATS', function() {
       beforeEach(function(){
       beforeEach(function(){
         controller.reopen({
         controller.reopen({
@@ -74,18 +74,29 @@ describe('App.MainAdminSecurityAddStep4Controller', function () {
             ];
             ];
           }.property()
           }.property()
         });
         });
-        App.set('stackDependedComponents', []);
-        controller.set('stages', []);
+        controller.set('commands', []);
         controller.set('totalSteps', 3);
         controller.set('totalSteps', 3);
-        controller.loadStages();
+        var service = {
+          id: 'YARN',
+          service_name: 'YARN',
+          host_components: ['APP_TIMLINE_SERVER_c6401.ambari.apache.org']
+        };
+        var hostComponent = {
+          component_name: 'APP_TIMELINE_SERVER',
+          id: 'APP_TIMLINE_SERVER_c6401.ambari.apache.org',
+          service_id: 'YARN'
+        };
+        App.store.load(App.HostComponent, hostComponent);
+        App.store.load(App.Service, service);
+        controller.loadCommands();
       });
       });
 
 
-      it('delete ATS component stage should be after stage3', function() {
-        expect(controller.get('stages').indexOf(controller.get('stages').findProperty('stage','stage5'))).to.eql(2);
+      it('delete ATS component stage should be after APPLY_CONFIGURATIONS', function() {
+        expect(controller.get('commands').indexOf(controller.get('commands').findProperty('name','DELETE_ATS'))).to.eql(2);
       });
       });
 
 
-      it('stages length should be equal to 4', function() {
-        expect(controller.get('stages').length).to.eql(4);
+      it('commands length should be equal to 4', function() {
+        expect(controller.get('commands').length).to.eql(4);
       });
       });
 
 
       it('total steps should be equal to 4', function() {
       it('total steps should be equal to 4', function() {
@@ -104,18 +115,19 @@ describe('App.MainAdminSecurityAddStep4Controller', function () {
             ];
             ];
           }.property()
           }.property()
         });
         });
-        App.set('stackDependedComponents', [
-          Em.Object.create({
-            componentName: 'APP_TIMELINE_SERVER'
-          })
-        ]);
-        controller.set('stages', []);
+        controller.set('commands', []);
         controller.set('totalSteps', 3);
         controller.set('totalSteps', 3);
-        controller.loadStages();
+        var service = {
+          id: 'YARN',
+          service_name: 'YARN',
+          host_components: []
+        };
+        App.store.load(App.Service, service);
+        controller.loadCommands();
       });
       });
 
 
-      it('stages length should be equal to 3', function() {
-        expect(controller.get('stages').length).to.eql(3);
+      it('commands length should be equal to 3', function() {
+        expect(controller.get('commands').length).to.eql(3);
       });
       });
 
 
       it('total steps should be equal to 3', function() {
       it('total steps should be equal to 3', function() {