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