Repository: tez
Updated Branches:
  refs/heads/master b120e8e84 -> baa506557


TEZ-2878. Tez UI: AM error handling - Make the UI handle cases in which AM 
returns unexpected/no data (sree)


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

Branch: refs/heads/master
Commit: baa506557e1397f508959021419dfb2bb9ba50f7
Parents: b120e8e
Author: Sreenath Somarajapuram <s...@apache.org>
Authored: Thu Nov 5 07:35:28 2015 +0530
Committer: Sreenath Somarajapuram <s...@apache.org>
Committed: Thu Nov 5 07:35:28 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  1 +
 tez-ui/src/main/webapp/app/scripts/app.js       |  9 +++
 .../controllers/dag-task-attempts-controller.js | 22 ++----
 .../webapp/app/scripts/controllers/dag_tasks.js | 23 ++----
 .../app/scripts/controllers/dag_vertices.js     | 83 +++++++++-----------
 .../scripts/controllers/polling-controller.js   | 77 ++++++++++++++++++
 .../controllers/table-page-controller.js        | 10 ++-
 .../app/scripts/controllers/task_controller.js  | 13 +--
 .../task_task_attempts_controller.js            | 22 ++----
 .../scripts/controllers/vertex_controller.js    | 13 +--
 .../vertex_task_attempts_controller.js          | 22 ++----
 .../controllers/vertex_tasks_controller.js      | 22 ++----
 .../main/webapp/app/scripts/default-configs.js  |  3 +-
 .../scripts/helpers/entity-array-pollster.js    | 15 ++--
 .../src/main/webapp/app/scripts/helpers/misc.js |  1 +
 .../app/scripts/models/TimelineRestAdapter.js   | 23 ++++++
 .../src/main/webapp/app/scripts/models/dag.js   | 10 +++
 17 files changed, 202 insertions(+), 167 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 35528c2..4d63906 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -7,6 +7,7 @@ INCOMPATIBLE CHANGES
   TEZ-2679. Admin forms of launch env settings
 
 ALL CHANGES:
+  TEZ-2878. Tez UI: AM error handling - Make the UI handle cases in which AM 
returns unexpected/no data
   TEZ-2922. Tez Live UI gives access denied for admins
   TEZ-2849. Implement Specific Workaround for JDK-8026049 & JDK-8073093.
   TEZ-2828. Fix typo in "Shuffle assigned " log statement in 
shuffle.orderedgrouped.Shuffle.

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/app.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/app.js 
b/tez-ui/src/main/webapp/app/scripts/app.js
index 51d5ee8..5d7e28d 100644
--- a/tez-ui/src/main/webapp/app/scripts/app.js
+++ b/tez-ui/src/main/webapp/app/scripts/app.js
@@ -261,6 +261,14 @@ App.ready = function () {
     }
   });
 
