You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ja...@apache.org on 2013/06/22 02:38:23 UTC

svn commit: r1495647 - in /incubator/ambari/trunk/ambari-web/app: controllers/global/ controllers/main/admin/security/ controllers/main/admin/security/add/ routes/ utils/

Author: jaimin
Date: Sat Jun 22 00:38:22 2013
New Revision: 1495647

URL: http://svn.apache.org/r1495647
Log:
AMBARI-2387. Security Wizard: the user gets stuck after quitting Security wizard and starting it again. (jaimin via Andrii Tkach)

Modified:
    incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js
    incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js
    incubator/ambari/trunk/ambari-web/app/routes/add_security.js
    incubator/ambari/trunk/ambari-web/app/routes/main.js
    incubator/ambari/trunk/ambari-web/app/utils/db.js
    incubator/ambari/trunk/ambari-web/app/utils/polling.js

Modified: incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js?rev=1495647&r1=1495646&r2=1495647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/global/background_operations_controller.js Sat Jun 22 00:38:22 2013
@@ -75,7 +75,7 @@ App.BackgroundOperationsController = Em.
         status: "",
         isRunning: false,
         hosts: []
-      })
+      });
       if(request.Requests.request_context != ""){
         rq.name = request.Requests.request_context;
         rq.displayName = request.Requests.request_context;
@@ -86,7 +86,10 @@ App.BackgroundOperationsController = Em.
       runningTasks += request.tasks.filterProperty('Tasks.status', 'IN_PROGRESS').length;
       runningTasks += request.tasks.filterProperty('Tasks.status', 'PENDING').length;
       if(runningTasks > 0){
+        rq.set('isRunning', true);
         runningServices++;
+      } else {
+        rq.set('isRunning', false);
       }
 
       var hostNames = request.tasks.mapProperty('Tasks.host_name').uniq();

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js?rev=1495647&r1=1495646&r2=1495647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step2.js Sat Jun 22 00:38:22 2013
@@ -22,7 +22,6 @@ App.MainAdminSecurityAddStep2Controller 
   name: 'mainAdminSecurityAddStep2Controller',
   stepConfigs: [],
   installedServices: [],
-  serviceConfigs: require('data/secure_configs'),
   selectedService: null,
 
   isSubmitDisabled: function () {
@@ -40,7 +39,6 @@ App.MainAdminSecurityAddStep2Controller 
   loadStep: function () {
     console.log("TRACE: Loading addSecurity step2: Configure Services");
     this.clearStep();
-    var serviceConfigs = this.get('serviceConfigs');
     this.renderServiceConfigs(this.get('content.services'));
     var storedServices = this.get('content.serviceConfigProperties');
     if (storedServices) {
@@ -55,7 +53,7 @@ App.MainAdminSecurityAddStep2Controller 
           //if we have config for specified component
           if (componentVal) {
             //set it
-            _config.set('value', componentVal.value)
+            _config.set('value', componentVal.value);
           }
 
         }, this);
@@ -73,19 +71,16 @@ App.MainAdminSecurityAddStep2Controller 
    * @param serviceConfigs
    */
   renderServiceConfigs: function (serviceConfigs) {
-    this.get('serviceConfigs').forEach(function (_serviceConfig) {
+    serviceConfigs.forEach(function (_serviceConfig) {
 
       var serviceConfig = App.ServiceConfig.create({
         filename: _serviceConfig.filename,
         serviceName: _serviceConfig.serviceName,
         displayName: _serviceConfig.displayName,
         configCategories: _serviceConfig.configCategories,
-        showConfig: false,
+        showConfig: true,
         configs: []
       });
-      if (serviceConfigs.someProperty('serviceName', serviceConfig.serviceName)) {
-        serviceConfig.showConfig = true;
-      }
 
       this.loadComponentConfigs(_serviceConfig, serviceConfig);
 

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js?rev=1495647&r1=1495646&r2=1495647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/add/step3.js Sat Jun 22 00:38:22 2013
@@ -69,7 +69,6 @@ App.MainAdminSecurityAddStep3Controller 
         var failedStages = stages.filterProperty('isError', true);
         failedStages.setEach('isError', false);
         failedStages.setEach('isStarted', false);
-        failedStages.setEach('isCompleted', false);
       } else if (stages.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
         var runningStage = stages.filterProperty('isStarted', true).findProperty('isCompleted', false);
         runningStage.set('isStarted', false);
@@ -78,6 +77,12 @@ App.MainAdminSecurityAddStep3Controller 
     } else {
       this.loadStages();
       this.addInfoToStages();
+      var runningOperations = App.router.get('backgroundOperationsController.services').filterProperty('isRunning');
+      var stopAllOperation = runningOperations.findProperty('name', 'Stop All Services');
+      var stopStage = this.get('stages').findProperty('name', 'STOP_SERVICES');
+      if (stopStage.get('name') === 'STOP_SERVICES' && stopAllOperation) {
+        stopStage.set('requestId', stopAllOperation.get('id'));
+      }
     }
     this.moveToNextStage();
   },
@@ -119,9 +124,9 @@ App.MainAdminSecurityAddStep3Controller 
 
   loadStages: function () {
     this.get('stages').pushObjects([
-      App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true}),
-      App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false}),
-      App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true})
+      App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true, name: 'STOP_SERVICES'}),
+      App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false, name: 'APPLY_CONFIGURATIONS'}),
+      App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true, name: 'START_SERVICES'})
     ]);
   },
 
