瀏覽代碼

AMBARI-5242. Move wizard freezes on step "Configure component", operation "Install (component name)". (Denys Buzhor via akovalenko)

Aleksandr Kovalenko 11 年之前
父節點
當前提交
4be37e9b0a

+ 25 - 17
ambari-web/app/controllers/main/admin/highAvailability/progress_controller.js

@@ -187,6 +187,28 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
 
   onTaskStatusChange: function () {
     console.warn('func: onTaskStatusChange1');
+    var statuses = this.get('tasks').mapProperty('status');
+    var logs = this.get('tasks').mapProperty('hosts');
+    var requestIds = this.get('currentRequestIds');
+    console.warn('func: onTaskStatusChange5',statuses, logs, requestIds);
+    // save task info
+    App.router.get(this.get('content.controllerName')).saveTasksStatuses(statuses);
+    App.router.get(this.get('content.controllerName')).saveRequestIds(requestIds);
+    App.router.get(this.get('content.controllerName')).saveLogs(logs);
+    // call saving of cluster status asynchronous
+    // synchronous executing cause problems in Firefox
+    App.clusterStatus.setClusterStatus({
+      clusterName: this.get('content.cluster.name'),
+      clusterState: this.get('clusterDeployState'),
+      wizardControllerName: this.get('content.controllerName'),
+      localdb: App.db.data
+    }, { async: true, success: 'statusChangeCallback', sender: this });
+  },
+  /**
+   * Method that called after saving persist data to server.
+   * Switch task according its status.
+   */
+  statusChangeCallback: function() {
     if (!this.get('tasks').someProperty('status', 'IN_PROGRESS') && !this.get('tasks').someProperty('status', 'QUEUED') && !this.get('tasks').someProperty('status', 'FAILED')) {
       var nextTask = this.get('tasks').findProperty('status', 'PENDING');
       if (nextTask) {
@@ -210,24 +232,10 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
     }
     this.get('tasks').filterProperty('status','COMPLETED').setEach('showRetry', false);
     this.get('tasks').filterProperty('status','COMPLETED').setEach('showRollback', false);
-
-    var statuses = this.get('tasks').mapProperty('status');
-    var logs = this.get('tasks').mapProperty('hosts');
-    var requestIds = this.get('currentRequestIds');
-    console.warn('func: onTaskStatusChange5',statuses, logs, requestIds);
-    App.router.get(this.get('content.controllerName')).saveTasksStatuses(statuses);
-    App.router.get(this.get('content.controllerName')).saveRequestIds(requestIds);
-    App.router.get(this.get('content.controllerName')).saveLogs(logs);
-    App.clusterStatus.setClusterStatus({
-      clusterName: this.get('content.cluster.name'),
-      clusterState: this.get('clusterDeployState'),
-      wizardControllerName: this.get('content.controllerName'),
-      localdb: App.db.data
-    });
   },
 
-  /*
-   run command of appropriate task
+  /**
+   * Run command of appropriate task
    */
   runTask: function (taskId) {
     console.warn('func: runTask',taskId);
@@ -370,6 +378,7 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
     console.warn('func: doPolling');
     this.setTaskStatus(this.get('currentTaskId'), 'IN_PROGRESS');
     var requestIds = this.get('currentRequestIds');
+    this.set('logs', []);
     for (var i = 0; i < requestIds.length; i++) {
       App.ajax.send({
         name: 'admin.high_availability.polling',
@@ -415,7 +424,6 @@ App.HighAvailabilityProgressPageController = App.HighAvailabilityWizardControlle
           self.doPolling()
         }, self.POLL_INTERVAL);
       }
-      this.set('logs', []);
     }
   },
 

+ 17 - 4
ambari-web/app/models/cluster_states.js

@@ -124,9 +124,11 @@ App.clusterStatus = Ember.Object.create({
   /**
    * update cluster status and post it on server
    * @param newValue
+   * @param opt - used for additional ajax request options, by default ajax used synchronous mode
+   *
    * @return {*}
    */
-  setClusterStatus: function(newValue){
+  setClusterStatus: function(newValue, opt){
     if(App.testMode) return false;
     var user = App.db.getUser();
     var login = App.db.getLoginName();
@@ -146,6 +148,7 @@ App.clusterStatus = Ember.Object.create({
         this.set('wizardControllerName', newValue.wizardControllerName);
         val.wizardControllerName = newValue.wizardControllerName;
       }
+
       if (newValue.localdb) {
         if (newValue.localdb.app && newValue.localdb.app.user)
           delete newValue.localdb.app.user;
@@ -156,7 +159,7 @@ App.clusterStatus = Ember.Object.create({
       } else {
         delete App.db.data.app.user;
         delete App.db.data.app.loginName;
-          val.localdb = App.db.data;
+        val.localdb = App.db.data;
         App.db.setUser(user);
         App.db.setLoginName(login);
       }
@@ -165,7 +168,7 @@ App.clusterStatus = Ember.Object.create({
 
       keyValuePair[this.get('key')] = JSON.stringify(val);
 
-      App.ajax.send({
+      var ajaxOptions = {
         name: 'cluster.state',
         sender: this,
         data: {
@@ -173,7 +176,17 @@ App.clusterStatus = Ember.Object.create({
         },
         beforeSend: 'clusterStatusBeforeSend',
         error: 'clusterStatusErrorCallBack'
-      });
+      };
+
+      if (opt) {
+        ajaxOptions.async = !!opt.async;
+        ajaxOptions.sender = opt.sender || this;
+        ajaxOptions.success = opt.success;
+        ajaxOptions.beforeSend = opt.beforeSend;
+        ajaxOptions.error = opt.error;
+      }
+
+      App.ajax.send(ajaxOptions);
       return newValue;
     }
   },