浏览代码

AMBARI-6156 Change calls which request logs to asynchronous. (atkach)

atkach 11 年之前
父节点
当前提交
b642840c03

+ 17 - 7
ambari-web/app/controllers/global/background_operations_controller.js

@@ -43,8 +43,7 @@ App.BackgroundOperationsController = Em.Controller.extend({
   levelInfo: Em.Object.create({
     name: 'REQUESTS_LIST',
     requestId: null,
-    taskId: null,
-    sync: false
+    taskId: null
   }),
 
   /**
@@ -70,6 +69,20 @@ App.BackgroundOperationsController = Em.Controller.extend({
       'callback': callback,
       'data': queryParams.data
     });
+    return !this.isInitLoading();
+  },
+  /**
+   * indicate whether data for current level has already been loaded or not
+   * @return {Boolean}
+   */
+  isInitLoading: function () {
+    var levelInfo = this.get('levelInfo');
+    var request = this.get('services').findProperty('id', levelInfo.get('requestId'));
+
+    if (levelInfo.get('name') === 'HOSTS_LIST') {
+      return !!(request && App.isEmptyObject(request.get('hostsMap')));
+    }
+    return false;
   },
   /**
    * construct params of ajax query regarding displayed level
@@ -86,18 +99,15 @@ App.BackgroundOperationsController = Em.Controller.extend({
       result.successCallback = 'callBackFilteredByTask';
       result.data = {
         'taskId': levelInfo.get('taskId'),
-        'requestId': levelInfo.get('requestId'),
-        'sync': levelInfo.get('sync')
+        'requestId': levelInfo.get('requestId')
       };
     } else if (levelInfo.get('name') === 'TASKS_LIST' || levelInfo.get('name') === 'HOSTS_LIST') {
       result.name = 'background_operations.get_by_request';
       result.successCallback = 'callBackFilteredByRequest';
       result.data = {
-        'requestId': levelInfo.get('requestId'),
-        'sync': levelInfo.get('sync')
+        'requestId': levelInfo.get('requestId')
       };
     }
-    levelInfo.set('sync', false);
     return result;
   },
 

+ 1 - 2
ambari-web/app/controllers/wizard/step9_controller.js

@@ -948,8 +948,7 @@ App.WizardStep9Controller = Em.Controller.extend({
       data: {
         'taskId': taskId,
         'requestId': requestId,
-        'clusterName': clusterName,
-        'sync': true
+        'clusterName': clusterName
       },
       success: 'loadCurrentTaskLogSuccessCallback',
       error: 'loadCurrentTaskLogErrorCallback'

+ 42 - 34
ambari-web/app/templates/common/host_progress_popup.hbs

@@ -102,31 +102,35 @@
         </div>
       {{/if}}
     {{/if}}
-    <div id="host-info" {{bindAttr class="view.isRequestSchedule:scheduled"}}>
-      {{#if view.isHostEmptyList}}
-        <div class="log-list-wrap">{{t hostPopup.noHostsToShow}}</div>
-      {{else}}
-        {{#each hostInfo in view.pageContent}}
-          <div {{bindAttr class="hostInfo.isVisible::hidden :log-list-wrap"}}>
-            <div {{action gotoTasks hostInfo}} class="task-list-line-cursor">
-              <div class="host-name-icon-wrap">
-                <i {{bindAttr class="hostInfo.status hostInfo.icon"}}></i>
-                <a href="#">
-                  {{hostInfo.displayName}}
-                </a>
-              </div>
-              <div class="progress-bar span2">
-                <div {{bindAttr class="hostInfo.isInProgress:progress-striped :active hostInfo.barColor :progress"}}>
-                  <div class="bar" {{bindAttr style="hostInfo.barWidth"}}></div>
+    {{#if view.isLevelLoaded}}
+        <div id="host-info" {{bindAttr class="view.isRequestSchedule:scheduled"}}>
+          {{#if view.isHostEmptyList}}
+              <div class="log-list-wrap">{{t hostPopup.noHostsToShow}}</div>
+          {{else}}
+            {{#each hostInfo in view.pageContent}}
+                <div {{bindAttr class="hostInfo.isVisible::hidden :log-list-wrap"}}>
+                    <div {{action gotoTasks hostInfo}} class="task-list-line-cursor">
+                        <div class="host-name-icon-wrap">
+                            <i {{bindAttr class="hostInfo.status hostInfo.icon"}}></i>
+                            <a href="#">
+                              {{hostInfo.displayName}}
+                            </a>
+                        </div>
+                        <div class="progress-bar span2">
+                            <div {{bindAttr class="hostInfo.isInProgress:progress-striped :active hostInfo.barColor :progress"}}>
+                                <div class="bar" {{bindAttr style="hostInfo.barWidth"}}></div>
+                            </div>
+                        </div>
+                        <div class="host-progress-num">{{hostInfo.progress}}%</div>
+                        <div class="show-details"><i class="icon-caret-right"></i></div>
+                    </div>
                 </div>
-              </div>
-              <div class="host-progress-num">{{hostInfo.progress}}%</div>
-              <div class="show-details"><i class="icon-caret-right"></i></div>
-            </div>
-          </div>
-        {{/each}}
-      {{/if}}
-    </div>
+            {{/each}}
+          {{/if}}
+        </div>
+    {{else}}
+      <div class="spinner"></div>
+    {{/if}}
   </div>
 
 
@@ -182,17 +186,21 @@
         <a title="Open in New Window" {{action openTaskLogInDialog}} class="task-detail-open-dialog"><i class="icon-external-link"></i> {{t common.open}}</a>
       </div>
     </div>
-    <div class="task-detail-log-info">
-      <div class="content-area" >
-        <div class="task-detail-log-clipboard-wrap" ></div>
-        <div class="task-detail-log-maintext">
-          <h5>stderr: &nbsp; <span class="muted">{{view.openedTask.errorLog}} </span></h5>
-          <pre class="stderr">{{view.openedTask.stderr}}</pre>
-          <h5>stdout: &nbsp; <span class="muted"> {{view.openedTask.outputLog}} </span> </h5>
-          <pre class="stdout">{{view.openedTask.stdout}}</pre>
+    {{#if view.isLevelLoaded}}
+        <div class="task-detail-log-info">
+            <div class="content-area">
+                <div class="task-detail-log-clipboard-wrap"></div>
+                <div class="task-detail-log-maintext">
+                    <h5>stderr: &nbsp; <span class="muted">{{view.openedTask.errorLog}} </span></h5>
+                    <pre class="stderr">{{view.openedTask.stderr}}</pre>
+                    <h5>stdout: &nbsp; <span class="muted"> {{view.openedTask.outputLog}} </span></h5>
+                    <pre class="stdout">{{view.openedTask.stdout}}</pre>
+                </div>
+            </div>
         </div>
-      </div>
-    </div>
+    {{else}}
+      <div class="spinner"></div>
+    {{/if}}
   </div>
     {{else}}
       <div class="spinner"></div>

+ 14 - 10
ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs

@@ -74,17 +74,21 @@
                   class="icon-external-link"></i> {{t common.open}}</a>
         </div>
       </div>
-      <div class="task-detail-log-info">
-        <div class="content-area">
-          <div class="task-detail-log-clipboard-wrap"></div>
-          <div class="task-detail-log-maintext">
-            <h5>stderr: &nbsp; <span class="muted">{{view.openedTask.errorLog}} </span></h5>
-            <pre class="stderr">{{view.openedTask.stderr}}</pre>
-            <h5>stdout: &nbsp; <span class="muted"> {{view.openedTask.outputLog}} </span></h5>
-            <pre class="stdout">{{view.openedTask.stdout}}</pre>
+      {{#if view.isTaskLoaded}}
+          <div class="task-detail-log-info">
+              <div class="content-area">
+                  <div class="task-detail-log-clipboard-wrap"></div>
+                  <div class="task-detail-log-maintext">
+                      <h5>stderr: &nbsp; <span class="muted">{{view.openedTask.errorLog}} </span></h5>
+                      <pre class="stderr">{{view.openedTask.stderr}}</pre>
+                      <h5>stdout: &nbsp; <span class="muted"> {{view.openedTask.outputLog}} </span></h5>
+                      <pre class="stdout">{{view.openedTask.stdout}}</pre>
+                  </div>
+              </div>
           </div>
-        </div>
-      </div>
+      {{else}}
+        <div class="spinner"></div>
+      {{/if}}
     </div>
   {{/if}}
 {{/if}}

+ 2 - 12
ambari-web/app/utils/ajax/ajax.js

@@ -46,22 +46,12 @@ var urls = {
   'background_operations.get_by_request': {
     'real': '/clusters/{clusterName}/requests/{requestId}?fields=*,tasks/Tasks/command,tasks/Tasks/command_detail,tasks/Tasks/start_time,tasks/Tasks/end_time,tasks/Tasks/exit_code,tasks/Tasks/host_name,tasks/Tasks/id,tasks/Tasks/role,tasks/Tasks/status&minimal_response=true',
     'mock': '/data/background_operations/task_by_request{requestId}.json',
-    'testInProduction': true,
-    'format': function (data) {
-      return {
-        async: !data.sync
-      };
-    }
+    'testInProduction': true
   },
   'background_operations.get_by_task': {
     'real': '/clusters/{clusterName}/requests/{requestId}/tasks/{taskId}',
     'mock': '/data/background_operations/list_on_start.json',
-    'testInProduction': true,
-    'format': function (data) {
-      return {
-        async: !data.sync
-      };
-    }
+    'testInProduction': true
   },
   'service.item.start_stop': {
     'real': '/clusters/{clusterName}/services/{serviceName}',

+ 29 - 27
ambari-web/app/utils/host_progress_popup.js

@@ -548,6 +548,30 @@ App.HostPopup = Em.Object.create({
 
         pagination: true,
         isPaginate: false,
+        /**
+         * Select box, display names and values
+         */
+        categories: [
+          categoryObject.create({value: 'all', labelPath: 'hostPopup.status.category.all'}),
+          categoryObject.create({value: 'pending', labelPath: 'hostPopup.status.category.pending'}),
+          categoryObject.create({value: 'in_progress', labelPath: 'hostPopup.status.category.inProgress'}),
+          categoryObject.create({value: 'failed', labelPath: 'hostPopup.status.category.failed'}),
+          categoryObject.create({value: 'completed', labelPath: 'hostPopup.status.category.success'}),
+          categoryObject.create({value: 'aborted', labelPath: 'hostPopup.status.category.aborted'}),
+          categoryObject.create({value: 'timedout', labelPath: 'hostPopup.status.category.timedout'})
+        ],
+
+        /**
+         * Selected option is bound to this values
+         */
+        serviceCategory: null,
+        hostCategory: null,
+        taskCategory: null,
+        /**
+         * flag to indicate whether level data has already been loaded
+         * applied only to HOSTS_LIST and TASK_DETAILS levels, whereas async query used to obtain data
+         */
+        isLevelLoaded: true,
         content: function() {
           return this.get('hosts') || [];
         }.property('hosts.length', 'isHostListHidden'),
@@ -602,11 +626,9 @@ App.HostPopup = Em.Object.create({
           this.get("controller").onServiceUpdate(this.get('isServiceListHidden'));
           this.get("controller").onHostUpdate();
           this.set('parentView.isLoaded', true);
-          //push hosts into view when none or all hosts are loaded
-          if(this.get('hosts') == null || this.get('hosts').length === this.get("controller.hosts").length){
-            this.set("hosts", this.get("controller.hosts"));
-          }
+          this.set("hosts", this.get("controller.hosts"));
           this.set("services", this.get("controller.servicesInfo"));
+          this.set('isLevelLoaded', true);
         }.observes("controller.dataSourceController.serviceTimestamp"),
 
         /**
@@ -680,26 +702,6 @@ App.HostPopup = Em.Object.create({
           return isEmptyList;
         },
 
-        /**
-         * Select box, display names and values
-         */
-        categories: [
-          categoryObject.create({value: 'all', labelPath: 'hostPopup.status.category.all'}),
-          categoryObject.create({value: 'pending', labelPath: 'hostPopup.status.category.pending'}),
-          categoryObject.create({value: 'in_progress', labelPath: 'hostPopup.status.category.inProgress'}),
-          categoryObject.create({value: 'failed', labelPath: 'hostPopup.status.category.failed'}),
-          categoryObject.create({value: 'completed', labelPath: 'hostPopup.status.category.success'}),
-          categoryObject.create({value: 'aborted', labelPath: 'hostPopup.status.category.aborted'}),
-          categoryObject.create({value: 'timedout', labelPath: 'hostPopup.status.category.timedout'})
-        ],
-
-        /**
-         * Selected option is binded to this values
-         */
-        serviceCategory: null,
-        hostCategory: null,
-        taskCategory: null,
-
         /**
          * Depending on currently viewed tab, call setSelectCount function
          */
@@ -733,17 +735,17 @@ App.HostPopup = Em.Object.create({
             levelInfo.set('requestId', this.get('controller.currentServiceId'));
             levelInfo.set('name', levelName);
             if (levelName === 'HOSTS_LIST') {
-              levelInfo.set('sync', (this.get('controller.hosts').length === 0));
-              dataSourceController.requestMostRecent();
+              this.set('isLevelLoaded', dataSourceController.requestMostRecent());
             } else if (levelName === 'TASK_DETAILS') {
-              levelInfo.set('sync', true);
               dataSourceController.requestMostRecent();
+              this.set('isLevelLoaded', false);
             } else if (levelName === 'REQUESTS_LIST') {
               this.get('controller.hosts').clear();
               dataSourceController.requestMostRecent();
             }
           } else if (securityControllers.contains(dataSourceController.get('name'))) {
             if (levelName === 'TASK_DETAILS') {
+              this.set('isLevelLoaded', false);
               dataSourceController.startUpdatingTask(this.get('controller.currentServiceId'), this.get('openedTaskId'));
             } else {
               dataSourceController.stopUpdatingTask(this.get('controller.currentServiceId'));

+ 2 - 4
ambari-web/app/utils/polling.js

@@ -128,8 +128,7 @@ App.Poll = Em.Object.extend({
         sender: this,
         data: {
           requestId: this.get('requestId'),
-          taskId: this.get('currentTaskId'),
-          sync: true
+          taskId: this.get('currentTaskId')
         },
         success: 'pollTaskLogSuccessCallback'
       })
@@ -159,8 +158,7 @@ App.Poll = Em.Object.extend({
       name: 'background_operations.get_by_request',
       sender: this,
       data: {
-        requestId: this.get('requestId'),
-        sync: false
+        requestId: this.get('requestId')
       },
       success: 'startPollingSuccessCallback',
       error: 'startPollingErrorCallback'

+ 8 - 0
ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js

@@ -57,6 +57,12 @@ App.WizardStep9HostLogPopupBodyView = Em.View.extend({
    */
   isEmptyList: true,
 
+  /**
+   * Is task logs loaded
+   * @type {Boolean}
+   */
+  isTaskLoaded: true,
+
   /**
    * Checks if no visible tasks are in popup
    * @method visibleTasks
@@ -159,6 +165,7 @@ App.WizardStep9HostLogPopupBodyView = Em.View.extend({
         tasksArr.push(taskInfo);
       }, this);
     }
+    this.set('isTaskLoaded', true);
     return tasksArr;
   }.property('parentView.c.logTasksChangesCounter'),
 
@@ -213,6 +220,7 @@ App.WizardStep9HostLogPopupBodyView = Em.View.extend({
       this.set("isLogWrapHidden", false);
       this.set('parentView.c.currentOpenTaskId', taskInfo.id);
       this.set('parentView.c.currentOpenTaskRequestId', taskInfo.requestId);
+      this.set('isTaskLoaded', false);
       this.get('parentView.c').loadCurrentTaskLog();
       $(".modal").scrollTop(0);
       $(".modal-body").scrollTop(0);