@@ -523,7 +528,7 @@ App.MainAdminSecurityAddStep3Controller 
       }
       else {
         this.get('configs').filterProperty('id', 'site property').filterProperty('filename', _serviceConfigTags.siteName + '.xml').forEach(function (_config) {
-            _serviceConfigTags.configs[_config.name] = _config.value;
+          _serviceConfigTags.configs[_config.name] = _config.value;
         }, this);
       }
     }, this);
@@ -533,6 +538,7 @@ App.MainAdminSecurityAddStep3Controller 
     var stages = [];
     this.get('stages').forEach(function (_stage) {
       var stage = {
+        name: _stage.get('name'),
         stage: _stage.get('stage'),
         label: _stage.get('label'),
         isPolling: _stage.get('isPolling'),

Modified: incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js?rev=1495647&r1=1495646&r2=1495647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js (original)
+++ incubator/ambari/trunk/ambari-web/app/controllers/main/admin/security/disable.js Sat Jun 22 00:38:22 2013
@@ -41,7 +41,6 @@ App.MainAdminSecurityDisableController =
   },
 
   loadStep: function () {
-
     this.clearStep();
     var stages = App.db.getSecurityDeployStages();
     if (stages && stages.length > 0) {
@@ -52,7 +51,6 @@ App.MainAdminSecurityDisableController =
         var failedStages = stages.filterProperty('isError', true);
         failedStages.setEach('isError', false);
         failedStages.setEach('isStarted', false);
-        failedStages.setEach('isCompleted', false);
       } else if (stages.filterProperty('isStarted', true).someProperty('isCompleted', false)) {
         var runningStage = stages.filterProperty('isStarted', true).findProperty('isCompleted', false);
         runningStage.set('isStarted', false);
@@ -61,6 +59,12 @@ App.MainAdminSecurityDisableController =
     } else {
       this.loadStages();
       this.addInfoToStages();
+      var runningOperations = App.router.get('backgroundOperationsController.services').filterProperty('isRunning');
+      var stopAllOperation = runningOperations.findProperty('name', 'Stop All Services');
+      var stopStage = this.get('stages').findProperty('name', 'STOP_SERVICES');
+      if (stopStage.get('name') === 'STOP_SERVICES' && stopAllOperation) {
+        stopStage.set('requestId', stopAllOperation.get('id'));
+      }
     }
     this.loadSecureServices();
     this.moveToNextStage();
@@ -69,9 +73,9 @@ App.MainAdminSecurityDisableController =
 
   loadStages: function () {
     this.get('stages').pushObjects([
-      App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true}),
-      App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false}),
-      App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true})
+      App.Poll.create({stage: 'stage2', label: Em.I18n.translations['admin.addSecurity.apply.stage2'], isPolling: true, name: 'STOP_SERVICES'}),
+      App.Poll.create({stage: 'stage3', label: Em.I18n.translations['admin.addSecurity.apply.stage3'], isPolling: false, name: 'APPLY_CONFIGURATIONS'}),
+      App.Poll.create({stage: 'stage4', label: Em.I18n.translations['admin.addSecurity.apply.stage4'], isPolling: true, name: 'START_SERVICES'})
     ]);
   },
 
