java.lang.Object
net.i2p.router.web.HelperBase
net.i2p.router.web.helpers.JobQueueHelper
Helper for job queue page rendering and form processing.
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static classOrders job names alphabetically with a locale-sensitive collator, so the console's job list sorts the way the user's locale expects.private static classA group of jobs with the same name and time key.private static classSorts job groups by name, then by time.private static classSorts job groups by time descending, keeping equal times in their current order.private static classOrders job rows for display by job name, using a locale-aware collator.private static interfaceDerives the time key used to group a job.Field Summary
FieldsModifier and TypeFieldDescriptionprivate StringURI of the request being rendered.private static intMost jobs listed on the page.private static final longWindow counting a job as recently run.Fields inherited from class HelperBase
_context, _log, _out, CHECKED, PROP_ADVANCED, SELECTEDModifier and TypeFieldDescriptionprotected RouterContextThe router context.protected LogThe log instance.protected WriterThe writer for output.static final StringChecked attribute for HTML checkboxes.static final StringProperty key for advanced mode.static final StringSelected attribute for HTML select options.Constructor Summary
ConstructorsMethod Summary
Modifier and TypeMethodDescriptionprivate voidgetJobCounts(StringBuilder buf, ObjectCounterUnsafe<String> counter, int scheduledCount) Append per-job counts to the buffer.Get the job queue stats HTML.Get the job queue summary HTML.private voidgetJobStats(StringBuilder buf) Render the HTML for the job stats.private static List<JobQueueHelper.JobGroup> groupByNameAndTime(List<Job> jobs, JobQueueHelper.JobTimeFn timeFn) Group the jobs by name, then by the time key derived from each job.private booleanWhether the page shows the recently run jobs.private static StringjobNameDisplay(String jobName, List<Job> jobs) Build the job name label, with a count badge when the group holds several jobs.private voidrenderJobStatsHTML(Writer out) Renders the job statistics table.private voidrenderStatusHTML(Writer out) Moved from JobQueue.voidsetRequestURI(String uri) Set the request URI.Methods inherited from class HelperBase
_t, _t, _t, _x, getChecked, isAdvanced, ngettext, setContextId, storeWriterModifier and TypeMethodDescriptionTranslate a string.Translate a string with a parameter.Translate a string with two parameters.static StringMark a string for extraction by xgettext and translation.protected StringgetChecked(String prop) Get the checked attribute for a boolean property.booleanCheck if advanced mode is enabled.Translate a string with plural forms (ngettext).voidsetContextId(String contextId) Configure this bean to query a particular router context.voidstoreWriter(Writer out) Store the writer for output.
Field Details
MAX_JOBS_DISPLAYED
private static int MAX_JOBS_DISPLAYEDMost jobs listed on the page.RECENT_WINDOW_MS
private static final long RECENT_WINDOW_MSWindow counting a job as recently run.- See Also:
_requestURI
URI of the request being rendered.
Constructor Details
JobQueueHelper
public JobQueueHelper()Constructor. The console builds this helper per page render and points it at the request URI through the bean setter, so a bare instance is the starting state.
Method Details
setRequestURI
isRecentMode
private boolean isRecentMode()Whether the page shows the recently run jobs.- Returns:
- true in the recent view
getJobQueueSummary
getJobQueueStats
renderStatusHTML
Moved from JobQueue.- Parameters:
out- the writer the job queue status HTML is appended to- Throws:
IOException- if writing to out fails
groupByNameAndTime
private static List<JobQueueHelper.JobGroup> groupByNameAndTime(List<Job> jobs, JobQueueHelper.JobTimeFn timeFn) Group the jobs by name, then by the time key derived from each job.- Parameters:
jobs- the jobs to grouptimeFn- derives the time key for each job- Returns:
- the groups, in no particular order - sort before display
jobNameDisplay
renderJobStatsHTML
Renders the job statistics table.- Parameters:
out- the writer to render into- Throws:
IOException- if the writing fails
getJobCounts
private void getJobCounts(StringBuilder buf, ObjectCounterUnsafe<String> counter, int scheduledCount) Append per-job counts to the buffer.- Parameters:
buf- the buffer the job count HTML list is appended tocounter- per-job counts keyed by job namescheduledCount- number of timed jobs, added to the ready count for the queue total
getJobStats
Render the HTML for the job stats. Moved from JobQueue.- Parameters:
buf- the buffer the job statistics HTML is appended to