Search in sources :

Example 16 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class DefaultIndexProviderMap method init.

@Override
public void init() {
    Iterable<IndexProvider> indexProviders = dependencies.resolveTypeDependencies(IndexProvider.class);
    for (IndexProvider provider : indexProviders) {
        IndexProviderDescriptor providerDescriptor = provider.getProviderDescriptor();
        requireNonNull(providerDescriptor);
        IndexProvider existing = put(providerDescriptor, provider);
        if (existing != null) {
            throw new IllegalArgumentException("Tried to load multiple schema index providers with the same provider descriptor " + providerDescriptor + ". First loaded " + existing + " then " + provider);
        }
    }
    initDefaultProviders();
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) TokenIndexProvider(org.neo4j.kernel.impl.index.schema.TokenIndexProvider) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor)

Example 17 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class DefaultIndexProviderMap method lookup.

@Override
public IndexProvider lookup(IndexProviderDescriptor providerDescriptor) {
    assertInit();
    IndexProvider provider = indexProvidersByDescriptor.get(providerDescriptor);
    assertProviderFound(provider, providerDescriptor.name());
    return provider;
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) TokenIndexProvider(org.neo4j.kernel.impl.index.schema.TokenIndexProvider)

Example 18 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class DefaultIndexProviderMapTest method shouldThrowOnLookupOnUnknownProvider.

@Test
void shouldThrowOnLookupOnUnknownProvider() {
    // given
    IndexProvider provider;
    Dependencies dependencies = new Dependencies();
    dependencies.satisfyDependency(provider = provider("provider", "1.2"));
    dependencies.satisfyDependency(fulltext());
    dependencies.satisfyDependency(tokenProvider());
    // when
    DefaultIndexProviderMap defaultIndexProviderMap = createDefaultProviderMap(dependencies, provider.getProviderDescriptor());
    defaultIndexProviderMap.init();
    assertThrows(IndexProviderNotFoundException.class, () -> defaultIndexProviderMap.lookup(new IndexProviderDescriptor("provider2", "1.2")));
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) Dependencies(org.neo4j.collection.Dependencies) Test(org.junit.jupiter.api.Test)

Example 19 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class IndexPopulationJobTest method indexPopulator.

private IndexPopulator indexPopulator(IndexPrototype prototype) {
    IndexSamplingConfig samplingConfig = new IndexSamplingConfig(Config.defaults());
    IndexProvider indexProvider = db.getDependencyResolver().resolveDependency(DefaultIndexProviderMap.class).getDefaultProvider();
    IndexDescriptor indexDescriptor = prototype.withName("index_21").materialise(21);
    indexDescriptor = indexProvider.completeConfiguration(indexDescriptor);
    return indexProvider.getPopulator(indexDescriptor, samplingConfig, heapBufferFactory(1024), INSTANCE, tokenNameLookup);
}
Also used : IndexProvider(org.neo4j.kernel.api.index.IndexProvider) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor)

Example 20 with IndexProvider

use of org.neo4j.kernel.api.index.IndexProvider in project neo4j by neo4j.

the class IndexingServiceTest method shouldNotHaveToWaitForOrphanedUniquenessIndexInRecovery.

