Search in sources :

Example 1 with JobletStatus

use of io.datarouter.joblet.enums.JobletStatus 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 2 with JobletStatus

use of io.datarouter.joblet.enums.JobletStatus in project datarouter by hotpads.

the class JobletService method handleJobletInterruption.

public void handleJobletInterruption(PhaseTimer timer, JobletRequest jobletRequest) {
    jobletRequest.setReservedBy(null);
    jobletRequest.setReservedAt(null);
    JobletStatus setStatusTo = jobletRequest.getRestartable() ? JobletStatus.CREATED : JobletStatus.INTERRUPTED;
    jobletRequest.setStatus(setStatusTo);
    jobletRequestDao.updateOrBust(jobletRequest);
    timer.add("update JobletRequest");
    if (jobletRequest.getRestartable()) {
        requeueJobletRequest(timer, jobletRequest);
    }
    logger.warn("interrupted {} set status={}, reservedBy=null, reservedAt=null", jobletRequest.getKey(), setStatusTo);
}
Also used : JobletStatus(io.datarouter.joblet.enums.JobletStatus)

Example 3 with JobletStatus

use of io.datarouter.joblet.enums.JobletStatus in project datarouter by hotpads.

the class JobletUpdateHandler method restart.

@Handler
private Mav restart(@Param(PARAM_jobletType) OptionalString type, @Param(PARAM_status) String status) {
    JobletStatus jobletStatus = JobletStatus.fromPersistentStringStatic(status);
    long numRestarted = 0;
    if (type.isPresent()) {
        JobletType<?> jobletType = jobletTypeFactory.fromPersistentString(type.get());
        numRestarted = jobletService.restartJoblets(jobletType, jobletStatus);
    } else {
        for (JobletType<?> jobletType : jobletTypeFactory.getAllTypes()) {
            numRestarted += jobletService.restartJoblets(jobletType, jobletStatus);
        }
    }
    var dto = new DatarouterChangelogDtoBuilder("Joblet", type.orElse("all") + " " + status, "restart", getSessionInfo().getRequiredSession().getUsername()).build();
    changelogRecorder.record(dto);
    return pageFactory.message(request, "restarted " + numRestarted);
}
Also used : JobletStatus(io.datarouter.joblet.enums.JobletStatus) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 4 with JobletStatus

use of io.datarouter.joblet.enums.JobletStatus in project datarouter by hotpads.

the class JobletUpdateHandler method deleteGroup.

@Handler
private Mav deleteGroup(@Param(PARAM_jobletType) String typeString, @Param(PARAM_executionOrder) Integer executionOrder, @Param(PARAM_status) String status) {
    JobletType<?> jobletType = jobletTypeFactory.fromPersistentString(typeString);
    Objects.requireNonNull(jobletType, "No joblet type found with name=" + typeString);
    JobletStatus statusString = JobletStatus.fromPersistentStringStatic(status);
    JobletRequestKey prefix = JobletRequestKey.create(jobletType, executionOrder, null, null);
    jobletRequestDao.scanWithPrefix(prefix).include(jobletRequest -> statusString == jobletRequest.getStatus()).map(Databean::getKey).batch(100).forEach(jobletRequestDao::deleteMulti);
    String message = String.format("Deleted joblets with type %s, status %s, executionOrder %s", typeString, status, executionOrder);
    var dto = new DatarouterChangelogDtoBuilder("Joblet", typeString + " " + status + " " + executionOrder, "deleteGroup", getSessionInfo().getRequiredSession().getUsername()).build();
    changelogRecorder.record(dto);
    return pageFactory.message(request, message);
}
Also used : JobletService(io.datarouter.joblet.service.JobletService) Scanner(io.datarouter.scanner.Scanner) JobletTypeFactory(io.datarouter.joblet.type.JobletTypeFactory) LoggerFactory(org.slf4j.LoggerFactory) JobletRequestQueueManager(io.datarouter.joblet.queue.JobletRequestQueueManager) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) JobletStatus(io.datarouter.joblet.enums.JobletStatus) ArrayList(java.util.ArrayList) ChangelogRecorder(io.datarouter.instrumentation.changelog.ChangelogRecorder) Inject(javax.inject.Inject) JobletType(io.datarouter.joblet.type.JobletType) JobletRequestKey(io.datarouter.joblet.storage.jobletrequest.JobletRequestKey) Duration(java.time.Duration) Map(java.util.Map) DatarouterJobletRequestDao(io.datarouter.joblet.storage.jobletrequest.DatarouterJobletRequestDao) Param(io.datarouter.web.handler.types.Param) JobletRequest(io.datarouter.joblet.storage.jobletrequest.JobletRequest) JobletPageFactory(io.datarouter.joblet.JobletPageFactory) JobletRequestQueueKey(io.datarouter.joblet.storage.jobletrequestqueue.JobletRequestQueueKey) Logger(org.slf4j.Logger) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) Mav(io.datarouter.web.handler.mav.Mav) DatarouterJobletQueueDao(io.datarouter.joblet.storage.jobletrequestqueue.DatarouterJobletQueueDao) Objects(java.util.Objects) List(java.util.List) Databean(io.datarouter.model.databean.Databean) BaseHandler(io.datarouter.web.handler.BaseHandler) JobletRequestKey(io.datarouter.joblet.storage.jobletrequest.JobletRequestKey) Databean(io.datarouter.model.databean.Databean) JobletStatus(io.datarouter.joblet.enums.JobletStatus) OptionalString(io.datarouter.web.handler.types.optional.OptionalString) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 5 with JobletStatus

use of io.datarouter.joblet.enums.JobletStatus in project datarouter by hotpads.

the class JobletCounterJob method saveQueueStatsByStatus.

private void saveQueueStatsByStatus(JobletSummary summary) {
    JobletStatus status = summary.getStatus();
    datarouterJobletCounters.saveGlobalQueueLengthJoblets(status, summary.getNumType());
    datarouterJobletCounters.saveGlobalQueueLengthItems(status, summary.getSumItems());
    datarouterJobletCounters.saveGlobalFirst(status, getFirstCreatedMinutesToNow(summary));
}
Also used : JobletStatus(io.datarouter.joblet.enums.JobletStatus)

Aggregations

JobletStatus (io.datarouter.joblet.enums.JobletStatus)9 DatarouterJobletRequestDao (io.datarouter.joblet.storage.jobletrequest.DatarouterJobletRequestDao)4 JobletRequest (io.datarouter.joblet.storage.jobletrequest.JobletRequest)4 Scanner (io.datarouter.scanner.Scanner)4 Inject (javax.inject.Inject)4 DatarouterJobletCounters (io.datarouter.joblet.DatarouterJobletCounters)3 JobletRequestQueueManager (io.datarouter.joblet.queue.JobletRequestQueueManager)3 JobletRequestKey (io.datarouter.joblet.storage.jobletrequest.JobletRequestKey)3 DatarouterJobletQueueDao (io.datarouter.joblet.storage.jobletrequestqueue.DatarouterJobletQueueDao)3 JobletRequestQueueKey (io.datarouter.joblet.storage.jobletrequestqueue.JobletRequestQueueKey)3 JobletType (io.datarouter.joblet.type.JobletType)3 JobletTypeFactory (io.datarouter.joblet.type.JobletTypeFactory)3 Databean (io.datarouter.model.databean.Databean)3 BaseHandler (io.datarouter.web.handler.BaseHandler)3 Collection (java.util.Collection)3 List (java.util.List)3 Map (java.util.Map)3 Objects (java.util.Objects)3 Logger (org.slf4j.Logger)3 LoggerFactory (org.slf4j.LoggerFactory)3