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);
}
}
}
Aggregations