Bläddra i källkod

[jobbrowser] Job counter error with Yarn

It turns out the proxy fetches data from the JobHistory Server,
which returns HTML even when requesting JSON. In this case,
we should return None.
Abraham Elmahrek 11 år sedan
förälder
incheckning
53abe91

+ 5 - 1
apps/jobbrowser/src/jobbrowser/yarn_models.py

@@ -101,7 +101,11 @@ class Job:
 
   @property
   def counters(self):
-    return self.api.counters(self.id)['jobCounters']
+    counters = self.api.counters(self.id)
+    if counters:
+      return counters['jobCounters']
+    else:
+      return None
 
   @property
   def full_job_conf(self):

+ 7 - 1
desktop/libs/hadoop/src/hadoop/yarn/mapreduce_api.py

@@ -71,7 +71,13 @@ class MapreduceApi(object):
 
   def counters(self, job_id):
     app_id = job_id.replace('job', 'application')
-    return self._root.get('%(app_id)s/ws/%(version)s/mapreduce/jobs/%(job_id)s/counters' % {'app_id': app_id, 'job_id': job_id, 'version': _API_VERSION}, headers={'Accept': _JSON_CONTENT_TYPE})
+    response = self._root.get('%(app_id)s/ws/%(version)s/mapreduce/jobs/%(job_id)s/counters' % {'app_id': app_id, 'job_id': job_id, 'version': _API_VERSION}, headers={'Accept': _JSON_CONTENT_TYPE})
+    # If it hits the job history server, it will return HTML.
+    # Simply return None in this case because there isn't much data there.
+    if isinstance(response, basestring):
+      return None
+    else:
+      return response
 
   def tasks(self, job_id):
     app_id = job_id.replace('job', 'application')