Search in sources :

Example 11 with IndexNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException in project neo4j by neo4j.

the class NonUniqueDatabaseIndexSamplerTest method nonUniqueSamplingCancel.

@Test
void nonUniqueSamplingCancel() throws IOException {
    Terms terms = getTerms("test", 1);
    Map<String, Terms> fieldTermsMap = MapUtil.genericMap("0string", terms, "id", terms, "0string", terms);
    IndexReaderStub indexReader = new IndexReaderStub(new SamplingFields(fieldTermsMap));
    when(indexSearcher.getIndexReader()).thenReturn(indexReader);
    NonUniqueLuceneIndexSampler luceneIndexSampler = createSampler();
    taskControl.cancel();
    IndexNotFoundKernelException notFoundKernelException = assertThrows(IndexNotFoundKernelException.class, () -> luceneIndexSampler.sampleIndex(NULL));
    assertEquals("Index dropped while sampling.", notFoundKernelException.getMessage());
}
Also used : IndexReaderStub(org.neo4j.kernel.api.impl.index.IndexReaderStub) Terms(org.apache.lucene.index.Terms) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) Test(org.junit.jupiter.api.Test)

Example 12 with IndexNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException in project neo4j by neo4j.

the class IndexStatisticsTest method shouldRemoveIndexStatisticsAfterIndexIsDeleted.

@Test
public void shouldRemoveIndexStatisticsAfterIndexIsDeleted() throws KernelException {
    // given
    indexOnlineMonitor.initialize(0);
    createSomePersons();
    IndexDescriptor index = createPersonNameIndex();
    awaitIndexesOnline();
    // when
    dropIndex(index);
    // then
    try {
        indexSelectivity(index);
        fail("Expected IndexNotFoundKernelException to be thrown");
    } catch (IndexNotFoundKernelException e) {
        var sample = getIndexingStatisticsStore().indexSample(index.getId());
        assertEquals(0, sample.uniqueValues());
        assertEquals(0, sample.sampleSize());
    }
    // and then index size and index updates are zero on disk
    var indexSample = getIndexingStatisticsStore().indexSample(index.getId());
    assertEquals(0, indexSample.indexSize());
    assertEquals(0, indexSample.updates());
}
Also used : IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.Test)

Example 13 with IndexNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException in project neo4j by neo4j.

the class RelationshipCheckerWithRelationshipTypeIndexTest method extractRelationshipTypeIndexProxy.

@BeforeEach
private void extractRelationshipTypeIndexProxy() {
    IndexingService indexingService = db.getDependencyResolver().resolveDependency(IndexingService.class);
    final IndexDescriptor[] indexDescriptors = schemaStorage.indexGetForSchema(SchemaDescriptor.forAnyEntityTokens(EntityType.RELATIONSHIP), CursorContext.NULL);
    // The Relationship Type Index should exist and be unique.
    assertThat(indexDescriptors.length).isEqualTo(1);
    rtiDescriptor = indexDescriptors[0];
    try {
        rtiProxy = indexingService.getIndexProxy(rtiDescriptor);
    } catch (IndexNotFoundKernelException e) {
        throw new RuntimeException(e);
    }
}
Also used : IndexingService(org.neo4j.kernel.impl.api.index.IndexingService) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 14 with IndexNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException in project neo4j by neo4j.

the class BuiltInProceduresTest method indexDetailsShouldGiveMessageForConcurrentlyDeletedIndexes.

@Test
void indexDetailsShouldGiveMessageForConcurrentlyDeletedIndexes() throws Throwable {
    // Given
    givenIndex("User", "name");
    when(schemaReadCore.indexGetState(any(IndexDescriptor.class))).thenThrow(new IndexNotFoundKernelException("Not found."));
    // When/Then
    final Map<String, Object> configMap = MapUtil.genericMap(new HashMap<>(), "config1", "value1", "config2", 2, "config3", true);
    assertThat(call("db.indexDetails", "index_" + 1000)).contains(record(1000L, "index_1000", "NOT FOUND", 0D, "NONUNIQUE", "BTREE", "NODE", singletonList("User"), singletonList("name"), EMPTY.getProviderDescriptor().name(), configMap, "Index not found. It might have been concurrently dropped."));
}
Also used : IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 15 with IndexNotFoundKernelException

use of org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException in project neo4j by neo4j.

the class FusionIndexSampler method sampleIndex.

@Override
public IndexSample sampleIndex(CursorContext cursorContext) throws IndexNotFoundKernelException {
    List<IndexSample> samples = new ArrayList<>();
    Exception exception = null;
    for (IndexSampler sampler : samplers) {
        try {
            samples.add(sampler.sampleIndex(cursorContext));
        } catch (IndexNotFoundKernelException | RuntimeException e) {
            exception = Exceptions.chain(exception, e);
        }
    }
    if (exception != null) {
        throwIfUnchecked(exception);
        throwIfInstanceOf(exception, IndexNotFoundKernelException.class);
        throw new RuntimeException(exception);
    }
    return combineSamples(samples);
}
Also used : IndexSample(org.neo4j.kernel.api.index.IndexSample) ArrayList(java.util.ArrayList) IndexNotFoundKernelException(org.neo4j.internal.kernel.api.exceptions.schema.IndexNotFoundKernelException) 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