Search in sources :

Example 1 with DefaultIndexProviderMap

use of org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap in project neo4j by neo4j.

the class Database method initializeExtensions.

private LifeSupport initializeExtensions(Dependencies dependencies) {
    LifeSupport extensionsLife = new LifeSupport();
    extensionsLife.add(new DatabaseExtensions(new DatabaseExtensionContext(databaseLayout, dbmsInfo, dependencies), extensionFactories, dependencies, fail()));
    indexProviderMap = extensionsLife.add(new DefaultIndexProviderMap(dependencies, databaseConfig));
    dependencies.satisfyDependency(indexProviderMap);
    extensionsLife.init();
    return extensionsLife;
}
Also used : DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) DatabaseExtensionContext(org.neo4j.kernel.extension.context.DatabaseExtensionContext) LifeSupport(org.neo4j.kernel.lifecycle.LifeSupport) DatabaseExtensions(org.neo4j.kernel.extension.DatabaseExtensions)

Example 2 with DefaultIndexProviderMap

use of org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap in project neo4j by neo4j.

the class IndexingServiceTest method newIndexingServiceWithMockedDependencies.

private IndexingService newIndexingServiceWithMockedDependencies(IndexPopulator populator, IndexAccessor accessor, DataUpdates data, IndexingService.Monitor monitor, IndexDescriptor... rules) throws IOException {
    when(indexProvider.getInitialState(any(IndexDescriptor.class), any(CursorContext.class))).thenReturn(ONLINE);
    when(indexProvider.getProviderDescriptor()).thenReturn(PROVIDER_DESCRIPTOR);
    when(indexProvider.getPopulator(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(), any(), any(TokenNameLookup.class))).thenReturn(populator);
    data.getsProcessedByStoreScanFrom(storeView);
    when(indexProvider.getOnlineAccessor(any(IndexDescriptor.class), any(IndexSamplingConfig.class), any(TokenNameLookup.class))).thenReturn(accessor);
    when(indexProvider.storeMigrationParticipant(any(FileSystemAbstraction.class), any(PageCache.class), any())).thenReturn(StoreMigrationParticipant.NOT_PARTICIPATING);
    Config config = Config.newBuilder().set(default_schema_provider, PROVIDER_DESCRIPTOR.name()).build();
    DefaultIndexProviderMap providerMap = life.add(new DefaultIndexProviderMap(buildIndexDependencies(indexProvider, fulltextProvider()), config));
    return life.add(IndexingServiceFactory.createIndexingService(config, life.add(scheduler), providerMap, storeViewFactory, nameLookup, loop(iterator(rules)), internalLogProvider, userLogProvider, monitor, schemaState, indexStatisticsStore, PageCacheTracer.NULL, INSTANCE, "", writable()));
}
Also used : DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) TokenNameLookup(org.neo4j.common.TokenNameLookup) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) Config(org.neo4j.configuration.Config) IndexConfig(org.neo4j.internal.schema.IndexConfig) CursorContext(org.neo4j.io.pagecache.context.CursorContext) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) PageCache(org.neo4j.io.pagecache.PageCache)

Example 3 with DefaultIndexProviderMap

use of org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap in project neo4j by neo4j.

the class IndexingServiceTest method shouldLogIndexStateOnInit.

@Test
void shouldLogIndexStateOnInit() throws Exception {
    // given
    IndexProvider provider = mockIndexProviderWithAccessor(PROVIDER_DESCRIPTOR);
    Config config = Config.defaults(default_schema_provider, PROVIDER_DESCRIPTOR.name());
    IndexProviderMap providerMap = life.add(new DefaultIndexProviderMap(buildIndexDependencies(provider, fulltextProvider()), config));
    IndexDescriptor onlineIndex = storeIndex(1, 1, 1, PROVIDER_DESCRIPTOR);
    IndexDescriptor populatingIndex = storeIndex(2, 1, 2, PROVIDER_DESCRIPTOR);
    IndexDescriptor failedIndex = storeIndex(3, 2, 2, PROVIDER_DESCRIPTOR);
    life.add(IndexingServiceFactory.createIndexingService(config, mock(JobScheduler.class), providerMap, mock(IndexStoreViewFactory.class), nameLookup, asList(onlineIndex, populatingIndex, failedIndex), internalLogProvider, userLogProvider, IndexingService.NO_MONITOR, schemaState, indexStatisticsStore, PageCacheTracer.NULL, INSTANCE, "", writable()));
    when(provider.getInitialState(eq(onlineIndex), any())).thenReturn(ONLINE);
    when(provider.getInitialState(eq(populatingIndex), any())).thenReturn(POPULATING);
    when(provider.getInitialState(eq(failedIndex), any())).thenReturn(FAILED);
    nameLookup.label(1, "LabelOne");
    nameLookup.label(2, "LabelTwo");
    nameLookup.propertyKey(1, "propertyOne");
    nameLookup.propertyKey(2, "propertyTwo");
    // when
    life.init();
    // then
    assertThat(internalLogProvider).forLevel(DEBUG).containsMessages("IndexingService.init: index 1 on (:LabelOne {propertyOne}) is ONLINE", "IndexingService.init: index 2 on (:LabelOne {propertyTwo}) is POPULATING", "IndexingService.init: index 3 on (:LabelTwo {propertyTwo}) is FAILED");
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) Config(org.neo4j.configuration.Config) IndexConfig(org.neo4j.internal.schema.IndexConfig) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) Test(org.junit.jupiter.api.Test)

