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();
}
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);
}
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);
}
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);
}
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));
}
Aggregations