+  App.ClusterAppAdapter = DS.RESTAdapter.extend({
+    host: App.env.RMWebUrl,
+    namespace: App.Configs.restNamespace.cluster,
+    pathForType: function() {
+      return 'apps';
+    }
+  });
+
 };
 
 $.ajaxPrefilter(function(options, originalOptions, jqXHR) {
@@ -283,6 +291,7 @@ require('scripts/router');
 require('scripts/views/**/*');
 require('scripts/models/**/*');
 
+require('scripts/controllers/polling-controller');
 require('scripts/controllers/table-page-controller');
 require('scripts/controllers/**/*');
 

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
----------------------------------------------------------------------
diff --git 
a/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
 
b/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
index eeddcb0..ade2c7f 100644
--- 
a/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
+++ 
b/tez-ui/src/main/webapp/app/scripts/controllers/dag-task-attempts-controller.js
@@ -27,16 +27,7 @@ App.DagTaskAttemptsController = 
App.TablePageController.extend({
 
   cacheDomain: Ember.computed.alias('controllers.dag.id'),
 
-  pollster: App.Helpers.EntityArrayPollster.create(),
-
-  init: function () {
-    this._super();
-    this.get('pollster').setProperties({
-      entityType: 'attemptInfo',
-      mergeProperties: ['status', 'progress'],
-      store: this.get('store')
-    });
-  },
+  pollingType: 'attemptInfo',
 
   pollsterControl: function () {
     if(this.get('status') == 'RUNNING' &&
@@ -52,21 +43,18 @@ App.DagTaskAttemptsController = 
App.TablePageController.extend({
   }.observes('status', 'amWebServiceVersion', 'rowsDisplayed', 'loading', 
'isActive'),
 
   pollsterOptionsObserver: function () {
-    var rows = this.get('rowsDisplayed');
-    this.set('pollster.targetRecords', rows);
-
-    this.set('pollster.options', (rows && rows.length) ? {
+    this.set('pollster.options', {
       appID: this.get('applicationId'),
       dagID: this.get('idx'),
       counters: this.get('countersDisplayed'),
-      attemptID: rows.map(function (row) {
+      attemptID: this.get('rowsDisplayed').map(function (row) {
           var attemptIndex = App.Helpers.misc.getIndexFromId(row.get('id')),
               taskIndex = App.Helpers.misc.getIndexFromId(row.get('taskID')),
               vertexIndex = 
App.Helpers.misc.getIndexFromId(row.get('vertexID'));
           return '%@_%@_%@'.fmt(vertexIndex, taskIndex, attemptIndex);
         }).join(',')
-    } : null);
-  }.observes('applicationId', 'idx', 'rowsDisplayed', 'counters'),
+    });
+  }.observes('applicationId', 'idx', 'rowsDisplayed'),
 
   countersDisplayed: function () {
     return App.Helpers.misc.getCounterQueryParam(this.get('columns'));

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js 
b/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
index 567b608..33a11d6 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/dag_tasks.js
@@ -17,7 +17,6 @@
  */
 
 App.DagTasksController = App.TablePageController.extend({
-
   controllerName: 'DagTasksController',
   needs: "dag",
 
@@ -27,16 +26,7 @@ App.DagTasksController = App.TablePageController.extend({
 
   cacheDomain: Ember.computed.alias('controllers.dag.id'),
 
-  pollster: App.Helpers.EntityArrayPollster.create(),
-
-  init: function () {
-    this._super();
-    this.get('pollster').setProperties({
-      entityType: 'taskInfo',
-      mergeProperties: ['status', 'progress'],
-      store: this.get('store')
-    });
-  },
+  pollingType: 'taskInfo',
 
   pollsterControl: function () {
     if(this.get('status') == 'RUNNING' &&
@@ -52,20 +42,17 @@ App.DagTasksController = App.TablePageController.extend({
   }.observes('status', 'amWebServiceVersion', 'rowsDisplayed', 'loading', 
'isActive'),
 
   pollsterOptionsObserver: function () {
-    var rows = this.get('rowsDisplayed');
-    this.set('pollster.targetRecords', rows);
-
-    this.set('pollster.options', (rows && rows.length) ? {
+    this.set('pollster.options', {
       appID: this.get('applicationId'),
       dagID: this.get('idx'),
       counters: this.get('countersDisplayed'),
-      taskID: rows.map(function (row) {
+      taskID: this.get('rowsDisplayed').map(function (row) {
           var taskIndex = App.Helpers.misc.getIndexFromId(row.get('id')),
           vertexIndex = App.Helpers.misc.getIndexFromId(row.get('vertexID'));
           return '%@_%@'.fmt(vertexIndex, taskIndex);
         }).join(',')
-    } : null);
-  }.observes('applicationId', 'idx', 'rowsDisplayed', 'counters'),
+    });
+  }.observes('applicationId', 'idx', 'rowsDisplayed'),
 
   countersDisplayed: function () {
     return App.Helpers.misc.getCounterQueryParam(this.get('columns'));

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/dag_vertices.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/dag_vertices.js 
b/tez-ui/src/main/webapp/app/scripts/controllers/dag_vertices.js
index 087eaa8..f25c59e 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/dag_vertices.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/dag_vertices.js
@@ -26,10 +26,36 @@ App.DagVerticesController = App.TablePageController.extend({
 
   cacheDomain: Ember.computed.alias('controllers.dag.id'),
 
-  pollster: {},
-  amInfoUpdateServiceObserver: function () {
-    this.set('pollster.isRunning', !!this.get('amInfoUpdateService'));
-  }.observes('amInfoUpdateService').on('init'),
+  pollingType: 'vertexInfo',
+
+  pollsterControl: function () {
+
+    if(this.get('status') == 'RUNNING' &&
+        this.get('amWebServiceVersion') != '1' &&
+        !this.get('loading') &&
+        this.get('isActive') &&
+        this. get('rowsDisplayed.length') > 0) {
+      this.get('pollster').start();
+    }
+    else {
+      this.get('pollster').stop();
+    }
+  }.observes('status', 'amWebServiceVersion', 'rowsDisplayed', 'loading', 
'isActive'),
+
+  pollsterOptionsObserver: function () {
+    this.set('pollster.options', {
+      appID: this.get('applicationId'),
+      dagID: this.get('idx'),
+      counters: this.get('countersDisplayed'),
+      vertexID: this.get('rowsDisplayed').map(function (row) {
+          return App.Helpers.misc.getIndexFromId(row.get('id'));
+        }).join(',')
+    });
+  }.observes('applicationId', 'idx', 'rowsDisplayed'),
+
+  countersDisplayed: function () {
+    return App.Helpers.misc.getCounterQueryParam(this.get('columns'));
+  }.property('columns'),
 
   beforeLoad: function () {
     var dagController = this.get('controllers.dag'),
@@ -84,38 +110,6 @@ App.DagVerticesController = App.TablePageController.extend({
     }
   },
 
-  _onColumnChange: function () {
-    App.set('vertexCounters', 
App.Helpers.misc.getCounterQueryParam(this.get('columns')));
-  }.observes('columns').on('init'),
-
-  overlayVertexInfo: function(vertex, amVertexInfo) {
-    if (Em.isNone(amVertexInfo) || Em.isNone(vertex)) return;
-    amVertexInfo.set('_amInfoLastUpdatedTime', moment());
-
-    var props = ['progress', '_amInfoLastUpdatedTime']; 
-    if (this.get('controllers.dag.amWebServiceVersion') != '1') {
-      // status is not available for v1 version.
-      props.push('status')
-    }
-    var propValues = amVertexInfo.getProperties(props);
-    propValues['counterGroups'] = 
App.Helpers.misc.mergeCounterInfo(vertex.get('counterGroups'),
-                                    amVertexInfo.get('counters')).slice(0);
-    vertex.setProperties(propValues);
-
-    Em.tryInvoke(vertex, 'didLoad');
-  },
-
-  updateVertexInfo: function() {
-    var amVertexInfo = this.get('controllers.dag.amVertexInfo');
-    var vertices = this.get('data');
-    var that = this;
-    if (amVertexInfo && vertices) {
-      amVertexInfo.forEach(function(item) {
-        that.overlayVertexInfo(vertices.findBy('id', item.get('id')), item);
-      });
-    }
-  }.observes('controllers.dag.amVertexInfo', 'data'),
-
   defaultColumnConfigs: function() {
     function onProgressChange() {
       var progress = this.get('vertex.progress'),
@@ -157,18 +151,13 @@ App.DagVerticesController = 
App.TablePageController.extend({
         headerCellName: 'Status',
         templateName: 'components/basic-table/status-cell',
         contentPath: 'status',
+        observePath: true,
         getCellContent: function(row) {
-          var status = row.get('status'),
-              content = Ember.Object.create({
-                vertex: row,
-              });
-          if(status == 'RUNNING') {
-            row.addObserver('_amInfoLastUpdatedTime', content, 
onProgressChange);
-            row.addObserver('progress', content, onProgressChange);
-            row.addObserver('status', content, onProgressChange);
-          }
-          onProgressChange.call(content);
-          return content;
+          var status = row.get('status');
+          return {
+            status: status,
+            statusIcon: App.Helpers.misc.getStatusClassForEntity(status)
+          };
         }
       },
       {

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/polling-controller.js
----------------------------------------------------------------------
diff --git 
a/tez-ui/src/main/webapp/app/scripts/controllers/polling-controller.js 
b/tez-ui/src/main/webapp/app/scripts/controllers/polling-controller.js
new file mode 100644
index 0000000..c15db57
--- /dev/null
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/polling-controller.js
@@ -0,0 +1,77 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+var DEFAULT_MERGE_PROPS = ['status', 'progress'];
+
+App.PollingController = Em.ObjectController.extend({
+
+  pollster: null,
+  pollingEnabled: false,
+
+  pollingType: null,
+  pollingOptions: null,
+
+  init: function () {
+    this._super();
+    this.set('pollster', App.Helpers.EntityArrayPollster.create({
+      store: this.get('store'),
+
+      mergeProperties: DEFAULT_MERGE_PROPS,
+      entityType: this.get('pollingType'),
+      options: this.get('pollingOptions'),
+
+      onFailure: this.onPollingFailure.bind(this)
+    }));
+  },
+
+  onPollingFailure: function (error) {
+    var appID = this.get('pollster.options.appID'),
+        that = this;
+
+    App.Helpers.misc.removeRecord(this.get('store'), 'clusterApp', appID);
+    this.get('store').find('clusterApp', appID).then(function (app) {
+      if(app.get('isComplete')) {
+        that.get('pollster').stop();
+        that.applicationComplete();
+      }
+      else {
+        error.message = "Application Master (AM) is out of reach. Either it's 
down, or CORS is not enabled.";
+        that.applicationFailed(error);
+      }
+    }).catch(function (error) {
+      that.get('pollster').stop();
+      error.message = "Resource Manager (RM) is out of reach. Either it's 
down, or CORS is not enabled.";
+      that.applicationFailed(error);
+    });
+  },
+
+  applicationComplete: function () {
+    if(this.load) {
+      this.load();
+    }
+  },
+
+  applicationFailed: function (error) {
+    // TODO: TEZ-2877 - #1
+    Em.Logger.error(error);
+    var err = App.Helpers.misc.formatError(error, error.message);
+    var msg = 'Error code: %@, message: %@'.fmt(err.errCode, err.msg);
+    App.Helpers.ErrorBar.getInstance().show(msg, err.details);
+  }
+
+});

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/table-page-controller.js
----------------------------------------------------------------------
diff --git 
a/tez-ui/src/main/webapp/app/scripts/controllers/table-page-controller.js 
b/tez-ui/src/main/webapp/app/scripts/controllers/table-page-controller.js
index dc66d7d..a91dafc 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/table-page-controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/table-page-controller.js
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-App.TablePageController = Em.ObjectController.extend(
+App.TablePageController = App.PollingController.extend(
     App.DataArrayLoaderMixin,
     App.ColumnSelectorMixin, {
       queryParams: ['pageNum', 'rowCount', 'searchText', 'sortColumnId', 
'sortOrder'],
@@ -42,6 +42,14 @@ App.TablePageController = Em.ObjectController.extend(
         this.set('isActive', false);
       },
 
+      rowsDisplayedObserver: function () {
+        this.set('pollster.targetRecords', this.get('rowsDisplayed'));
+      }.observes('rowsDisplayed', 'pollster'),
+
+      applicationComplete: function () {
+        this.loadData(true);
+      },
+
       statusMessage: function () {
         return this.get('loading') ? "Loading all records..." : null;
       }.property('loading'),

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js 
b/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js
index 9a4476c..564b529 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/task_controller.js
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-App.TaskController = Em.ObjectController.extend(App.Helpers.DisplayHelper, 
App.ModelRefreshMixin, {
+App.TaskController = App.PollingController.extend(App.Helpers.DisplayHelper, 
App.ModelRefreshMixin, {
   controllerName: 'TaskController',
 
   pageTitle: 'Task',
@@ -25,16 +25,7 @@ App.TaskController = 
Em.ObjectController.extend(App.Helpers.DisplayHelper, App.M
 
   isActive: false,
 
-  pollster: App.Helpers.EntityArrayPollster.create(),
-
-  init: function () {
-    this._super();
-    this.get('pollster').setProperties({
-      entityType: 'taskInfo',
-      mergeProperties: ['status', 'progress'],
-      store: this.get('store')
-    });
-  },
+  pollingType: 'taskInfo',
 
   setup: function () {
     this.set('isActive', true);

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
----------------------------------------------------------------------
diff --git 
a/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
 
b/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
index 87504e2..eef2a4a 100644
--- 
a/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
+++ 
b/tez-ui/src/main/webapp/app/scripts/controllers/task_task_attempts_controller.js
@@ -28,16 +28,7 @@ App.TaskAttemptsController = 
App.TablePageController.extend(App.AutoCounterColum
 
   cacheDomain: Ember.computed.alias('controllers.task.dagID'),
 
-  pollster: App.Helpers.EntityArrayPollster.create(),
-
-  init: function () {
-    this._super();
-    this.get('pollster').setProperties({
-      entityType: 'attemptInfo',
-      mergeProperties: ['status', 'progress'],
-      store: this.get('store')
-    });
-  },
+  pollingType: 'attemptInfo',
 
   pollsterControl: function () {
     if(this.get('vertex.dag.status') == 'RUNNING' &&
@@ -54,21 +45,18 @@ App.TaskAttemptsController = 
App.TablePageController.extend(App.AutoCounterColum
     'vertex.dag.amWebServiceVersion', 'rowsDisplayed', 'loading', 'isActive'),
 
   pollsterOptionsObserver: function () {
-    var rows = this.get('rowsDisplayed');
-    this.set('pollster.targetRecords', rows);
-
-    this.set('pollster.options', (rows && rows.length) ? {
+    this.set('pollster.options', {
       appID: this.get('vertex.dag.applicationId'),
       dagID: this.get('vertex.dag.idx'),
       counters: this.get('countersDisplayed'),
-      attemptID: rows.map(function (row) {
+      attemptID: this.get('rowsDisplayed').map(function (row) {
           var attemptIndex = App.Helpers.misc.getIndexFromId(row.get('id')),
               taskIndex = App.Helpers.misc.getIndexFromId(row.get('taskID')),
               vertexIndex = 
App.Helpers.misc.getIndexFromId(row.get('vertexID'));
           return '%@_%@_%@'.fmt(vertexIndex, taskIndex, attemptIndex);
         }).join(',')
-    } : null);
-  }.observes('vertex.dag.applicationId', 'vertex.dag.idx', 'rowsDisplayed', 
'counters'),
+    });
+  }.observes('vertex.dag.applicationId', 'vertex.dag.idx', 'rowsDisplayed'),
 
   countersDisplayed: function () {
     return App.Helpers.misc.getCounterQueryParam(this.get('columns'));

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js
----------------------------------------------------------------------
diff --git 
a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js 
b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js
index 4cc4797..a7b8ac7 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_controller.js
@@ -16,7 +16,7 @@
  * limitations under the License.
  */
 
-App.VertexController = Em.ObjectController.extend(App.Helpers.DisplayHelper, 
App.ModelRefreshMixin, {
+App.VertexController = App.PollingController.extend(App.Helpers.DisplayHelper, 
App.ModelRefreshMixin, {
   controllerName: 'VertexController',
 
   pageTitle: 'Vertex',
@@ -24,16 +24,7 @@ App.VertexController = 
Em.ObjectController.extend(App.Helpers.DisplayHelper, App
   loading: true,
   isActive: false,
 
-  pollster: App.Helpers.EntityArrayPollster.create(),
-
-  init: function () {
-    this._super();
-    this.get('pollster').setProperties({
-      entityType: 'vertexInfo',
-      mergeProperties: ['status', 'progress'],
-      store: this.get('store')
-    });
-  },
+  pollingType: 'vertexInfo',
 
   setup: function () {
     this.set('isActive', true);

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
----------------------------------------------------------------------
diff --git 
a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
 
b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
index b6d659d..f9fa086 100644
--- 
a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
+++ 
b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_task_attempts_controller.js
@@ -28,16 +28,7 @@ App.VertexTaskAttemptsController = 
App.TablePageController.extend(App.AutoCounte
 
   cacheDomain: Ember.computed.alias('controllers.vertex.dagID'),
 
-  pollster: App.Helpers.EntityArrayPollster.create(),
-
-  init: function () {
-    this._super();
-    this.get('pollster').setProperties({
-      entityType: 'attemptInfo',
-      mergeProperties: ['status', 'progress'],
-      store: this.get('store')
-    });
-  },
+  pollingType: 'attemptInfo',
 
   pollsterControl: function () {
     if(this.get('dag.status') == 'RUNNING' &&
@@ -53,21 +44,18 @@ App.VertexTaskAttemptsController = 
App.TablePageController.extend(App.AutoCounte
   }.observes('dag.status', 'dag.amWebServiceVersion', 'rowsDisplayed', 
'loading', 'isActive'),
 
   pollsterOptionsObserver: function () {
-    var rows = this.get('rowsDisplayed');
-    this.set('pollster.targetRecords', rows);
-
-    this.set('pollster.options', (rows && rows.length) ? {
+    this.set('pollster.options', {
       appID: this.get('dag.applicationId'),
       dagID: this.get('dag.idx'),
       counters: this.get('countersDisplayed'),
-      attemptID: rows.map(function (row) {
+      attemptID: this.get('rowsDisplayed').map(function (row) {
           var attemptIndex = App.Helpers.misc.getIndexFromId(row.get('id')),
               taskIndex = App.Helpers.misc.getIndexFromId(row.get('taskID')),
               vertexIndex = 
App.Helpers.misc.getIndexFromId(row.get('vertexID'));
           return '%@_%@_%@'.fmt(vertexIndex, taskIndex, attemptIndex);
         }).join(',')
-    } : null);
-  }.observes('dag.applicationId', 'dag.idx', 'rowsDisplayed', 'counters'),
+    });
+  }.observes('dag.applicationId', 'dag.idx', 'rowsDisplayed'),
 
   countersDisplayed: function () {
     return App.Helpers.misc.getCounterQueryParam(this.get('columns'));

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js
----------------------------------------------------------------------
diff --git 
a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js 
b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js
index c4d09f4..5ffa185 100644
--- a/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js
+++ b/tez-ui/src/main/webapp/app/scripts/controllers/vertex_tasks_controller.js
@@ -28,16 +28,7 @@ App.VertexTasksController = 
App.TablePageController.extend(App.AutoCounterColumn
 
   cacheDomain: Ember.computed.alias('controllers.vertex.dagID'),
 
-  pollster: App.Helpers.EntityArrayPollster.create(),
-
-  init: function () {
-    this._super();
-    this.get('pollster').setProperties({
-      entityType: 'taskInfo',
-      mergeProperties: ['status', 'progress'],
-      store: this.get('store')
-    });
-  },
+  pollingType: 'taskInfo',
 
   pollsterControl: function () {
     if(this.get('dag.status') == 'RUNNING' &&
@@ -52,20 +43,17 @@ App.VertexTasksController = 
App.TablePageController.extend(App.AutoCounterColumn
   }.observes('dag.status', 'dag.amWebServiceVersion', 'rowsDisplayed', 
'loading', 'isActive'),
 
   pollsterOptionsObserver: function () {
-    var rows = this.get('rowsDisplayed');
-    this.set('pollster.targetRecords', rows);
-
-    this.set('pollster.options', (rows && rows.length) ? {
+    this.set('pollster.options', {
       appID: this.get('dag.applicationId'),
       dagID: this.get('dag.idx'),
       counters: this.get('countersDisplayed'),
-      taskID: rows.map(function (row) {
+      taskID: this.get('rowsDisplayed').map(function (row) {
           var taskIndex = App.Helpers.misc.getIndexFromId(row.get('id')),
           vertexIndex = App.Helpers.misc.getIndexFromId(row.get('vertexID'));
           return '%@_%@'.fmt(vertexIndex, taskIndex);
         }).join(',')
-    } : null);
-  }.observes('dag.applicationId', 'dag.idx', 'rowsDisplayed', 'counters'),
+    });
+  }.observes('dag.applicationId', 'dag.idx', 'rowsDisplayed'),
 
   countersDisplayed: function () {
     return App.Helpers.misc.getCounterQueryParam(this.get('columns'));

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/default-configs.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/default-configs.js 
b/tez-ui/src/main/webapp/app/scripts/default-configs.js
index 13867d8..93556aa 100644
--- a/tez-ui/src/main/webapp/app/scripts/default-configs.js
+++ b/tez-ui/src/main/webapp/app/scripts/default-configs.js
@@ -49,7 +49,8 @@ $.extend(true, App.Configs, {
     timeline: 'ws/v1/timeline',
     applicationHistory: 'ws/v1/applicationhistory',
     aminfo: 'proxy/__app_id__/ws/v1/tez',
-    aminfoV2: 'proxy/__app_id__/ws/v2/tez'
+    aminfoV2: 'proxy/__app_id__/ws/v2/tez',
+    cluster: 'ws/v1/cluster'
   },
 
   tables: {

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js
----------------------------------------------------------------------
diff --git 
a/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js 
b/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js
index d7f4aa4..31181be 100644
--- a/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js
+++ b/tez-ui/src/main/webapp/app/scripts/helpers/entity-array-pollster.js
@@ -29,8 +29,11 @@ App.Helpers.EntityArrayPollster = 
App.Helpers.Pollster.extend({
   targetRecords: [],
 
   _ready: function () {
-    return this.get('entityType') && this.get('store') && this.get('options');
-  }.property('entityType', 'store', 'options'),
+    return this.get('entityType') &&
+        this.get('store') &&
+        this.get('options') &&
+        this.get('targetRecords.length');
+  }.property('entityType', 'store', 'options', 'targetRecords.length'),
 
   start: function(interval) {
     if(!this.get('isRunning')) {
@@ -46,7 +49,6 @@ App.Helpers.EntityArrayPollster = 
App.Helpers.Pollster.extend({
   },
 
   stop: function() {
-    this.set('amProgressInfoSucceededOnce', false);
     if(this.get('isRunning')) {
       Ember.run.cancel(this.get('timer'));
       this.set('isRunning', false);
@@ -79,19 +81,12 @@ App.Helpers.EntityArrayPollster = 
App.Helpers.Pollster.extend({
   },
 
   onResponse: function (data) {
-    this.set('amProgressInfoSucceededOnce', true);
     this.set('polledRecords', data);
     this.mergeToTarget();
   },
 
   onFailure: function (err) {
     // Implement based on requirement
-    if (this.get('amProgressInfoSucceededOnce') === true) {
-      this.set('amProgressInfoSucceededOnce', false);
-      App.Helpers.ErrorBar.getInstance().show(
-        "Failed to get in-progress status. Manually refresh to get the updated 
status",
-        "Application Manager either exited or is not running.");
-    }
   },
 
   _final: function () {

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/helpers/misc.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/helpers/misc.js 
b/tez-ui/src/main/webapp/app/scripts/helpers/misc.js
index ddd7d6a..d6bd67a 100644
--- a/tez-ui/src/main/webapp/app/scripts/helpers/misc.js
+++ b/tez-ui/src/main/webapp/app/scripts/helpers/misc.js
@@ -448,6 +448,7 @@ App.Helpers.misc = {
    * @param type {String}
    * @param id {String}
    */
+  //TODO: TEZ-2876 Extend store to have a loadRecord function that skips the 
cache
   removeRecord: function (store, type, id) {
     var record = store.getById(type, id);
     if(record) {

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js 
b/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js
index 9a79851..e7fe876 100644
--- a/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js
+++ b/tez-ui/src/main/webapp/app/scripts/models/TimelineRestAdapter.js
@@ -598,3 +598,26 @@ App.AttemptInfoSerializer = DS.RESTSerializer.extend({
     }
   }
 });
+
+App.ClusterAppSerializer = App.TimelineSerializer.extend({
+  map: {
+    id: 'id',
+    status: 'state',
+    finalStatus: 'finalStatus'
+  },
+
+  _normalizeSingleDagPayload: function(rawPayload) {
+    return {
+      clusterApp: rawPayload.clusterApp.app
+    }
+  },
+
+  normalizePayload: function(rawPayload){
+    // we handled only single clusterApp
+    return this._normalizeSingleDagPayload(rawPayload);
+  },
+
+  normalize: function(type, hash, prop) {
+    return Em.JsonMapper.map(hash, this.get('map'));
+  }
+});

http://git-wip-us.apache.org/repos/asf/tez/blob/baa50655/tez-ui/src/main/webapp/app/scripts/models/dag.js
----------------------------------------------------------------------
diff --git a/tez-ui/src/main/webapp/app/scripts/models/dag.js 
b/tez-ui/src/main/webapp/app/scripts/models/dag.js
index 6e6362a..a21b983 100644
--- a/tez-ui/src/main/webapp/app/scripts/models/dag.js
+++ b/tez-ui/src/main/webapp/app/scripts/models/dag.js
@@ -342,6 +342,16 @@ App.TezApp = App.AbstractEntity.extend({
   tezVersion: DS.attr('string'),
 });
 
+App.ClusterApp = App.AbstractEntity.extend({
+  status: DS.attr('string'),
+  finalStatus: DS.attr('string'),
+
+  isComplete: function () {
+    var status = this.get('status');
+    return status == 'FINISHED' || status == 'FAILED' || status == 'KILLED';
+  }.property('status')
+});
+
 App.Task = App.AbstractEntity.extend({
   status: DS.attr('string'),
 

Reply via email to