use of io.datarouter.joblet.storage.jobletdata.JobletData in project datarouter by hotpads.
the class TableSamplerTestTool method executeJobletsAndCollectSamples.
public static List<TableSample> executeJobletsAndCollectSamples(DatarouterInjector injector, List<JobletPackage> jobletPackages) {
List<TableSample> results = new ArrayList<>();
for (JobletData jobletData : JobletPackage.getJobletDatas(jobletPackages)) {
TableSpanSamplerJoblet joblet = injector.getInstance(TableSpanSamplerJoblet.class);
JobletRequest jobletRequest = new JobletRequest();
// this field referenced by the joblet
jobletRequest.getKey().setCreated(System.currentTimeMillis());
joblet.setJobletRequest(jobletRequest);
TableSpanSamplerJobletParams params = new TableSpanSamplerJobletCodec().unmarshallData(jobletData.getData());
joblet.setJobletParams(params);
joblet.process();
results.addAll(joblet.getSamples());
}
return results;
}
use of io.datarouter.joblet.storage.jobletdata.JobletData 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.JobletData in project datarouter by hotpads.
the class JobletPackage method createDetailed.
public static <P> JobletPackage createDetailed(JobletType<P> jobletType, JobletPriority priority, Instant dateCreated, int batchSequence, boolean restartable, String queueId, String groupId, P params) {
JobletCodec<P> codec = jobletType.getCodecSupplier().get();
// build JobletData
String encodedParams = codec.marshallData(params);
JobletData data = new JobletData(encodedParams);
// build JobletRequest
JobletRequest request = new JobletRequest(jobletType, priority, dateCreated, batchSequence, restartable, getDataSignature(encodedParams));
request.setQueueId(queueId);
request.setGroupId(groupId);
request.setNumItems(codec.calculateNumItems(params));
return new JobletPackage(request, data);
}
Aggregations