You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@ambari.apache.org by ak...@apache.org on 2014/08/27 14:58:06 UTC

git commit: AMBARI-7035. Views: Jobs view support for existing ATS. (akovalenko)

Repository: ambari
Updated Branches:
  refs/heads/trunk a82633457 -> 61695fa43


AMBARI-7035. Views: Jobs view support for existing ATS. (akovalenko)


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

Branch: refs/heads/trunk
Commit: 61695fa43735b12a08b15af9504210ac6c9a0bf2
Parents: a826334
Author: Aleksandr Kovalenko <ak...@hortonworks.com>
Authored: Wed Aug 27 15:55:38 2014 +0300
Committer: Aleksandr Kovalenko <ak...@hortonworks.com>
Committed: Wed Aug 27 15:55:38 2014 +0300

----------------------------------------------------------------------
 .../src/main/resources/ui/app/scripts/app.js    |  2 +-
 .../app/scripts/controllers/job_controller.js   |  2 +-
 .../app/scripts/controllers/jobs_controller.js  | 14 ++--
 .../resources/ui/app/scripts/helpers/ajax.js    | 17 +++--
 .../resources/ui/app/scripts/helpers/jobs.js    | 78 +++++++++-----------
 .../mappers/application_status_mapper.js        | 47 ++++++++++++
 contrib/views/jobs/src/main/resources/view.xml  | 10 +++
 7 files changed, 111 insertions(+), 59 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/ambari/blob/61695fa4/contrib/views/jobs/src/main/resources/ui/app/scripts/app.js
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/src/main/resources/ui/app/scripts/app.js b/contrib/views/jobs/src/main/resources/ui/app/scripts/app.js
index 3ab2c30..2ae6d20 100644
--- a/contrib/views/jobs/src/main/resources/ui/app/scripts/app.js
+++ b/contrib/views/jobs/src/main/resources/ui/app/scripts/app.js
@@ -55,7 +55,7 @@ App.initializer({
 
     });
 
-    application.ApplicationStatusMapper.getClusterName();
+    application.ApplicationStatusMapper.getInstanceParameters();
 
   }
 });

