Search in sources :

Example 1 with PhysicalSortedStorageReaderNode

use of io.datarouter.storage.node.op.raw.read.SortedStorageReader.PhysicalSortedStorageReaderNode in project datarouter by hotpads.

the class TableCountHandler method resample.

@Handler
private Mav resample(String clientName, String tableName) {
    var node = (PhysicalSortedStorageReaderNode<?, ?, ?>) nodes.getPhysicalNodeForClientAndTable(clientName, tableName);
    tableSpanSamplerJobletCreatorFactory.create(node, tableSamplerService.getSampleInterval(node), tableSamplerService.getBatchSize(node), true, true, System.currentTimeMillis()).createJoblets();
    var dto = new DatarouterChangelogDtoBuilder("Nodewatch", clientName + "." + tableName, "resample", getSessionInfo().getNonEmptyUsernameOrElse("")).build();
    changelogRecorder.record(dto);
    return new InContextRedirectMav(request, paths.datarouter.nodewatch.tableCount.toSlashedString() + "?submitAction=singleTable&clientName=" + clientName + "&tableName=" + tableName);
}
Also used : PhysicalSortedStorageReaderNode(io.datarouter.storage.node.op.raw.read.SortedStorageReader.PhysicalSortedStorageReaderNode) InContextRedirectMav(io.datarouter.web.handler.mav.imp.InContextRedirectMav) DatarouterChangelogDtoBuilder(io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder) BaseHandler(io.datarouter.web.handler.BaseHandler)

Example 2 with PhysicalSortedStorageReaderNode

use of io.datarouter.storage.node.op.raw.read.SortedStorageReader.PhysicalSortedStorageReaderNode in project datarouter by hotpads.

the class TableSpanSamplerJoblet method process.

@Override
public void process() {
    TableSample dbSample = tableSampleDao.get(params.endSample.getKey());
    if (dbSample == null) {
        logger.warn("aborting because dbSample missing {}", params.endSample);
        return;
    }
    if (ObjectTool.notEquals(params.samplerId, dbSample.getSamplerId())) {
        logger.warn("aborting because wrong samplerId={}, {}", params.samplerId, params.endSample);
        return;
    }
    // TODO make expiration a generic joblet feature
    Duration age = jobletRequest.getKey().getAge();
    if (ComparableTool.gt(age, TableSample.MAX_TIME_IN_QUEUE)) {
        logger.warn("aborting expired joblet {} with age {}", jobletRequest, age);
        datarouterJobletCounters.incNumJobletsExpired(1);
        datarouterJobletCounters.incNumJobletsExpired(JOBLET_TYPE, 1);
        return;
    // the joblet creator will quickly create another one based on the stale dateScheduled
    }
    PhysicalNode<?, ?, ?> physicalNode = datarouterNodes.getPhysicalNodeForClientAndTable(params.nodeNames.getClientName(), params.nodeNames.getTableName());
    SortedStorageReaderNode<?, ?, ?> node = (PhysicalSortedStorageReaderNode<?, ?, ?>) physicalNode;
    Objects.requireNonNull(node, "node not found for " + params.nodeNames);
    // TODO replace strings with more formal client detection
    boolean clientSupportsOffsetting = physicalNode.getClientType().supportsOffsetSampling();
    Instant deadline = Instant.now().plus(MAX_RUNNING_TIME);
    samples = new TableSpanSampler<>(node, tableSampleDao, params.samplerId, params.nodeNames, params.startSampleKey, params.endSample, params.sampleEveryN, clientSupportsOffsetting && nodewatchSettingRoot.enableOffsetting.get(), params.batchSize, Instant.ofEpochMilli(params.createdTimeMs), params.scanUntilEnd, deadline).call();
}
Also used : PhysicalSortedStorageReaderNode(io.datarouter.storage.node.op.raw.read.SortedStorageReader.PhysicalSortedStorageReaderNode) Instant(java.time.Instant) TableSample(io.datarouter.nodewatch.storage.tablesample.TableSample) Duration(java.time.Duration)

Aggregations

PhysicalSortedStorageReaderNode (io.datarouter.storage.node.op.raw.read.SortedStorageReader.PhysicalSortedStorageReaderNode)2 DatarouterChangelogDtoBuilder (io.datarouter.instrumentation.changelog.ChangelogRecorder.DatarouterChangelogDtoBuilder)1 TableSample (io.datarouter.nodewatch.storage.tablesample.TableSample)1 BaseHandler (io.datarouter.web.handler.BaseHandler)1 InContextRedirectMav (io.datarouter.web.handler.mav.imp.InContextRedirectMav)1 Duration (java.time.Duration)1 Instant (java.time.Instant)1