Example 4 with DefaultIndexProviderMap

use of org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap 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 5 with DefaultIndexProviderMap

use of org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap in project neo4j by neo4j.

the class IndexingServiceTest method shouldLogIndexStateOnStart.

@Test
void shouldLogIndexStateOnStart() throws Throwable {
    // given
    IndexProvider provider = mockIndexProviderWithAccessor(PROVIDER_DESCRIPTOR);
    Config config = Config.defaults(default_schema_provider, PROVIDER_DESCRIPTOR.name());
    DefaultIndexProviderMap providerMap = new DefaultIndexProviderMap(buildIndexDependencies(provider, fulltextProvider()), config);
    providerMap.init();
    IndexDescriptor onlineIndex = storeIndex(1, 1, 1, PROVIDER_DESCRIPTOR);
    IndexDescriptor populatingIndex = storeIndex(2, 1, 2, PROVIDER_DESCRIPTOR);
    IndexDescriptor failedIndex = storeIndex(3, 2, 2, PROVIDER_DESCRIPTOR);
    IndexingService indexingService = IndexingServiceFactory.createIndexingService(config, mock(JobScheduler.class), providerMap, storeViewFactory, nameLookup, asList(onlineIndex, populatingIndex, failedIndex), internalLogProvider, userLogProvider, IndexingService.NO_MONITOR, schemaState, indexStatisticsStore, PageCacheTracer.NULL, INSTANCE, "", writable());
    when(provider.getInitialState(eq(onlineIndex), any())).thenReturn(ONLINE);
    when(provider.getInitialState(eq(populatingIndex), any())).thenReturn(POPULATING);
    when(provider.getInitialState(eq(failedIndex), any())).thenReturn(FAILED);
    indexingService.init();
    nameLookup.label(1, "LabelOne");
    nameLookup.label(2, "LabelTwo");
    nameLookup.propertyKey(1, "propertyOne");
    nameLookup.propertyKey(2, "propertyTwo");
    when(indexStatisticsStore.indexSample(anyLong())).thenReturn(new IndexSample(100L, 32L, 32L));
    internalLogProvider.clear();
    // when
    indexingService.start();
    // then
    verify(provider).getPopulationFailure(eq(failedIndex), any());
    assertThat(internalLogProvider).forLevel(DEBUG).containsMessages("IndexingService.start: index 1 on (:LabelOne {propertyOne}) is ONLINE", "IndexingService.start: index 2 on (:LabelOne {propertyTwo}) is POPULATING", "IndexingService.start: index 3 on (:LabelTwo {propertyTwo}) is FAILED");
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) JobScheduler(org.neo4j.scheduler.JobScheduler) IndexSample(org.neo4j.kernel.api.index.IndexSample) Config(org.neo4j.configuration.Config) IndexConfig(org.neo4j.internal.schema.IndexConfig) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) Test(org.junit.jupiter.api.Test)

Aggregations

DefaultIndexProviderMap (org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap)9 Config (org.neo4j.configuration.Config)6 IndexConfig (org.neo4j.internal.schema.IndexConfig)6 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)6 Test (org.junit.jupiter.api.Test)5 IndexProvider (org.neo4j.kernel.api.index.IndexProvider)5 JobScheduler (org.neo4j.scheduler.JobScheduler)5 ArrayList (java.util.ArrayList)3 IndexSample (org.neo4j.kernel.api.index.IndexSample)3 DatabaseExtensions (org.neo4j.kernel.extension.DatabaseExtensions)3 LifeSupport (org.neo4j.kernel.lifecycle.LifeSupport)3 DatabaseReadOnlyChecker (org.neo4j.configuration.helpers.DatabaseReadOnlyChecker)2 RecoveryCleanupWorkCollector (org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector)2 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)2 CursorContext (org.neo4j.io.pagecache.context.CursorContext)2 IndexStatisticsStore (org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore)2 Log (org.neo4j.logging.Log)2 SimpleLogService (org.neo4j.logging.internal.SimpleLogService)2 Monitors (org.neo4j.monitoring.Monitors)2 DelegatingTokenHolder (org.neo4j.token.DelegatingTokenHolder)2