Search in sources :

Example 16 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class IndexIT method shouldBeAbleToRemoveAConstraintIndexWithoutOwner.

@Test
void shouldBeAbleToRemoveAConstraintIndexWithoutOwner() throws Exception {
    // given
    AssertableLogProvider logProvider = new AssertableLogProvider();
    ConstraintIndexCreator creator = new ConstraintIndexCreator(() -> kernel, indexingService, logProvider);
    IndexProviderDescriptor provider = GenericNativeIndexProvider.DESCRIPTOR;
    IndexPrototype prototype = uniqueForSchema(schema).withName("constraint name").withIndexProvider(provider);
    IndexDescriptor constraintIndex = creator.createConstraintIndex(prototype);
    // then
    KernelTransaction transaction = newTransaction();
    assertEquals(emptySet(), asSet(transaction.schemaRead().constraintsGetForLabel(labelId)));
    commit();
    // when
    SchemaWrite schemaWrite = schemaWriteInNewTransaction();
    schemaWrite.indexDrop(constraintIndex);
    commit();
    // then
    transaction = newTransaction();
    assertEquals(emptySet(), asSet(transaction.schemaRead().indexesGetForLabel(labelId)));
    commit();
}
Also used : KernelTransaction(org.neo4j.kernel.api.KernelTransaction) ConstraintIndexCreator(org.neo4j.kernel.impl.api.state.ConstraintIndexCreator) SchemaWrite(org.neo4j.internal.kernel.api.SchemaWrite) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexPrototype(org.neo4j.internal.schema.IndexPrototype) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) AssertableLogProvider(org.neo4j.logging.AssertableLogProvider) Test(org.junit.jupiter.api.Test) KernelIntegrationTest(org.neo4j.kernel.impl.api.integrationtest.KernelIntegrationTest)

Example 17 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class StubStorageCursors method indexDescriptor.

private IndexDescriptor indexDescriptor(EntityType entityType, long id) {
    IndexPrototype indexPrototype = IndexPrototype.forSchema(forAnyEntityTokens(entityType)).withIndexType(LOOKUP).withIndexProvider(new IndexProviderDescriptor("token-lookup", "1.0"));
    indexPrototype = indexPrototype.withName(SchemaRule.generateName(indexPrototype, new String[] {}, new String[] {}));
    return indexPrototype.materialise(id);
}
Also used : IndexPrototype(org.neo4j.internal.schema.IndexPrototype) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor)

Example 18 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class IndexingServiceTest method shouldFailToStartIfMissingIndexProvider.

@Test
void shouldFailToStartIfMissingIndexProvider() throws Exception {
    // GIVEN an indexing service that has a schema index provider X
    String otherProviderKey = "something-completely-different";
    IndexProviderDescriptor otherDescriptor = new IndexProviderDescriptor(otherProviderKey, "no-version");
    IndexDescriptor rule = storeIndex(1, 2, 3, otherDescriptor);
    newIndexingServiceWithMockedDependencies(mock(IndexPopulator.class), mock(IndexAccessor.class), new DataUpdates(), rule);
    // WHEN trying to start up and initialize it with an index from provider Y
    var e = assertThrows(LifecycleException.class, life::init);
    assertThat(e.getCause().getMessage()).contains(PROVIDER_DESCRIPTOR.name());
    assertThat(e.getCause().getMessage()).contains(otherProviderKey);
}
Also used : IndexPopulator(org.neo4j.kernel.api.index.IndexPopulator) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Example 19 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class IndexingServiceTest method shouldLogDeprecatedIndexesOnStart.

