Search in sources :

Example 21 with IndexNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException 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 (var reader = indexProxy.newValueReader();
                var cursorContext = new CursorContext(pageCacheTracer.createPageCursorTracer(INDEX_SAMPLER_TAG));
                IndexSampler sampler = reader.createSampler()) {
                IndexSample sample = sampler.sampleIndex(cursorContext);
                // check again if the index is online before saving the counts in the store
                if (indexProxy.getState() == ONLINE) {
                    indexStatisticsStore.replaceStats(indexId, sample);
                    durationLogger.markAsFinished();
                    log.debug(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.kernel.api.index.IndexSample) CursorContext(org.neo4j.io.pagecache.context.CursorContext) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) IndexSampler(org.neo4j.kernel.api.index.IndexSampler)

Aggregations

IndexNotFoundKernelException (org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException)21 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)13 InternalIndexState (org.neo4j.internal.kernel.api.InternalIndexState)5 ArrayList (java.util.ArrayList)4 Test (org.junit.jupiter.api.Test)4 CursorContext (org.neo4j.io.pagecache.context.CursorContext)4 IndexSampler (org.neo4j.kernel.api.index.IndexSampler)4 IOException (java.io.IOException)3 SchemaRead (org.neo4j.internal.kernel.api.SchemaRead)3 IndexProxy (org.neo4j.kernel.impl.api.index.IndexProxy)3 UncheckedIOException (java.io.UncheckedIOException)2 Arrays (java.util.Arrays)2 HashMap (java.util.HashMap)2 List (java.util.List)2 Map (java.util.Map)2 Collectors (java.util.stream.Collectors)2 Test (org.junit.Test)2 EntityType (org.neo4j.common.EntityType)2 Iterators (org.neo4j.internal.helpers.collection.Iterators)2 IndexEntryConflictException (org.neo4j.kernel.api.exceptions.index.IndexEntryConflictException)2