use of io.datarouter.joblet.dto.JobletSummary in project datarouter by hotpads.
the class JobletHandler method makeContent.
private ContainerTag<?> makeContent(Collection<JobletSummary> rows) {
String contextPath = request.getContextPath();
var title = h4(TITLE).withClass("mt-2");
var table = new J2HtmlTable<JobletSummary>().withClasses("sortable table table-sm table-striped table-bordered table-hover").withHtmlColumn("Type", row -> {
String metricNamePrefix = DatarouterJobletCounters.makeQueueLengthJobletsCreatedPrefix(row.getType());
String text = row.getType();
return externalLinkBuilder.get().counters(metricNamePrefix).map(href -> td(a(text).withHref(href))).orElse(td(text));
}).withColumn("Execution order", JobletSummary::getExecutionOrder).withColumn("Status", row -> row.getStatus().getPersistentString()).withHtmlColumn("Num Joblets", row -> tdAlignRight(NumberFormatter.addCommas(row.getNumType()))).withHtmlColumn("Sum items", row -> tdAlignRight(NumberFormatter.addCommas(row.getSumItems()))).withHtmlColumn("Avg items", row -> tdAlignRight(NumberFormatter.format(row.getAvgItems(), 1))).withHtmlColumn("Queues", row -> {
String href = localLinkBuilder.queues(contextPath, row.getType(), row.getExecutionOrder(), row.getNumQueueIds());
return tdAlignRight(a(row.getNumQueueIds() + "").withHref(href));
}).withHtmlColumn("Failures", row -> {
String href = localLinkBuilder.exceptions(contextPath, row.getType());
return tdAlignRight(a(row.getNumFailures() + "").withHref(href));
}).withHtmlColumn("First reserved", row -> tdAlignRight(row.getFirstReservedAgo()).attr("sorttable_customkey", row.getFirstReservedMsAgo())).withHtmlColumn("First created", row -> tdAlignRight(row.getFirstCreatedAgo()).attr("sorttable_customkey", row.getFirstCreatedMsAgo())).withHtmlColumn("", row -> {
var chartIcon = i().withClass("fas fa-chart-line");
var href = metricLinkBuilder.availableMetricsLink("Joblet .* " + row.getType() + "$");
return td(a(chartIcon).withHref(href));
}).withHtmlColumn("X", row -> {
var trashIcon = i().withClass("fas fa-trash");
String href = localLinkBuilder.delete(contextPath, row.getType(), row.getExecutionOrder(), row.getStatus());
return td(a(trashIcon).withHref(href));
}).build(rows);
return div(title, table).withClass("container-fluid");
}
use of io.datarouter.joblet.dto.JobletSummary in project datarouter by hotpads.
the class JobletHandler method list.
@Handler
private Mav list(@Param(PARAM_whereStatus) OptionalString pStatus, @Param(PARAM_type) OptionalString pType) {
Scanner<JobletRequest> requests = jobletRequestDao.scan();
if (pStatus.isPresent() && pType.isPresent()) {
JobletStatus status = JobletStatus.fromPersistentStringStatic(pStatus.get());
requests = requests.include(request -> status == request.getStatus()).include(request -> request.getKey().getType().equals(pType.get()));
} else if (pStatus.isPresent() && pType.isEmpty()) {
JobletStatus status = JobletStatus.fromPersistentStringStatic(pStatus.get());
requests = requests.include(request -> status == request.getStatus());
} else if (pStatus.isEmpty() && pType.isPresent()) {
requests = requests.include(request -> request.getKey().getType().equals(pType.get()));
}
Collection<JobletSummary> summaries = JobletSummary.summarizeByTypeExecutionOrderStatus(requests);
return pageFactory.startBuilder(request).withTitle(TITLE).withRequires(DatarouterWebRequireJsV2.SORTTABLE).withContent(makeContent(summaries)).buildMav();
}
use of io.datarouter.joblet.dto.JobletSummary in project datarouter by hotpads.
the class JobletQueuesHandler method queues.
@Handler
private Mav queues(@Param(P_jobletType) String jobletType, @Param(P_executionOrder) Integer executionOrder) {
JobletType<?> type = jobletTypeFactory.fromPersistentString(jobletType);
JobletRequestKey prefix = new JobletRequestKey(type.getPersistentString(), executionOrder, null, null);
Scanner<JobletRequest> requests = jobletRequestDao.scanWithPrefix(prefix);
Collection<JobletSummary> summaries = JobletSummary.summarizeByQueueStatus(requests).values();
return pageFactory.startBuilder(request).withTitle(TITLE).withRequires(DatarouterWebRequireJsV2.SORTTABLE).withContent(makeContent(type, executionOrder, summaries)).buildMav();
}
Aggregations