http://git-wip-us.apache.org/repos/asf/ambari/blob/61695fa4/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/job_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/job_controller.js b/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/job_controller.js
index f1125d9..dbf3a4f 100644
--- a/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/job_controller.js
+++ b/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/job_controller.js
@@ -71,7 +71,7 @@ App.JobController = Ember.ObjectController.extend(App.RunPeriodically, {
       timeout = this.get('loadTimeout'),
       yarnService = App.HiveJob.store.getById('service', 'YARN'),
       content = this.get('content');
-    if (!Em.isNone(yarnService)) {
+    if (!Em.isNone(yarnService) || App.get('atsURL')) {
       if (!Em.isNone(content)) {
         App.Helpers.jobs.refreshJobDetails(
           content,

http://git-wip-us.apache.org/repos/asf/ambari/blob/61695fa4/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/jobs_controller.js
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/jobs_controller.js b/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/jobs_controller.js
index d96f598..16acb56 100644
--- a/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/jobs_controller.js
+++ b/contrib/views/jobs/src/main/resources/ui/app/scripts/controllers/jobs_controller.js
@@ -557,11 +557,11 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
    */
   checkDataLoadingError: function (jqXHR) {
     var atsComponent = App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER');
-    if (atsComponent && atsComponent.get('workStatus') != "STARTED") {
+    if (!App.get('atsURL') && atsComponent && atsComponent.get('workStatus') != "STARTED") {
       this.set('jobsMessage', Em.I18n.t('jobs.error.ats.down'));
     }
     else {
-      if (jqXHR && jqXHR.status == 400) {
+      if (jqXHR && (jqXHR.status == 400 || jqXHR.status == 404)) {
         this.set('jobsMessage', Em.I18n.t('jobs.error.400'));
       }
       else {
@@ -584,15 +584,14 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
       atsComponent = App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER'),
       atsInValidState = !!atsComponent && atsComponent.get('workStatus') === "STARTED";
     this.checkDataLoadingError();
-    if (!Em.isNone(yarnService) && atsInValidState) {
+    if (App.get('atsURL') || (!Em.isNone(yarnService) && atsInValidState)) {
       this.set('loading', true);
-      var historyServerHostName = atsComponent.get('hostName');
+      var atsURL = App.get('atsURL') || 'http://' + atsComponent.get('hostName') + ':' + yarnService.get('ahsWebPort');
       App.ajax.send({
         name: 'jobs_lastID',
         sender: this,
         data: {
-          historyServerHostName: historyServerHostName,
-          ahsWebPort: yarnService.get('ahsWebPort')
+          atsURL: atsURL
         },
         success: 'lastIDSuccessCallback',
         error : 'lastIDErrorCallback'
@@ -601,8 +600,7 @@ App.JobsController = Ember.ArrayController.extend(App.RunPeriodically, {
         name: 'load_jobs',
         sender: this,
         data: {
-          historyServerHostName: historyServerHostName,
-          ahsWebPort: yarnService.get('ahsWebPort'),
+          atsURL: atsURL,
           filtersLink: this.get('filterObject').createJobsFiltersLink()
         },
         success: 'loadJobsSuccessCallback',

http://git-wip-us.apache.org/repos/asf/ambari/blob/61695fa4/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/ajax.js
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/ajax.js b/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/ajax.js
index e0eacf5..e648e61 100644
--- a/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/ajax.js
+++ b/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/ajax.js
@@ -31,37 +31,37 @@
 var urls = {
 
   'load_jobs': {
-    real: '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/HIVE_QUERY_ID{filtersLink}',
+    real: '/proxy?url={atsURL}/ws/v1/timeline/HIVE_QUERY_ID{filtersLink}',
     mock: '/scripts/assets/hive-queries.json',
     apiPrefix: ''
   },
 
   'jobs_lastID': {
-    real: '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/HIVE_QUERY_ID?limit=1&secondaryFilter=tez:true',
+    real: '/proxy?url={atsURL}/ws/v1/timeline/HIVE_QUERY_ID?limit=1&secondaryFilter=tez:true',
     mock: '/scripts/assets/hive-queries.json',
     apiPrefix: ''
   },
 
   'job_details': {
-    real: '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/HIVE_QUERY_ID/{job_id}?fields=events,otherinfo',
+    real: '/proxy?url={atsURL}/ws/v1/timeline/HIVE_QUERY_ID/{job_id}?fields=events,otherinfo',
     mock: '/scripts/assets/hive-query-2.json',
     apiPrefix: ''
   },
 
   'jobs.tezDag.NametoID': {
-    'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
+    'real': '/proxy?url={atsURL}/ws/v1/timeline/TEZ_DAG_ID?primaryFilter=dagName:{tezDagName}',
     'mock': '/scripts/assets/tezDag-name-to-id.json',
     'apiPrefix': ''
   },
 
   'jobs.tezDag.tezDagId': {
-    'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities,otherinfo',
+    'real': '/proxy?url={atsURL}/ws/v1/timeline/TEZ_DAG_ID/{tezDagId}?fields=relatedentities,otherinfo',
     'mock': '/scripts/assets/tezDag.json',
     'apiPrefix': ''
   },
 
   'jobs.tezDag.tezDagVertexId': {
-    'real': '/proxy?url=http://{historyServerHostName}:{ahsWebPort}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
+    'real': '/proxy?url={atsURL}/ws/v1/timeline/TEZ_VERTEX_ID/{tezDagVertexId}?fields=otherinfo',
     'mock': '/scripts/assets/tezDagVertex.json',
     'apiPrefix': ''
   },
@@ -94,6 +94,11 @@ var urls = {
   'configurations': {
     real: 'clusters/{clusterName}/configurations?{params}',
     mock: '/scripts/assets/configurations.json'
+  },
+
+  'instance_parameters': {
+    real: 'views/{view}/versions/{version}/instances/{instanceName}',
+    mock: ''
   }
 
 };

http://git-wip-us.apache.org/repos/asf/ambari/blob/61695fa4/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/jobs.js
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/jobs.js b/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/jobs.js
index 9255603..f0759da 100644
--- a/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/jobs.js
+++ b/contrib/views/jobs/src/main/resources/ui/app/scripts/helpers/jobs.js
@@ -45,16 +45,14 @@ App.Helpers.jobs = {
    * @method refreshHiveJobDetails
    */
   refreshHiveJobDetails: function (hiveJob, successCallback, errorCallback) {
-    var yarnService = App.HiveJob.store.getById('service', 'YARN'),
-      historyServerHostName = App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER').get('hostName'),
-      ahsWebPort = yarnService.get('ahsWebPort');
+    var  atsURL = App.get('atsURL') || 'http://' + App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER').get('hostName') +
+        ':' + App.HiveJob.store.getById('service', 'YARN').get('ahsWebPort');
 
     return App.ajax.send({
       name: 'job_details',
       sender: this,
       data: {
-        historyServerHostName: historyServerHostName,
-        ahsWebPort: ahsWebPort,
+        atsURL: atsURL,
         job_id: hiveJob.get('id'),
         successCallback: successCallback,
         errorCallback: errorCallback
@@ -89,9 +87,8 @@ App.Helpers.jobs = {
         name: 'jobs.tezDag.NametoID',
         sender: sender,
         data: {
-          historyServerHostName: params.historyServerHostName,
-          tezDagName: tezDagName,
-          ahsWebPort: params.ahsWebPort
+          atsURL: params.atsURL,
+          tezDagName: tezDagName
         },
         success: 'dagNameToIdSuccess',
         error: 'dagNameToIdError'
@@ -113,45 +110,43 @@ App.Helpers.jobs = {
    */
   refreshTezDagDetails: function (tezDagId, successCallback, errorCallback) {
     var self = this,
-      yarnService = App.HiveJob.store.getById('service', 'YARN'),
-      historyServerHostName = App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER').get('hostName'),
-      resourceManagerHostName = App.HiveJob.store.getById('component', 'RESOURCEMANAGER').get('hostName'),
-      ahsWebPort = yarnService.get('ahsWebPort'),
-      tezDag = App.HiveJob.store.getById('tezDag', tezDagId);
+        atsURL = App.get('atsURL') || 'http://' + App.HiveJob.store.getById('component', 'RESOURCEMANAGER').get('hostName') + ':' + App.HiveJob.store.getById('service', 'YARN').get('ahsWebPort'),
+        resourceManager = App.HiveJob.store.getById('component', 'RESOURCEMANAGER'),
+        resourceManagerHostName = App.get('resourceManagerURL') || (resourceManager && 'http://' + resourceManager.get('hostName') + ':8088') || '',
+        tezDag = App.HiveJob.store.getById('tezDag', tezDagId);
     if (tezDag) {
       var tezDagInstanceId = tezDag.get('instanceId'),
-        sender = {
-          loadTezDagSuccess: function (data) {
-            if (data) {
-              var app_id = Em.get(data, 'otherinfo.applicationId');
-              if (!Em.isNone(app_id)) {
-                tezDag.set('yarnApplicationId', app_id);
-                tezDag.set('yarnApplicationLink', 'http://'+resourceManagerHostName+':8088/cluster/app/'+app_id);
-              }
-              if (data.relatedentities && data.relatedentities.TEZ_VERTEX_ID != null) {
-                var count = data.relatedentities.TEZ_VERTEX_ID.length;
-                data.relatedentities.TEZ_VERTEX_ID.forEach(function (v) {
-                  self.refreshTezDagVertex(tezDagId, v, function () {
-                    if (--count <= 0) {
-                      // all vertices succeeded
-                      successCallback();
-                    }
+          sender = {
+            loadTezDagSuccess: function (data) {
+              if (data) {
+                var app_id = Em.get(data, 'otherinfo.applicationId');
+                if (app_id && resourceManagerHostName) {
+                  tezDag.set('yarnApplicationId', app_id);
+                  tezDag.set('yarnApplicationLink', resourceManagerHostName + '/cluster/app/' + app_id);
+                }
+                if (data.relatedentities && data.relatedentities.TEZ_VERTEX_ID != null) {
+                  var count = data.relatedentities.TEZ_VERTEX_ID.length;
+                  data.relatedentities.TEZ_VERTEX_ID.forEach(function (v) {
+                    self.refreshTezDagVertex(tezDagId, v, function () {
+                      if (--count <= 0) {
+                        // all vertices succeeded
+                        successCallback();
+                      }
+                    });
                   });
-                });
+                }
               }
+            },
+            loadTezDagError: function () {
+              errorCallback('job.dag.id.loaderror');
             }
-          },
-          loadTezDagError: function () {
-            errorCallback('job.dag.id.loaderror');
-          }
-        };
+          };
       App.ajax.send({
         name: 'jobs.tezDag.tezDagId',
         sender: sender,
         data: {
-          historyServerHostName: historyServerHostName,
           tezDagId: tezDagInstanceId,
-          ahsWebPort: ahsWebPort
+          atsURL: atsURL
         },
         success: 'loadTezDagSuccess',
         error: 'loadTezDagError'
@@ -171,9 +166,7 @@ App.Helpers.jobs = {
    * @method refreshTezDagVertex
    */
   refreshTezDagVertex: function (tezDagId, tezVertexInstanceId, successCallback) {
-    var yarnService = App.HiveJob.store.getById('service', 'YARN'),
-      historyServerHostName = App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER').get('hostName'),
-      ahsWebPort = yarnService.get('ahsWebPort'),
+    var atsURL = App.get('atsURL') || 'http://' + App.HiveJob.store.getById('component', 'APP_TIMELINE_SERVER').get('hostName') + ':' + App.HiveJob.store.getById('service', 'YARN').get('ahsWebPort'),
       tezDag = App.HiveJob.store.getById('tezDag', tezDagId),
       hiveJob = App.HiveJob.store.all('hiveJob').findBy('tezDag', tezDag),
       hiveJobFailed = hiveJob.get('failed'),
@@ -247,9 +240,8 @@ App.Helpers.jobs = {
       name: 'jobs.tezDag.tezDagVertexId',
       sender: sender,
       data: {
-        historyServerHostName: historyServerHostName,
-        tezDagVertexId: tezVertexInstanceId,
-        ahsWebPort: ahsWebPort
+        atsURL: atsURL,
+        tezDagVertexId: tezVertexInstanceId
       },
       success: 'loadTezDagVertexSuccess',
       error: 'loadTezDagVertexError'

http://git-wip-us.apache.org/repos/asf/ambari/blob/61695fa4/contrib/views/jobs/src/main/resources/ui/app/scripts/mappers/application_status_mapper.js
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/src/main/resources/ui/app/scripts/mappers/application_status_mapper.js b/contrib/views/jobs/src/main/resources/ui/app/scripts/mappers/application_status_mapper.js
index aa17bd5..935f2a1 100644
--- a/contrib/views/jobs/src/main/resources/ui/app/scripts/mappers/application_status_mapper.js
+++ b/contrib/views/jobs/src/main/resources/ui/app/scripts/mappers/application_status_mapper.js
@@ -110,6 +110,53 @@ App.ApplicationStatusMapper = Em.Object.createWithMixins(App.RunPeriodically, {
   },
 
   /**
+   * Get View instance properties provided by user
+   * @returns {$.ajax}
+   * @method getInstanceParameters
+   */
+  getInstanceParameters: function () {
+    var hashArray = location.pathname.split('/');
+    var view = hashArray[2];
+    var version = hashArray[3];
+    var instanceName = hashArray[4];
+    return App.ajax.send({
+      name: 'instance_parameters',
+      sender: this,
+      data: {
+        view: view,
+        version: version,
+        instanceName: instanceName
+      },
+      success: 'getInstanceParametersSuccessCallback',
+      error: 'getInstanceParametersErrorCallback'
+    });
+  },
+
+  /**
+   * Success callback for getInstanceParameters-request
+   * @param {object} data
+   * @method getInstanceParametersSuccessCallback
+   */
+  getInstanceParametersSuccessCallback: function (data) {
+    var atsURLParameter = data.ViewInstanceInfo.properties['yarn.ats.url'];
+    var resourceManagerURLParameter = data.ViewInstanceInfo.properties['yarn.resourcemanager.url'];
+    if (atsURLParameter) {
+      App.set('atsURL', atsURLParameter);
+      App.set('resourceManagerURL', resourceManagerURLParameter);
+    } else {
+      this.getClusterName();
+    }
+  },
+
+  /**
+   * Success callback for getInstanceParameters-request
+   * @method getInstanceParametersErrorCallback
+   */
+  getInstanceParametersErrorCallback: function () {
+    this.getClusterName();
+  },
+
+  /**
    * Get cluster name from server
    * @returns {$.ajax}
    * @method getClusterName

http://git-wip-us.apache.org/repos/asf/ambari/blob/61695fa4/contrib/views/jobs/src/main/resources/view.xml
----------------------------------------------------------------------
diff --git a/contrib/views/jobs/src/main/resources/view.xml b/contrib/views/jobs/src/main/resources/view.xml
index c48f6b5..30adca2 100644
--- a/contrib/views/jobs/src/main/resources/view.xml
+++ b/contrib/views/jobs/src/main/resources/view.xml
@@ -18,4 +18,14 @@ limitations under the License. Kerberos, LDAP, Custom. Binary/Htt
   <name>JOBS</name>
   <label>Jobs View</label>
   <version>1.0.0</version>
+  <parameter>
+      <name>yarn.ats.url</name>
+      <description>The URL to the YARN Application Timeline Server, used to provide Jobs information, typically, this is the yarn.timeline-service.webapp.address property in the yarn-site.xml configuration. For example: http://yarn.ats.address:8188</description>
+      <required>false</required>
+  </parameter>
+  <parameter>
+      <name>yarn.resourcemanager.url</name>
+      <description>The URL to the YARN ResourceManager, used to provide YARN Application data. For example: http://yarn.resourcemanager.address:8088</description>
+      <required>false</required>
+  </parameter>
 </view>