浏览代码

HUE-6663 [jb] Oozie pagination is not showing the total number of jobs

Romain Rigaux 8 年之前
父节点
当前提交
a549f7923b

+ 9 - 5
apps/jobbrowser/src/jobbrowser/apis/job_api.py

@@ -119,7 +119,7 @@ class YarnApi(Api):
         'duration': app['durationMs'],
         'submitted': app['startTimeMs']
       } for app in apps],
-      'total': None
+      'total': len(apps)
     }
 
 
@@ -263,9 +263,11 @@ class YarnMapReduceTaskApi(Api):
     if filters.get('types') and len(filters.get('types')) == 1:
       filter_params['task_types'] = filters['types'][0]
 
+    tasks = NativeYarnApi(self.user).get_tasks(**filter_params)
+
     return {
-      'apps': [self._massage_task(task) for task in NativeYarnApi(self.user).get_tasks(**filter_params)],
-      'total': None
+      'apps': [self._massage_task(task) for task in tasks],
+      'total': len(tasks)
     }
 
 
@@ -324,9 +326,11 @@ class YarnMapReduceTaskAttemptApi(Api):
 
 
   def apps(self):
+    attempts = NativeYarnApi(self.user).get_task(jobid=self.app_id, task_id=self.task_id).attempts
+
     return {
-      'apps': [self._massage_task(task) for task in NativeYarnApi(self.user).get_task(jobid=self.app_id, task_id=self.task_id).attempts],
-      'total': None
+      'apps': [self._massage_task(task) for task in attempts],
+      'total': len(attempts)
     }
 
 

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

@@ -346,9 +346,9 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
   <div class="inline">
     <div class="inline">
       ${ _('Showing') }
-      <span data-bind="text: Math.min((paginationPage() - 1) * paginationResultPage() + 1, paginationResultCounts())"></span>
+      <span data-bind="text: Math.min(paginationOffset(), paginationResultCounts())"></span>
       ${ _('to')}
-      <span data-bind="text: Math.min(paginationPage() * paginationResultPage(), paginationResultCounts())"></span>
+      <span data-bind="text: Math.min(paginationOffset() - 1 + paginationResultPage(), paginationResultCounts())"></span>
       ${ _('of') }
       <span data-bind="text: paginationResultCounts"></span>
 
@@ -1906,10 +1906,10 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
         return ['workflows', 'schedules', 'bundles'].indexOf(vm.interface()) != -1;
       });
       self.paginationPage = ko.observable(1);
-      self.paginationOffset = ko.observable(1);
+      self.paginationOffset = ko.observable(1); // Starting index
       self.paginationResultPage = ko.observable(100);
       self.paginationResultCounts = ko.computed(function() {
-        return self.apps().length;
+        return self.totalApps();
       });
       self.pagination = ko.computed(function() {
         return {

+ 6 - 1
apps/oozie/src/oozie/conf.py

@@ -61,9 +61,14 @@ REMOTE_SAMPLE_DIR = Config(
   help=_t("Location on HDFS where the Oozie workflows are stored. Parameters are $TIME and $USER, e.g. /user/$USER/hue/workspaces/workflow-$TIME")
 )
 
+
+def get_oozie_job_count():
+  '''Returns the maximum of jobs fetched by the API depending on the Hue version'''
+  return 100 if is_hue4() else 50
+
 OOZIE_JOBS_COUNT = Config(
   key='oozie_jobs_count',
-  default=50,
+  dynamic_default=get_oozie_job_count,
   type=int,
   help=_t('Maximum number of Oozie workflows or coodinators or bundles to retrieve in one API call.')
 )

+ 1 - 1
desktop/conf.dist/hue.ini

@@ -1105,7 +1105,7 @@
   ## remote_data_dir=/user/hue/oozie/workspaces
 
   # Maximum of Oozie workflows or coodinators to retrieve in one API call.
-  ## oozie_jobs_count=50
+  ## oozie_jobs_count=100
 
   # Use Cron format for defining the frequency of a Coordinator instead of the old frequency number/unit.
   ## enable_cron_scheduling=true

+ 1 - 1
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1107,7 +1107,7 @@
   ## remote_data_dir=/user/hue/oozie/workspaces
 
   # Maximum of Oozie workflows or coodinators to retrieve in one API call.
-  ## oozie_jobs_count=50
+  ## oozie_jobs_count=100
 
   # Use Cron format for defining the frequency of a Coordinator instead of the old frequency number/unit.
   ## enable_cron_scheduling=true