use of org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap in project neo4j by neo4j.
the class IndexingServiceTest method shouldLogIndexStateOnInit.
@Test
public void shouldLogIndexStateOnInit() throws Exception {
// given
SchemaIndexProvider provider = mock(SchemaIndexProvider.class);
when(provider.getProviderDescriptor()).thenReturn(PROVIDER_DESCRIPTOR);
when(provider.getOnlineAccessor(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(mock(IndexAccessor.class));
SchemaIndexProviderMap providerMap = new DefaultSchemaIndexProviderMap(provider);
TokenNameLookup mockLookup = mock(TokenNameLookup.class);
IndexRule onlineIndex = indexRule(1, 1, 1, PROVIDER_DESCRIPTOR);
IndexRule populatingIndex = indexRule(2, 1, 2, PROVIDER_DESCRIPTOR);
IndexRule failedIndex = indexRule(3, 2, 2, PROVIDER_DESCRIPTOR);
life.add(IndexingServiceFactory.createIndexingService(Config.empty(), mock(JobScheduler.class), providerMap, mock(IndexStoreView.class), mockLookup, asList(onlineIndex, populatingIndex, failedIndex), logProvider, IndexingService.NO_MONITOR, DO_NOTHING_CALLBACK));
when(provider.getInitialState(onlineIndex.getId(), onlineIndex.getIndexDescriptor())).thenReturn(ONLINE);
when(provider.getInitialState(populatingIndex.getId(), populatingIndex.getIndexDescriptor())).thenReturn(InternalIndexState.POPULATING);
when(provider.getInitialState(failedIndex.getId(), failedIndex.getIndexDescriptor())).thenReturn(InternalIndexState.FAILED);
when(mockLookup.labelGetName(1)).thenReturn("LabelOne");
when(mockLookup.labelGetName(2)).thenReturn("LabelTwo");
when(mockLookup.propertyKeyGetName(1)).thenReturn("propertyOne");
when(mockLookup.propertyKeyGetName(2)).thenReturn("propertyTwo");
// when
life.init();
// then
logProvider.assertExactly(logMatch.info("IndexingService.init: index 1 on :LabelOne(propertyOne) is ONLINE"), logMatch.info("IndexingService.init: index 2 on :LabelOne(propertyTwo) is POPULATING"), logMatch.info("IndexingService.init: index 3 on :LabelTwo(propertyTwo) is FAILED"));
}
use of org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method launchCustomIndexPopulation.
private void launchCustomIndexPopulation(Map<String, Integer> labelNameIdMap, int propertyId, List<NodeUpdates> updates) throws Exception {
NeoStores neoStores = getNeoStores();
LabelScanStore labelScanStore = getLabelScanStore();
ThreadToStatementContextBridge transactionStatementContextBridge = getTransactionStatementContextBridge();
try (Transaction transaction = embeddedDatabase.beginTx()) {
Statement statement = transactionStatementContextBridge.get();
DynamicIndexStoreView storeView = new DynamicIndexStoreViewWrapper(labelScanStore, LockService.NO_LOCK_SERVICE, neoStores, updates);
SchemaIndexProviderMap providerMap = new DefaultSchemaIndexProviderMap(getSchemaIndexProvider());
JobScheduler scheduler = getJobScheduler();
StatementTokenNameLookup tokenNameLookup = new StatementTokenNameLookup(statement.readOperations());
indexService = IndexingServiceFactory.createIndexingService(Config.empty(), scheduler, providerMap, storeView, tokenNameLookup, getIndexRules(neoStores), NullLogProvider.getInstance(), IndexingService.NO_MONITOR, () -> {
});
indexService.start();
IndexRule[] rules = createIndexRules(labelNameIdMap, propertyId);
indexService.createIndexes(rules);
transaction.success();
}
}
use of org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap in project neo4j by neo4j.
the class IndexingServiceTest method newIndexingServiceWithMockedDependencies.
private IndexingService newIndexingServiceWithMockedDependencies(IndexPopulator populator, IndexAccessor accessor, DataUpdates data, IndexingService.Monitor monitor, IndexRule... rules) throws IOException {
when(indexProvider.getInitialState(anyLong(), any(NewIndexDescriptor.class))).thenReturn(ONLINE);
when(indexProvider.getProviderDescriptor()).thenReturn(PROVIDER_DESCRIPTOR);
when(indexProvider.getPopulator(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(populator);
data.getsProcessedByStoreScanFrom(storeView);
when(indexProvider.getOnlineAccessor(anyLong(), any(NewIndexDescriptor.class), any(IndexSamplingConfig.class))).thenReturn(accessor);
when(indexProvider.snapshotMetaFiles()).thenReturn(Iterators.emptyIterator());
when(indexProvider.storeMigrationParticipant(any(FileSystemAbstraction.class), any(PageCache.class), any(LabelScanStoreProvider.class))).thenReturn(StoreMigrationParticipant.NOT_PARTICIPATING);
when(nameLookup.labelGetName(anyInt())).thenAnswer(new NameLookupAnswer("label"));
when(nameLookup.propertyKeyGetName(anyInt())).thenAnswer(new NameLookupAnswer("property"));
Config config = Config.embeddedDefaults(stringMap(GraphDatabaseSettings.multi_threaded_schema_index_population_enabled.name(), "false"));
return life.add(IndexingServiceFactory.createIndexingService(config, life.add(new Neo4jJobScheduler()), new DefaultSchemaIndexProviderMap(indexProvider), storeView, nameLookup, loop(iterator(rules)), logProvider, monitor, DO_NOTHING_CALLBACK));
}
use of org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap in project neo4j by neo4j.
the class IndexingServiceTest method shouldLogIndexStateOnStart.
@Test
public void shouldLogIndexStateOnStart() throws Exception {
// given
SchemaIndexProvider provider = mock(SchemaIndexProvider.class);
when(provider.getProviderDescriptor()).thenReturn(PROVIDER_DESCRIPTOR);
SchemaIndexProviderMap providerMap = new DefaultSchemaIndexProviderMap(provider);
TokenNameLookup mockLookup = mock(TokenNameLookup.class);
IndexRule onlineIndex = indexRule(1, 1, 1, PROVIDER_DESCRIPTOR);
IndexRule populatingIndex = indexRule(2, 1, 2, PROVIDER_DESCRIPTOR);
IndexRule failedIndex = indexRule(3, 2, 2, PROVIDER_DESCRIPTOR);
IndexingService indexingService = IndexingServiceFactory.createIndexingService(Config.empty(), mock(JobScheduler.class), providerMap, storeView, mockLookup, asList(onlineIndex, populatingIndex, failedIndex), logProvider, IndexingService.NO_MONITOR, DO_NOTHING_CALLBACK);
when(provider.getInitialState(onlineIndex.getId(), onlineIndex.getIndexDescriptor())).thenReturn(ONLINE);
when(provider.getInitialState(populatingIndex.getId(), populatingIndex.getIndexDescriptor())).thenReturn(InternalIndexState.POPULATING);
when(provider.getInitialState(failedIndex.getId(), failedIndex.getIndexDescriptor())).thenReturn(InternalIndexState.FAILED);
indexingService.init();
when(mockLookup.labelGetName(1)).thenReturn("LabelOne");
when(mockLookup.labelGetName(2)).thenReturn("LabelTwo");
when(mockLookup.propertyKeyGetName(1)).thenReturn("propertyOne");
when(mockLookup.propertyKeyGetName(2)).thenReturn("propertyTwo");
when(storeView.indexSample(anyLong(), any(DoubleLongRegister.class))).thenReturn(newDoubleLongRegister(32L, 32L));
logProvider.clear();
// when
indexingService.start();
// then
verify(provider).getPopulationFailure(3);
logProvider.assertAtLeastOnce(logMatch.info("IndexingService.start: index 1 on :LabelOne(propertyOne) is ONLINE"), logMatch.info("IndexingService.start: index 2 on :LabelOne(propertyTwo) is POPULATING"), logMatch.info("IndexingService.start: index 3 on :LabelTwo(propertyTwo) is FAILED"));
}
Aggregations