ambari-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From atk...@apache.org
Subject git commit: AMBARI-6156 Change calls which request logs to asynchronous. (atkach)
Date Tue, 17 Jun 2014 12:12:36 GMT
Repository: ambari
Updated Branches:
  refs/heads/trunk d54c9632f -> b642840c0


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


Project: http://git-wip-us.apache.org/repos/asf/ambari/repo
Commit: http://git-wip-us.apache.org/repos/asf/ambari/commit/b642840c
Tree: http://git-wip-us.apache.org/repos/asf/ambari/tree/b642840c
Diff: http://git-wip-us.apache.org/repos/asf/ambari/diff/b642840c

Branch: refs/heads/trunk
Commit: b642840c035040b0733772d9335753dd9b330121
Parents: d54c963
Author: atkach <atkach@hortonworks.com>
Authored: Tue Jun 17 15:10:26 2014 +0300
Committer: atkach <atkach@hortonworks.com>
Committed: Tue Jun 17 15:10:26 2014 +0300

----------------------------------------------------------------------
 .../global/background_operations_controller.js  | 24 +++++--
 .../app/controllers/wizard/step9_controller.js  |  3 +-
 .../templates/common/host_progress_popup.hbs    | 76 +++++++++++---------
 .../wizard/step9/step9HostTasksLogPopup.hbs     | 24 ++++---
 ambari-web/app/utils/ajax/ajax.js               | 14 +---
 ambari-web/app/utils/host_progress_popup.js     | 56 ++++++++-------
 ambari-web/app/utils/polling.js                 |  6 +-
 .../views/wizard/step9/hostLogPopupBody_view.js |  8 +++
 8 files changed, 115 insertions(+), 96 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/b642840c/ambari-web/app/controllers/global/background_operations_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/global/background_operations_controller.js b/ambari-web/app/controllers/global/background_operations_controller.js
index 933a413..99cc81f 100644
--- a/ambari-web/app/controllers/global/background_operations_controller.js
+++ b/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;
   },
 

http://git-wip-us.apache.org/repos/asf/ambari/blob/b642840c/ambari-web/app/controllers/wizard/step9_controller.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/controllers/wizard/step9_controller.js b/ambari-web/app/controllers/wizard/step9_controller.js
index 4228f2f..88a3e0a 100644
--- a/ambari-web/app/controllers/wizard/step9_controller.js
+++ b/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'

http://git-wip-us.apache.org/repos/asf/ambari/blob/b642840c/ambari-web/app/templates/common/host_progress_popup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/common/host_progress_popup.hbs b/ambari-web/app/templates/common/host_progress_popup.hbs
index 3903d36..0c83dfd 100644
--- a/ambari-web/app/templates/common/host_progress_popup.hbs
+++ b/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>

http://git-wip-us.apache.org/repos/asf/ambari/blob/b642840c/ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs
----------------------------------------------------------------------
diff --git a/ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs b/ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs
index 2671bbb..138d784 100644
--- a/ambari-web/app/templates/wizard/step9/step9HostTasksLogPopup.hbs
+++ b/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}}

http://git-wip-us.apache.org/repos/asf/ambari/blob/b642840c/ambari-web/app/utils/ajax/ajax.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/ajax/ajax.js b/ambari-web/app/utils/ajax/ajax.js
index 60f5aa4..f2428db 100644
--- a/ambari-web/app/utils/ajax/ajax.js
+++ b/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}',

http://git-wip-us.apache.org/repos/asf/ambari/blob/b642840c/ambari-web/app/utils/host_progress_popup.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/host_progress_popup.js b/ambari-web/app/utils/host_progress_popup.js
index d47f056..6b0efd0 100644
--- a/ambari-web/app/utils/host_progress_popup.js
+++ b/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"),
 
         /**
@@ -681,26 +703,6 @@ App.HostPopup = Em.Object.create({
         },
 
         /**
-         * 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
          */
         updateSelectView: 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'));

http://git-wip-us.apache.org/repos/asf/ambari/blob/b642840c/ambari-web/app/utils/polling.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/utils/polling.js b/ambari-web/app/utils/polling.js
index a0281a8..13b3a63 100644
--- a/ambari-web/app/utils/polling.js
+++ b/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'

http://git-wip-us.apache.org/repos/asf/ambari/blob/b642840c/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js
----------------------------------------------------------------------
diff --git a/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js b/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js
index f0c0785..daa35b2 100644
--- a/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js
+++ b/ambari-web/app/views/wizard/step9/hostLogPopupBody_view.js
@@ -58,6 +58,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);


Mime
View raw message