浏览代码

HUE-930 [jb] Have consistent job and task names across the whole app

We are now showing just short IDs for jobs, tasks and attempts
Modified jobsub and oozie too
Enrico Berti 13 年之前
父节点
当前提交
2cf16624fd

+ 5 - 5
apps/jobbrowser/src/jobbrowser/templates/attempt.mako

@@ -19,9 +19,9 @@
 %>
 <%namespace name="comps" file="jobbrowser_components.mako" />
 
-${commonheader(_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=attempt.attemptId), "jobbrowser", user)}
+${commonheader(_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=attempt.attemptId_short), "jobbrowser", user)}
 <div class="container-fluid">
-    <h1>${_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=attempt.attemptId)}</h1>
+    <h1>${_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=attempt.attemptId_short)}</h1>
     <div class="row-fluid">
         <div class="span2">
             <div class="well sidebar-nav">
@@ -69,11 +69,11 @@ ${commonheader(_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=a
                         <tbody>
                         <tr>
                             <td>${_('Attempt ID')}</td>
-                            <td>${attempt.attemptId}</td>
+                            <td>${attempt.attemptId_short}</td>
                         </tr>
                         <tr>
                             <td>${_('Task ID')}</td>
-                            <td><a href="${url('jobbrowser.views.single_task', jobid=joblnk.jobId, taskid=taskid)}" title="${_('View this task')}">${task.taskId}</a></td>
+                            <td><a href="${url('jobbrowser.views.single_task', jobid=joblnk.jobId, taskid=taskid)}" title="${_('View this task')}">${task.taskId_short}</a></td>
                         </tr>
                         <tr>
                             <td>${_('Task Type')}</td>
@@ -81,7 +81,7 @@ ${commonheader(_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=a
                         </tr>
                         <tr>
                             <td>${_('JobId')}</td>
-                            <td><a href="${url('jobbrowser.views.single_job', jobid=joblnk.jobId)}" title="${_('View this job')}">${joblnk.jobId}</a></td>
+                            <td><a href="${url('jobbrowser.views.single_job', jobid=joblnk.jobId)}" title="${_('View this job')}">${joblnk.jobId_short}</a></td>
                         </tr>
                         <tr>
                             <td>${_('State')}</td>

+ 2 - 2
apps/jobbrowser/src/jobbrowser/templates/attempt_logs.mako

@@ -19,9 +19,9 @@
 %>
 <%namespace name="comps" file="jobbrowser_components.mako" />
 
-${commonheader(_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=attempt.attemptId), "jobbrowser", user)}
+${commonheader(_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=attempt.attemptId_short), "jobbrowser", user)}
 <div class="container-fluid">
-    <h1>${_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=attempt.attemptId)}</h1>
+    <h1>${_('Task Attempt: %(attemptId)s - Job Browser') % dict(attemptId=attempt.attemptId_short)}</h1>
     <div class="row-fluid">
         <div class="span2">
             <div class="well sidebar-nav">

+ 4 - 4
apps/jobbrowser/src/jobbrowser/templates/job.mako

@@ -83,16 +83,16 @@
         </tr>
     % endfor
 </%def>
-${commonheader(_('Job: %(jobId)s - Job Browser') % dict(jobId=job.jobId), "jobbrowser", user)}
+${commonheader(_('Job: %(jobId)s - Job Browser') % dict(jobId=job.jobId_short), "jobbrowser", user)}
 
 <div class="container-fluid">
-    <h1>${_('Job: %(jobId)s - Job Browser') % dict(jobId=job.jobId)}</h1>
+    <h1>${_('Job: %(jobId)s - Job Browser') % dict(jobId=job.jobId_short)}</h1>
     <div class="row-fluid">
         <div class="span2">
             <div class="well sidebar-nav">
                 <ul class="nav nav-list">
                     <li class="nav-header">${_('Job ID')}</li>
-                    <li>${job.jobId}</li>
+                    <li>${job.jobId_short}</li>
                     <li class="nav-header">${_('User')}</li>
                     <li>${job.user}</li>
                     <li class="nav-header">${_('Status')}</li>
@@ -192,7 +192,7 @@ ${commonheader(_('Job: %(jobId)s - Job Browser') % dict(jobId=job.jobId), "jobbr
                         <tbody>
                         <tr>
                             <td>${_('ID')}</td>
-                            <td>${job.jobId}</td>
+                            <td>${job.jobId_short}</td>
                         </tr>
                         <tr>
                             <td>${_('User')}</td>

+ 2 - 2
apps/jobbrowser/src/jobbrowser/templates/task.mako

@@ -19,10 +19,10 @@
 %>
 <%namespace name="comps" file="jobbrowser_components.mako" />
 
-${commonheader(_('Job Task: %(taskId)s - Job Browser') % dict(taskId=task.taskId), "jobbrowser", user)}
+${commonheader(_('Job Task: %(taskId)s - Job Browser') % dict(taskId=task.taskId_short), "jobbrowser", user)}
 
 <div class="container-fluid">
-    <h1>${_('Job Task: %(taskId)s - Job Browser') % dict(taskId=task.taskId)}</h1>
+    <h1>${_('Job Task: %(taskId)s - Job Browser') % dict(taskId=task.taskId_short)}</h1>
     <div class="row-fluid">
         <div class="span2">
             <div class="well sidebar-nav">

+ 2 - 2
apps/jobbrowser/src/jobbrowser/templates/tasks.mako

@@ -21,7 +21,7 @@
 
 <%namespace name="comps" file="jobbrowser_components.mako" />
 
-${commonheader(_('Task View: Job: %(jobId)s - Job Browser') % dict(jobId=jobid), "jobbrowser", user)}
+${commonheader(_('Task View: Job: %(jobId)s - Job Browser') % dict(jobId=jobid_short), "jobbrowser", user)}
 
 <%def name="selected(val, state)">
     %   if val is not None and state is not None and val in state:
@@ -29,7 +29,7 @@ ${commonheader(_('Task View: Job: %(jobId)s - Job Browser') % dict(jobId=jobid),
     %   endif
 </%def>
 <div class="container-fluid">
-    <h1>${_('Task View: Job: %(jobId)s') % dict(jobId=jobid)}</h1>
+    <h1>${_('Task View: Job: %(jobId)s') % dict(jobId=jobid_short)}</h1>
     <div class="well hueWell">
         <form method="get" action="/jobbrowser/jobs/${jobid}/tasks">
             <b>${_('Filter tasks:')}</b>

+ 17 - 15
apps/jobbrowser/src/jobbrowser/tests.py

@@ -157,16 +157,17 @@ class TestJobBrowserWithHadoop(unittest.TestCase, OozieServerProvider):
     oozie_jobid = response.context['jobid']
     OozieServerProvider.wait_until_completion(oozie_jobid, timeout=500, step=1)
     hadoop_job_id = get_hadoop_job_id(self.oozie, oozie_jobid, 1)
+    hadoop_job_id_short = views.get_shorter_id(hadoop_job_id)
 
     # Select only killed jobs (should be absent)
     # Taking advantage of the fact new jobs are at the top of the list!
     response = self.client.get('/jobbrowser/jobs/?state=killed')
-    assert_false(hadoop_job_id in response.content)
+    assert_false(hadoop_job_id_short in response.content)
 
     # Select only failed jobs (should be present)
     # Map job should succeed. Reduce job should fail.
     response = self.client.get('/jobbrowser/jobs/?state=failed')
-    assert_true(hadoop_job_id in response.content)
+    assert_true(hadoop_job_id_short in response.content)
 
     # The single job view should have the failed task table
     response = self.client.get('/jobbrowser/jobs/%s' % (hadoop_job_id,))
@@ -187,8 +188,8 @@ class TestJobBrowserWithHadoop(unittest.TestCase, OozieServerProvider):
 
     # Selecting by failed state should include the failed map
     response = self.client.get('/jobbrowser/jobs/%s/tasks?taskstate=failed' % (hadoop_job_id,))
-    assert_true('_r_000000' in response.content)
-    assert_true('_m_000000' not in response.content)
+    assert_true('r_000000' in response.content)
+    assert_true('m_000000' not in response.content)
 
   def test_kill_job(self):
     """
@@ -219,7 +220,7 @@ class TestJobBrowserWithHadoop(unittest.TestCase, OozieServerProvider):
 
     # Make sure that the first map task succeeds before moving on
     # This will keep us from hitting timing-related failures
-    first_mapper = hadoop_job_id.replace('job', 'task') + '_m_000000'
+    first_mapper = 'm_000000'
     start = time.time()
     timeout_sec = 60
     while first_mapper not in \
@@ -235,7 +236,7 @@ class TestJobBrowserWithHadoop(unittest.TestCase, OozieServerProvider):
     # It should say killed
     response = self.client.get('/jobbrowser/jobs/%s' % (hadoop_job_id,))
     html = response.content.lower()
-    assert_true(hadoop_job_id in html)
+    assert_true(views.get_shorter_id(hadoop_job_id) in html)
     assert_true('killed' in html)
 
     # Exercise select by taskstate
@@ -292,35 +293,36 @@ class TestJobBrowserWithHadoop(unittest.TestCase, OozieServerProvider):
     oozie_jobid = response.context['jobid']
     job = OozieServerProvider.wait_until_completion(oozie_jobid, timeout=120, step=1)
     hadoop_job_id = get_hadoop_job_id(self.oozie, oozie_jobid, 1)
+    hadoop_job_id_short = views.get_shorter_id(hadoop_job_id)
 
     # All jobs page and fetch job ID
     # Taking advantage of the fact new jobs are at the top of the list!
     response = self.client.get('/jobbrowser/jobs/')
-    assert_true(hadoop_job_id in response.content)
+    assert_true(hadoop_job_id_short in response.content)
 
     # Make sure job succeeded
     response = self.client.get('/jobbrowser/jobs/?state=completed')
-    assert_true(hadoop_job_id in response.content)
+    assert_true(hadoop_job_id_short in response.content)
     response = self.client.get('/jobbrowser/jobs/?state=failed')
-    assert_false(hadoop_job_id in response.content)
+    assert_false(hadoop_job_id_short in response.content)
     response = self.client.get('/jobbrowser/jobs/?state=running')
-    assert_false(hadoop_job_id in response.content)
+    assert_false(hadoop_job_id_short in response.content)
     response = self.client.get('/jobbrowser/jobs/?state=killed')
-    assert_false(hadoop_job_id in response.content)
+    assert_false(hadoop_job_id_short in response.content)
 
     # Check sharing permissions
     # Login as ourself
     finish = SHARE_JOBS.set_for_testing(True)
     try:
       response = self.client.get('/jobbrowser/jobs/?user=')
-      assert_true(hadoop_job_id in response.content)
+      assert_true(hadoop_job_id_short in response.content)
     finally:
       finish()
 
     finish = SHARE_JOBS.set_for_testing(False)
     try:
       response = self.client.get('/jobbrowser/jobs/?user=')
-      assert_true(hadoop_job_id in response.content)
+      assert_true(hadoop_job_id_short in response.content)
     finally:
       finish()
 
@@ -331,14 +333,14 @@ class TestJobBrowserWithHadoop(unittest.TestCase, OozieServerProvider):
     finish = SHARE_JOBS.set_for_testing(True)
     try:
       response = client_not_me.get('/jobbrowser/jobs/?user=')
-      assert_true(hadoop_job_id in response.content)
+      assert_true(hadoop_job_id_short in response.content)
     finally:
       finish()
 
     finish = SHARE_JOBS.set_for_testing(False)
     try:
       response = client_not_me.get('/jobbrowser/jobs/?user=')
-      assert_false(hadoop_job_id in response.content)
+      assert_false(hadoop_job_id_short in response.content)
     finally:
       finish()
 

+ 5 - 0
apps/jobbrowser/src/jobbrowser/views.py

@@ -230,6 +230,7 @@ def tasks(request, jobid):
     'request': request,
     'filter_params': filter_params,
     'jobid':jobid,
+    'jobid_short': get_shorter_id(jobid),
     'page': page,
     'tasktype': ttypes,
     'taskstate': tstates,
@@ -390,6 +391,10 @@ def make_substitutions(conf):
 ##################################
 ## Helper functions
 
+def get_shorter_id(hadoop_job_id):
+  return "_".join(hadoop_job_id.split("_")[-2:])
+
+
 def format_counter_name(s):
   """
   Makes counter/config names human readable:

+ 1 - 1
apps/jobsub/src/jobsub/templates/workflow.mako

@@ -128,7 +128,7 @@ ${layout.menubar(section='history')}
 
                 <td>
                 % if action.externalId:
-                  <a href="${ url('jobbrowser.views.single_job', jobid=action.externalId) }">${ action.externalId }</a>
+                  <a href="${ url('jobbrowser.views.single_job', jobid=action.externalId) }">${ "_".join(action.externalId.split("_")[-2:]) }</a>
                 % endif
                 </td>
 

+ 1 - 1
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflow.mako

@@ -214,7 +214,7 @@ ${ layout.menubar(section='dashboard') }
                 <td><span class="label ${ utils.get_status(action.status) }">${ action.status }</span></td>
                 <td>
                   % if action.externalId:
-                    <a href="${ url('jobbrowser.views.single_job', jobid=action.externalId) }">${ action.externalId }</a>
+                    <a href="${ url('jobbrowser.views.single_job', jobid=action.externalId) }">${ "_".join(action.externalId.split("_")[-2:]) }</a>
                   % endif
                 </td>
 

+ 1 - 1
apps/oozie/src/oozie/templates/dashboard/list_oozie_workflow_action.mako

@@ -87,7 +87,7 @@ ${ layout.menubar(section='running') }
         <td>${ _('External Id') }</td>
         <td>
           % if action.externalId:
-            <a href="${ url('jobbrowser.views.single_job', jobid=action.externalId) }">${ action.externalId }</a>
+            <a href="${ url('jobbrowser.views.single_job', jobid=action.externalId) }">${ "_".join(action.externalId.split("_")[-2:]) }</a>
           % endif
         </td>
       </tr>