瀏覽代碼

HUE-6664 [jb] Make configurable the number of jobs fetched without pagination

Lower from 1000 to 500 as it is a lot of objects displayed.
Romain Rigaux 8 年之前
父節點
當前提交
9996b110f9

+ 3 - 0
apps/jobbrowser/src/jobbrowser/apis/job_api.py

@@ -23,6 +23,7 @@ from hadoop.yarn import resource_manager_api
 
 from desktop.lib.exceptions import MessageException
 from desktop.lib.exceptions_renderable import PopupException
+from jobbrowser.conf import MAX_JOB_FETCH
 from jobbrowser.views import job_single_logs
 
 
@@ -99,6 +100,8 @@ class YarnApi(Api):
       filter_params['time_value'] = int(filters['time']['time_value'])
       filter_params['time_unit'] = filters['time']['time_unit']
 
+    filter_params['limit'] = MAX_JOB_FETCH.get()
+
     jobs = NativeYarnApi(self.user).get_jobs(**filter_params)
 
     apps = [massage_job_for_json(job, user=self.user) for job in sorted(jobs, key=lambda job: job.jobId, reverse=True)]

+ 8 - 1
apps/jobbrowser/src/jobbrowser/conf.py

@@ -44,4 +44,11 @@ ENABLE_V2 = Config(
     help=_("Show the version 2 of app which unifies all the past browsers into one."),
     type=coerce_bool,
     default=False
-)
+)
+
+MAX_JOB_FETCH = Config(
+  key='max_job_fetch',
+  default=500,
+  type=int,
+  help=_('Maximum number of jobs to fetch and display when pagination is not supported for the type.')
+)

+ 5 - 0
apps/jobbrowser/src/jobbrowser/templates/job_browser.mako

@@ -18,6 +18,7 @@
 
   from desktop import conf
   from desktop.views import commonheader, commonfooter, _ko
+  from jobbrowser.conf import MAX_JOB_FETCH
 %>
 
 <%
@@ -161,6 +162,7 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
               <!-- /ko -->
             </form>
 
+            <div data-bind="visible: jobs.showJobCountBanner" class="pull-center alert alert-warning">${ _("Showing oldest %s jobs. Use days filter to get the recent ones.") % MAX_JOB_FETCH.get() }</div>
 
             <div class="card card-small">
               <!-- ko hueSpinner: { spin: jobs.loadingJobs(), center: true, size: 'xlarge' } --><!-- /ko -->
@@ -1960,6 +1962,9 @@ ${ commonheader("Job Browser", "jobbrowser", user, request) | n,unicode }
 
       var lastFetchJobsRequest = null;
       var lastUpdateJobsRequest = null;
+      self.showJobCountBanner = ko.computed(function() {
+        return self.apps().length == ${ MAX_JOB_FETCH.get() };
+      });
 
       self.fetchJobs = function () {
         vm.apiHelper.cancelActiveRequest(lastUpdateJobsRequest);

+ 3 - 0
desktop/conf.dist/hue.ini

@@ -1277,6 +1277,9 @@
   # Offset in bytes where a negative offset will fetch the last N bytes for the given log file (default 1MB).
   ## log_offset=-1000000
 
+  # Maximum number of jobs to fetch and display when pagination is not supported for the type.
+  ## max_job_fetch=500
+
   # Show the version 2 of app which unifies all the past browsers into one.
   ## enable_v2=false
 

+ 3 - 0
desktop/conf/pseudo-distributed.ini.tmpl

@@ -1279,6 +1279,9 @@
   # Offset in bytes where a negative offset will fetch the last N bytes for the given log file (default 1MB).
   ## log_offset=-1000000
 
+  # Maximum number of jobs to fetch and display when pagination is not supported for the type.
+  ## max_job_fetch=500
+
   # Show the version 2 of app which unifies all the past browsers into one.
   ## enable_v2=false