Search in sources :

Example 1 with DurationLogger

use of org.neo4j.kernel.impl.util.DurationLogger in project neo4j by neo4j.

the class OnlineIndexSamplingJob method run.

@Override
public void run() {
    try (DurationLogger durationLogger = new DurationLogger(log, "Sampling index " + indexUserDescription)) {
        try {
            try (IndexReader reader = indexProxy.newReader()) {
                IndexSampler sampler = reader.createSampler();
                IndexSample sample = sampler.sampleIndex();
                // check again if the index is online before saving the counts in the store
                if (indexProxy.getState() == ONLINE) {
                    storeView.replaceIndexCounts(indexId, sample.uniqueValues(), sample.sampleSize(), sample.indexSize());
                    durationLogger.markAsFinished();
                    log.info(format("Sampled index %s with %d unique values in sample of avg size %d taken from " + "index containing %d entries", indexUserDescription, sample.uniqueValues(), sample.sampleSize(), sample.indexSize()));
                } else {
                    durationLogger.markAsAborted("Index no longer ONLINE");
                }
            }
        } catch (IndexNotFoundKernelException e) {
            durationLogger.markAsAborted("Attempted to sample missing/already deleted index " + indexUserDescription);
        }
    }
}
Also used : DurationLogger(org.neo4j.kernel.impl.util.DurationLogger) IndexSample(org.neo4j.storageengine.api.schema.IndexSample) IndexReader(org.neo4j.storageengine.api.schema.IndexReader) IndexNotFoundKernelException(org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException) IndexSampler(org.neo4j.storageengine.api.schema.IndexSampler)

Aggregations

IndexNotFoundKernelException (org.neo4j.kernel.api.exceptions.index.IndexNotFoundKernelException)1 DurationLogger (org.neo4j.kernel.impl.util.DurationLogger)1 IndexReader (org.neo4j.storageengine.api.schema.IndexReader)1 IndexSample (org.neo4j.storageengine.api.schema.IndexSample)1 IndexSampler (org.neo4j.storageengine.api.schema.IndexSampler)1