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