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