Search in sources :

Example 1 with JobletSummary

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");
}
Also used : J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) TagCreator.text(j2html.TagCreator.text) Scanner(io.datarouter.scanner.Scanner) JobletSummary(io.datarouter.joblet.dto.JobletSummary) JobletLocalLinkBuilder(io.datarouter.joblet.nav.JobletLocalLinkBuilder) TagCreator.h4(j2html.TagCreator.h4) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) JobletStatus(io.datarouter.joblet.enums.JobletStatus) Inject(javax.inject.Inject) NumberFormatter(io.datarouter.util.number.NumberFormatter) DatarouterWebRequireJsV2(io.datarouter.web.requirejs.DatarouterWebRequireJsV2) JobletExternalLinkBuilderSupplier(io.datarouter.joblet.nav.JobletExternalLinkBuilder.JobletExternalLinkBuilderSupplier) DatarouterJobletRequestDao(io.datarouter.joblet.storage.jobletrequest.DatarouterJobletRequestDao) Param(io.datarouter.web.handler.types.Param) J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) JobletRequest(io.datarouter.joblet.storage.jobletrequest.JobletRequest) JobletPageFactory(io.datarouter.joblet.JobletPageFactory) DatarouterJobletCounters(io.datarouter.joblet.DatarouterJobletCounters) TagCreator.i(j2html.TagCreator.i) Collection(java.util.Collection) Mav(io.datarouter.web.handler.mav.Mav) TagCreator.a(j2html.TagCreator.a) ContainerTag(j2html.tags.ContainerTag) DomContent(j2html.tags.DomContent) TagCreator.td(j2html.TagCreator.td) BaseHandler(io.datarouter.web.handler.BaseHandler) TagCreator.div(j2html.TagCreator.div) MetricLinkBuilder(io.datarouter.instrumentation.metric.MetricLinkBuilder) OptionalString(io.datarouter.web.handler.types.optional.OptionalString)

Example 2 with JobletSummary

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();
}
Also used : TagCreator.text(j2html.TagCreator.text) Scanner(io.datarouter.scanner.Scanner) JobletSummary(io.datarouter.joblet.dto.JobletSummary) JobletLocalLinkBuilder(io.datarouter.joblet.nav.JobletLocalLinkBuilder) TagCreator.h4(j2html.TagCreator.h4) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) JobletStatus(io.datarouter.joblet.enums.JobletStatus) Inject(javax.inject.Inject) NumberFormatter(io.datarouter.util.number.NumberFormatter) DatarouterWebRequireJsV2(io.datarouter.web.requirejs.DatarouterWebRequireJsV2) JobletExternalLinkBuilderSupplier(io.datarouter.joblet.nav.JobletExternalLinkBuilder.JobletExternalLinkBuilderSupplier) DatarouterJobletRequestDao(io.datarouter.joblet.storage.jobletrequest.DatarouterJobletRequestDao) Param(io.datarouter.web.handler.types.Param) J2HtmlTable(io.datarouter.web.html.j2html.J2HtmlTable) JobletRequest(io.datarouter.joblet.storage.jobletrequest.JobletRequest) JobletPageFactory(io.datarouter.joblet.JobletPageFactory) DatarouterJobletCounters(io.datarouter.joblet.DatarouterJobletCounters) TagCreator.i(j2html.TagCreator.i) Collection(java.util.Collection) Mav(io.datarouter.web.handler.mav.Mav) TagCreator.a(j2html.TagCreator.a) ContainerTag(j2html.tags.ContainerTag) DomContent(j2html.tags.DomContent) TagCreator.td(j2html.TagCreator.td) BaseHandler(io.datarouter.web.handler.BaseHandler) TagCreator.div(j2html.TagCreator.div) MetricLinkBuilder(io.datarouter.instrumentation.metric.MetricLinkBuilder) JobletStatus(io.datarouter.joblet.enums.JobletStatus) JobletSummary(io.datarouter.joblet.dto.JobletSummary) JobletRequest(io.datarouter.joblet.storage.jobletrequest.JobletRequest) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 3 with JobletSummary

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();
}
Also used : JobletRequestKey(io.datarouter.joblet.storage.jobletrequest.JobletRequestKey) JobletSummary(io.datarouter.joblet.dto.JobletSummary) JobletRequest(io.datarouter.joblet.storage.jobletrequest.JobletRequest) BaseHandler(io.datarouter.web.handler.BaseHandler)

Aggregations

JobletSummary (io.datarouter.joblet.dto.JobletSummary)3 JobletRequest (io.datarouter.joblet.storage.jobletrequest.JobletRequest)3 BaseHandler (io.datarouter.web.handler.BaseHandler)3 MetricLinkBuilder (io.datarouter.instrumentation.metric.MetricLinkBuilder)2 DatarouterJobletCounters (io.datarouter.joblet.DatarouterJobletCounters)2 JobletPageFactory (io.datarouter.joblet.JobletPageFactory)2 JobletStatus (io.datarouter.joblet.enums.JobletStatus)2 JobletExternalLinkBuilderSupplier (io.datarouter.joblet.nav.JobletExternalLinkBuilder.JobletExternalLinkBuilderSupplier)2 JobletLocalLinkBuilder (io.datarouter.joblet.nav.JobletLocalLinkBuilder)2 DatarouterJobletRequestDao (io.datarouter.joblet.storage.jobletrequest.DatarouterJobletRequestDao)2 Scanner (io.datarouter.scanner.Scanner)2 NumberFormatter (io.datarouter.util.number.NumberFormatter)2 Mav (io.datarouter.web.handler.mav.Mav)2 Param (io.datarouter.web.handler.types.Param)2 OptionalString (io.datarouter.web.handler.types.optional.OptionalString)2 J2HtmlTable (io.datarouter.web.html.j2html.J2HtmlTable)2 DatarouterWebRequireJsV2 (io.datarouter.web.requirejs.DatarouterWebRequireJsV2)2 TagCreator.a (j2html.TagCreator.a)2 TagCreator.div (j2html.TagCreator.div)2 TagCreator.h4 (j2html.TagCreator.h4)2