use of io.datarouter.joblet.storage.jobletdata.JobletDataKey in project datarouter by hotpads.
the class JobletService method getJobletPackagesForJobletRequests.
private List<JobletPackage> getJobletPackagesForJobletRequests(Collection<JobletRequest> jobletRequests) {
List<JobletDataKey> keys = Scanner.of(jobletRequests).map(JobletRequest::getJobletDataKey).list();
Map<Long, JobletData> dataKeyToJobletData = jobletDataDao.getMulti(keys).stream().collect(Collectors.toMap(jobletData -> jobletData.getKey().getId(), Function.identity()));
return jobletRequests.stream().map(jobletRequest -> {
Long dataKey = jobletRequest.getJobletDataId();
JobletData jobletData = dataKeyToJobletData.get(dataKey);
return new JobletPackage(jobletRequest, jobletData);
}).collect(Collectors.toList());
}
use of io.datarouter.joblet.storage.jobletdata.JobletDataKey in project datarouter by hotpads.
the class JobletVacuumJob method run.
@Override
public void run(TaskTracker tracker) {
Iterable<JobletRequest> jobletRequests = jobletRequestDao.scan().iterable();
List<JobletRequestKey> jobletsToDelete = new ArrayList<>();
List<JobletDataKey> jobletDataToDelete = new ArrayList<>();
for (JobletRequest jobletRequest : jobletRequests) {
if (shouldDelete(jobletRequest)) {
jobletsToDelete.add(jobletRequest.getKey());
jobletDataToDelete.add(jobletRequest.getJobletDataKey());
jobletRequestsDeleted++;
itemsDeleted = itemsDeleted + jobletRequest.getNumItems();
if (jobletsToDelete.size() >= BATCH_SIZE) {
deleteJobletRequests(jobletsToDelete, jobletDataToDelete);
}
}
}
if (!jobletsToDelete.isEmpty()) {
deleteJobletRequests(jobletsToDelete, jobletDataToDelete);
}
}
Aggregations