@Test
void shouldLogDeprecatedIndexesOnStart() throws Exception {
    // given two indexes per available index provider
    int id = 1;
    List<IndexDescriptor> indexDescriptors = new ArrayList<>();
    IndexProvider[] indexProviders = new IndexProvider[indexProviderDescriptors.length];
    for (int i = 0; i < indexProviderDescriptors.length; i++) {
        IndexProviderDescriptor indexProviderDescriptor = indexProviderDescriptors[i];
        IndexProvider indexProvider = mockIndexProviderWithAccessor(indexProviderDescriptor);
        indexProviders[i] = indexProvider;
        // Two indexes per provider
        for (int j = 0; j < 2; j++) {
            IndexDescriptor index = storeIndex(id, 1, id, indexProviderDescriptor);
            indexDescriptors.add(index);
            when(indexProvider.getInitialState(eq(index), any())).thenReturn(ONLINE);
            id++;
        }
    }
    Config config = Config.defaults(default_schema_provider, nativeBtree10Descriptor.name());
    DependencyResolver dependencies = buildIndexDependencies(indexProviders);
    DefaultIndexProviderMap providerMap = new DefaultIndexProviderMap(dependencies, config);
    providerMap.init();
    when(indexStatisticsStore.indexSample(anyLong())).thenReturn(new IndexSample(1, 1, 1));
    IndexingService indexingService = IndexingServiceFactory.createIndexingService(config, mock(JobScheduler.class), providerMap, storeViewFactory, nameLookup, indexDescriptors, internalLogProvider, userLogProvider, IndexingService.NO_MONITOR, schemaState, indexStatisticsStore, PageCacheTracer.NULL, INSTANCE, "", writable());
    // when starting IndexingService
    indexingService.init();
    for (IndexProviderDescriptor indexProviderDescriptor : indexProviderDescriptors) {
        onBothLogProviders(logProvider -> assertThat(logProvider).doesNotContainMessage(indexProviderDescriptor.name()));
    }
    userLogProvider.clear();
    indexingService.start();
    // then we should see log messages about deprecated providers if any
    for (IndexProviderDescriptor indexProviderDescriptor : indexProviderDescriptors) {
        if (isDeprecated(indexProviderDescriptor)) {
            assertThat(userLogProvider).containsMessages("Deprecated index providers in use:", indexProviderDescriptor.name() + " (2 indexes)", "Use procedure 'db.indexes()' to see what indexes use which index provider.");
        } else {
            onBothLogProviders(logProvider -> assertThat(logProvider).doesNotContainMessage(indexProviderDescriptor.name()));
        }
    }
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) Config(org.neo4j.configuration.Config) IndexConfig(org.neo4j.internal.schema.IndexConfig) ArrayList(java.util.ArrayList) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) DependencyResolver(org.neo4j.common.DependencyResolver) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) IndexSample(org.neo4j.kernel.api.index.IndexSample) Test(org.junit.jupiter.api.Test)

Example 20 with IndexProviderDescriptor

use of org.neo4j.internal.schema.IndexProviderDescriptor in project neo4j by neo4j.

the class IndexDirectoryStructureTest method shouldHandleWeirdCharactersInProviderKey.

@Test
void shouldHandleWeirdCharactersInProviderKey() {
    IndexProviderDescriptor providerWithWeirdName = new IndexProviderDescriptor("native+lucene", "1.0");
    assertCorrectDirectories(directoriesByProvider(databaseStoreDir).forProvider(providerWithWeirdName), baseIndexDirectory.resolve("native_lucene-1.0"), baseIndexDirectory.resolve("native_lucene-1.0").resolve(String.valueOf(indexId)));
}
Also used : IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)41 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)18 Test (org.junit.jupiter.api.Test)16 IndexProvider (org.neo4j.kernel.api.index.IndexProvider)11 IndexPrototype (org.neo4j.internal.schema.IndexPrototype)10 ArrayList (java.util.ArrayList)5 FulltextSchemaDescriptor (org.neo4j.internal.schema.FulltextSchemaDescriptor)5 IndexDirectoryStructure (org.neo4j.kernel.api.index.IndexDirectoryStructure)5 IndexConfig (org.neo4j.internal.schema.IndexConfig)4 LabelSchemaDescriptor (org.neo4j.internal.schema.LabelSchemaDescriptor)4 Path (java.nio.file.Path)3 BeforeEach (org.junit.jupiter.api.BeforeEach)3 IndexPopulator (org.neo4j.kernel.api.index.IndexPopulator)3 IOException (java.io.IOException)2 UncheckedIOException (java.io.UncheckedIOException)2 String.format (java.lang.String.format)2 Arrays (java.util.Arrays)2 Collection (java.util.Collection)2 EnumMap (java.util.EnumMap)2 HashMap (java.util.HashMap)2