@@ -100,7 +104,6 @@ App.MainAdminSecurityDisableController =
       } else if (currentStage && currentStage.get('stage') === 'stage3') {
         if (App.testMode) {
           currentStage.set('isSuccess', true);
-          currentStage.set('isCompleted', true);
           this.moveToNextStage();
         } else {
           this.loadClusterConfigs();
@@ -353,6 +356,7 @@ App.MainAdminSecurityDisableController =
     var stages = [];
     this.get('stages').forEach(function (_stage) {
       var stage = {
+        name: _stage.get('name'),
         stage: _stage.get('stage'),
         label: _stage.get('label'),
         isPolling: _stage.get('isPolling'),

Modified: incubator/ambari/trunk/ambari-web/app/routes/add_security.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/routes/add_security.js?rev=1495647&r1=1495646&r2=1495647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/routes/add_security.js (original)
+++ incubator/ambari/trunk/ambari-web/app/routes/add_security.js Sat Jun 22 00:38:22 2013
@@ -23,6 +23,7 @@ module.exports = Em.Route.extend({
     console.log('in /security/add:enter');
 
     Ember.run.next(function () {
+      //after refresh check if the wizard is open then restore it
       if (router.get('mainAdminSecurityController').getAddSecurityWizardStatus() === 'RUNNING') {
         var mainAdminSecurityController = router.get('mainAdminSecurityController');
         var addSecurityController = router.get('addSecurityController');
@@ -51,24 +52,23 @@ module.exports = Em.Route.extend({
                   if (!applyingConfigStage.get('isCompleted')) {
                     if (applyingConfigStage.get('isStarted')) {
                       App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
-                      return;
                     } else {
                       App.showConfirmationPopup(function () {
                         self.proceedOnClose();
                       }, Em.I18n.t('admin.addSecurity.enable.onClose'));
-                      return;
                     }
                   } else {
-                    App.showConfirmationPopup(function () {
-                        this.hide();
-                      }, Em.I18n.t('admin.addSecurity.enable.after.stage2.onClose'),
+                    App.showConfirmationPopup(function () {},
+                      Em.I18n.t('admin.addSecurity.enable.after.stage2.onClose'),
                       function () {
                         self.proceedOnClose();
                       });
-                    return;
                   }
+                  return;
                 }
               }
+              router.get('mainAdminSecurityAddStep3Controller').clearStep();
+              App.db.setSecurityDeployStages(undefined);
               self.proceedOnClose();
             },
             proceedOnClose: function () {
@@ -105,12 +105,14 @@ module.exports = Em.Route.extend({
   step1: Em.Route.extend({
     route: '/start',
     enter: function (router) {
-      App.clusterStatus.setClusterStatus({
-        clusterName: this.get('clusterName'),
-        clusterState: 'ADD_SECURITY_STEP_1',
-        wizardControllerName: router.get('addSecurityController.name'),
-        localdb: App.db.data
-      });
+      if(!App.testMode){
+        App.clusterStatus.setClusterStatus({
+          clusterName: this.get('clusterName'),
+          clusterState: 'ADD_SECURITY_STEP_1',
+          wizardControllerName: router.get('addSecurityController.name'),
+          localdb: App.db.data
+        });
+      }
     },
 
     connectOutlets: function (router) {
@@ -134,12 +136,14 @@ module.exports = Em.Route.extend({
     route: '/configure',
 
     enter: function (router) {
-      App.clusterStatus.setClusterStatus({
-        clusterName: this.get('clusterName'),
-        clusterState: 'ADD_SECURITY_STEP_2',
-        wizardControllerName: router.get('addSecurityController.name'),
-        localdb: App.db.data
-      });
+      if(!App.testMode){
+        App.clusterStatus.setClusterStatus({
+          clusterName: this.get('clusterName'),
+          clusterState: 'ADD_SECURITY_STEP_2',
+          wizardControllerName: router.get('addSecurityController.name'),
+          localdb: App.db.data
+        });
+      }
     },
     connectOutlets: function (router) {
       console.log('in addSecurity.step2:connectOutlets');

Modified: incubator/ambari/trunk/ambari-web/app/routes/main.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/routes/main.js?rev=1495647&r1=1495646&r2=1495647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/routes/main.js (original)
+++ incubator/ambari/trunk/ambari-web/app/routes/main.js Sat Jun 22 00:38:22 2013
@@ -688,6 +688,7 @@ module.exports = Em.Route.extend({
       disableSecurity: Ember.Route.extend({
         route: '/disableSecurity',
         enter: function (router) {
+          //after refresh check if the wizard is open then restore it
           if (router.get('mainAdminSecurityController').getDisableSecurityStatus() === 'RUNNING') {
             App.clusterStatus.setClusterStatus({
               clusterName: this.get('clusterName'),
@@ -718,12 +719,10 @@ module.exports = Em.Route.extend({
                   if (applyingConfigStage && !applyingConfigStage.get('isCompleted')) {
                     if (applyingConfigStage.get('isStarted')) {
                       App.showAlertPopup(Em.I18n.t('admin.security.applying.config.header'), Em.I18n.t('admin.security.applying.config.body'));
-                      return;
                     } else {
                       App.showConfirmationPopup(function () {
                         self.proceedOnClose();
                       }, Em.I18n.t('admin.addSecurity.disable.onClose'));
-                      return;
                     }
                   } else {
                     self.proceedOnClose();

Modified: incubator/ambari/trunk/ambari-web/app/utils/db.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/db.js?rev=1495647&r1=1495646&r2=1495647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/db.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/db.js Sat Jun 22 00:38:22 2013
@@ -310,12 +310,6 @@ App.db.setDisableSecurityStatus = functi
   localStorage.setObject('ambari', App.db.data);
 };
 
-App.db.setSecurityStage = function (securityStage) {
-  App.db.data = localStorage.getObject('ambari');
-  App.db.data.AddSecurity.securityStage = securityStage;
-  localStorage.setObject('ambari', App.db.data);
-};
-
 App.db.setSecurityDeployStages = function (securityStages) {
   App.db.data = localStorage.getObject('ambari');
   if (!App.db.data.AddSecurity) {
@@ -516,11 +510,6 @@ App.db.getDisableSecurityStatus = functi
   return App.db.data.disableSecurityStatus;
 };
 
-App.db.getSecurityStage = function () {
-  App.db.data = localStorage.getObject('ambari');
-  return App.db.data.AddSecurity.securityStage;
-};
-
 App.db.getSecurityDeployStages = function () {
   App.db.data = localStorage.getObject('ambari');
   return App.db.data.AddSecurity.securityDeployStages;

Modified: incubator/ambari/trunk/ambari-web/app/utils/polling.js
URL: http://svn.apache.org/viewvc/incubator/ambari/trunk/ambari-web/app/utils/polling.js?rev=1495647&r1=1495646&r2=1495647&view=diff
==============================================================================
--- incubator/ambari/trunk/ambari-web/app/utils/polling.js (original)
+++ incubator/ambari/trunk/ambari-web/app/utils/polling.js Sat Jun 22 00:38:22 2013
@@ -18,6 +18,7 @@
 
 var App = require('app');
 App.Poll = Em.Object.extend({
+  name: '',
   stage: '',
   label: '',
   isStarted: false,
@@ -126,6 +127,8 @@ App.Poll = Em.Object.extend({
           window.setTimeout(function () {
             self.startPolling();
           }, self.POLL_INTERVAL);
+        } else {
+          self.set('requestId', undefined);
         }
       },
 
@@ -156,13 +159,13 @@ App.Poll = Em.Object.extend({
   },
 
 
-  getExecutedTasks: function (tasksData) {
-    var succededTasks = tasksData.filterProperty('Tasks.status', 'COMPLETED');
-    var failedTasks = tasksData.filterProperty('Tasks.status', 'FAILED');
-    var abortedTasks = tasksData.filterProperty('Tasks.status', 'ABORTED');
-    var timedoutTasks = tasksData.filterProperty('Tasks.status', 'TIMEDOUT');
-    var inProgressTasks = tasksData.filterProperty('Tasks.status', 'IN_PROGRESS');
-    return (succededTasks.length + failedTasks.length + abortedTasks.length + timedoutTasks.length + inProgressTasks.length);
+  calculateProgressByTasks: function (tasksData) {
+    var queuedTasks = tasksData.filterProperty('Tasks.status', 'QUEUED').length;
+    var completedTasks = tasksData.filter(function(task){
+      return ['COMPLETED', 'FAILED', 'ABORTED', 'TIMEDOUT'].contains(task.Tasks.status);
+    }).length;
+    var inProgressTasks = tasksData.filterProperty('Tasks.status', 'IN_PROGRESS').length;
+    return Math.ceil(((queuedTasks * 0.09) + (inProgressTasks * 0.35) + completedTasks ) / tasksData.length * 100)
   },
 
   isPollingFinished: function (polledData) {
@@ -188,7 +191,7 @@ App.Poll = Em.Object.extend({
       console.log("ERROR: NO tasks available to process");
     }
     var requestId = this.get('requestId');
-    if (!App.testMode && polledData.Requests && polledData.Requests.id && polledData.Requests.id != requestId) {
+    if (polledData.Requests && polledData.Requests.id && polledData.Requests.id != requestId) {
       // We dont want to use non-current requestId's tasks data to
       // determine the current install status.
       // Also, we dont want to keep polling if it is not the
@@ -210,8 +213,7 @@ App.Poll = Em.Object.extend({
      totalProgress += self.progressPerHost(actionsPerHost, _host);
      }
      }, this); */
-    var executedTasks = this.getExecutedTasks(tasksData);
-    totalProgress = Math.floor((executedTasks / tasksData.length) * 100);
+    var totalProgress = this.calculateProgressByTasks(tasksData);
     this.set('progress', totalProgress.toString());
     console.log("INFO: right now the progress is: " + this.get('progress'));
     return this.isPollingFinished(tasksData);