@Test
void shouldNotHaveToWaitForOrphanedUniquenessIndexInRecovery() throws Exception {
    // given that we have a uniqueness index that needs to be recovered and that doesn't have a constraint attached to it
    IndexDescriptor descriptor = uniqueIndex.materialise(10);
    Iterable<IndexDescriptor> schemaRules = Collections.singletonList(descriptor);
    IndexProvider indexProvider = mock(IndexProvider.class);
    when(indexProvider.getInitialState(any(), any())).thenReturn(POPULATING);
    IndexProviderMap indexProviderMap = mock(IndexProviderMap.class);
    when(indexProviderMap.lookup(anyString())).thenReturn(indexProvider);
    when(indexProviderMap.lookup(any(IndexProviderDescriptor.class))).thenReturn(indexProvider);
    when(indexProviderMap.getDefaultProvider()).thenReturn(indexProvider);
    NullLogProvider logProvider = NullLogProvider.getInstance();
    IndexMapReference indexMapReference = new IndexMapReference();
    IndexProxyCreator indexProxyCreator = mock(IndexProxyCreator.class);
    IndexProxy indexProxy = mock(IndexProxy.class);
    when(indexProxy.getDescriptor()).thenReturn(descriptor);
    // Eventually return ONLINE so that this test won't hang if the product code changes in this regard.
    // This test should still fail below when verifying interactions with the proxy and monitor tho.
    when(indexProxy.getState()).thenReturn(POPULATING, POPULATING, POPULATING, POPULATING, ONLINE);
    when(indexProxyCreator.createRecoveringIndexProxy(any())).thenReturn(indexProxy);
    when(indexProxyCreator.createFailedIndexProxy(any(), any())).thenReturn(indexProxy);
    when(indexProxyCreator.createPopulatingIndexProxy(any(), anyBoolean(), any(), any())).thenReturn(indexProxy);
    JobScheduler scheduler = mock(JobScheduler.class);
    IndexSamplingController samplingController = mock(IndexSamplingController.class);
    IndexingService.Monitor monitor = mock(IndexingService.Monitor.class);
    IndexStoreViewFactory storeViewFactory = mock(IndexStoreViewFactory.class);
    when(storeViewFactory.createTokenIndexStoreView(any())).thenReturn(storeView);
    when(storeView.newPropertyAccessor(any(), any())).thenReturn(propertyAccessor);
    IndexingService indexingService = new IndexingService(indexProxyCreator, indexProviderMap, indexMapReference, storeViewFactory, schemaRules, samplingController, nameLookup, scheduler, null, logProvider, logProvider, monitor, mock(IndexStatisticsStore.class), PageCacheTracer.NULL, INSTANCE, "", writable(), Config.defaults());
    // and where index population starts
    indexingService.init();
    // when starting the indexing service
    indexingService.start();
    // then it should be able to start without awaiting the completion of the population of the index
    verify(indexProxy, never()).awaitStoreScanCompleted(anyLong(), any());
    verify(monitor, never()).awaitingPopulationOfRecoveredIndex(any());
}
Also used : JobScheduler(org.neo4j.scheduler.JobScheduler) IndexProviderDescriptor(org.neo4j.internal.schema.IndexProviderDescriptor) IndexDescriptor(org.neo4j.internal.schema.IndexDescriptor) DefaultIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap) IndexStoreViewFactory(org.neo4j.kernel.impl.transaction.state.storeview.IndexStoreViewFactory) IndexProvider(org.neo4j.kernel.api.index.IndexProvider) IndexStatisticsStore(org.neo4j.kernel.impl.api.index.stats.IndexStatisticsStore) IndexSamplingController(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingController) NullLogProvider(org.neo4j.logging.NullLogProvider) Test(org.junit.jupiter.api.Test)

Aggregations

IndexProvider (org.neo4j.kernel.api.index.IndexProvider)40 Test (org.junit.jupiter.api.Test)23 IndexDescriptor (org.neo4j.internal.schema.IndexDescriptor)17 IndexProviderDescriptor (org.neo4j.internal.schema.IndexProviderDescriptor)14 ArrayList (java.util.ArrayList)9 Config (org.neo4j.configuration.Config)9 GenericNativeIndexProvider (org.neo4j.kernel.impl.index.schema.GenericNativeIndexProvider)7 DefaultIndexProviderMap (org.neo4j.kernel.impl.transaction.state.DefaultIndexProviderMap)7 CursorContext (org.neo4j.io.pagecache.context.CursorContext)6 IndexSample (org.neo4j.kernel.api.index.IndexSample)6 TokenNameLookup (org.neo4j.common.TokenNameLookup)5 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)5 TokenIndexProvider (org.neo4j.kernel.impl.index.schema.TokenIndexProvider)5 JobScheduler (org.neo4j.scheduler.JobScheduler)5 IOException (java.io.IOException)4 String.format (java.lang.String.format)4 Arrays (java.util.Arrays)4 HashMap (java.util.HashMap)4 List (java.util.List)4 Map (java.util.Map)4