Search in sources :

Example 1 with DefaultSchemaIndexProviderMap

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"));
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) IndexAccessor(org.neo4j.kernel.api.index.IndexAccessor) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) Test(org.junit.Test)

Example 2 with DefaultSchemaIndexProviderMap

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();
    }
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) LabelScanStore(org.neo4j.kernel.api.labelscan.LabelScanStore) StatementTokenNameLookup(org.neo4j.kernel.api.StatementTokenNameLookup) Statement(org.neo4j.kernel.api.Statement) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) ThreadToStatementContextBridge(org.neo4j.kernel.impl.core.ThreadToStatementContextBridge) DynamicIndexStoreView(org.neo4j.kernel.impl.transaction.state.storeview.DynamicIndexStoreView) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) SchemaIndexProviderMap(org.neo4j.kernel.impl.api.index.SchemaIndexProviderMap) Transaction(org.neo4j.graphdb.Transaction) NeoStores(org.neo4j.kernel.impl.store.NeoStores)

Example 3 with DefaultSchemaIndexProviderMap

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));
}
Also used : IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) NewIndexDescriptor(org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) LabelScanStoreProvider(org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider) IndexSamplingConfig(org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig) Config(org.neo4j.kernel.configuration.Config) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) PageCache(org.neo4j.io.pagecache.PageCache)

Example 4 with DefaultSchemaIndexProviderMap

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"));
}
Also used : JobScheduler(org.neo4j.kernel.impl.util.JobScheduler) Neo4jJobScheduler(org.neo4j.kernel.impl.util.Neo4jJobScheduler) IndexRule(org.neo4j.kernel.impl.store.record.IndexRule) SchemaIndexProvider(org.neo4j.kernel.api.index.SchemaIndexProvider) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) TokenNameLookup(org.neo4j.kernel.api.TokenNameLookup) Registers.newDoubleLongRegister(org.neo4j.register.Registers.newDoubleLongRegister) DoubleLongRegister(org.neo4j.register.Register.DoubleLongRegister) DefaultSchemaIndexProviderMap(org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap) Test(org.junit.Test)

Aggregations

DefaultSchemaIndexProviderMap (org.neo4j.kernel.impl.transaction.state.DefaultSchemaIndexProviderMap)4 IndexRule (org.neo4j.kernel.impl.store.record.IndexRule)3 Test (org.junit.Test)2 TokenNameLookup (org.neo4j.kernel.api.TokenNameLookup)2 SchemaIndexProvider (org.neo4j.kernel.api.index.SchemaIndexProvider)2 NewIndexDescriptor (org.neo4j.kernel.api.schema_new.index.NewIndexDescriptor)2 IndexSamplingConfig (org.neo4j.kernel.impl.api.index.sampling.IndexSamplingConfig)2 JobScheduler (org.neo4j.kernel.impl.util.JobScheduler)2 Neo4jJobScheduler (org.neo4j.kernel.impl.util.Neo4jJobScheduler)2 Transaction (org.neo4j.graphdb.Transaction)1 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)1 PageCache (org.neo4j.io.pagecache.PageCache)1 Statement (org.neo4j.kernel.api.Statement)1 StatementTokenNameLookup (org.neo4j.kernel.api.StatementTokenNameLookup)1 IndexAccessor (org.neo4j.kernel.api.index.IndexAccessor)1 LabelScanStore (org.neo4j.kernel.api.labelscan.LabelScanStore)1 Config (org.neo4j.kernel.configuration.Config)1 SchemaIndexProviderMap (org.neo4j.kernel.impl.api.index.SchemaIndexProviderMap)1 LabelScanStoreProvider (org.neo4j.kernel.impl.api.scan.LabelScanStoreProvider)1 ThreadToStatementContextBridge (org.neo4j.kernel.impl.core.ThreadToStatementContextBridge)1