Search in sources :

Example 1 with TableSpanSamplerJobletParams

use of io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet.TableSpanSamplerJobletParams in project datarouter by hotpads.

the class TableSpanSamplerJobletCreator method createJobletPackage.

/*--------------------- create --------------------*/
private JobletPackage createJobletPackage(JobletPriority jobletPriority, TableSample start, TableSample end, long samplerId, boolean scanUntilEnd) {
    Objects.requireNonNull(end);
    // we want all joblets created by the parent job to have the same creation time so none have execution priority
    Instant jobletCreationDate = Instant.ofEpochMilli(samplerStartMs);
    int batchSequence = jobletBatchSequence++;
    TableSampleKey startSampleKey = Optional.ofNullable(start).map(TableSample::getKey).orElse(null);
    var params = new TableSpanSamplerJobletParams(scanUntilEnd, samplerStartMs, sampleSize, batchSize, startSampleKey, end, nodeNames, samplerId);
    return JobletPackage.createDetailed(TableSpanSamplerJoblet.JOBLET_TYPE, jobletPriority, jobletCreationDate, batchSequence, false, params.nodeNames.getClientName(), null, params);
}
Also used : Instant(java.time.Instant) TableSpanSamplerJobletParams(io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet.TableSpanSamplerJobletParams) TableSampleKey(io.datarouter.nodewatch.storage.tablesample.TableSampleKey)

Example 2 with TableSpanSamplerJobletParams

use of io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet.TableSpanSamplerJobletParams 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;
}
Also used : TableSpanSamplerJobletCodec(io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet.TableSpanSamplerJobletCodec) ArrayList(java.util.ArrayList) TableSpanSamplerJoblet(io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet) TableSample(io.datarouter.nodewatch.storage.tablesample.TableSample) TableSpanSamplerJobletParams(io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet.TableSpanSamplerJobletParams) JobletData(io.datarouter.joblet.storage.jobletdata.JobletData) JobletRequest(io.datarouter.joblet.storage.jobletrequest.JobletRequest)

Aggregations

TableSpanSamplerJobletParams (io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet.TableSpanSamplerJobletParams)2 JobletData (io.datarouter.joblet.storage.jobletdata.JobletData)1 JobletRequest (io.datarouter.joblet.storage.jobletrequest.JobletRequest)1 TableSpanSamplerJoblet (io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet)1 TableSpanSamplerJobletCodec (io.datarouter.nodewatch.joblet.TableSpanSamplerJoblet.TableSpanSamplerJobletCodec)1 TableSample (io.datarouter.nodewatch.storage.tablesample.TableSample)1 TableSampleKey (io.datarouter.nodewatch.storage.tablesample.TableSampleKey)1 Instant (java.time.Instant)1 ArrayList (java.util.ArrayList)1