use of org.neo4j.kernel.impl.api.index.IndexProviderMap in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method launchCustomIndexPopulation.
private void launchCustomIndexPopulation(GraphDatabaseSettings.SchemaIndex schemaIndex, Map<String, Integer> labelNameIdMap, int propertyId, Runnable customAction) throws Throwable {
RecordStorageEngine storageEngine = getStorageEngine();
try (Transaction transaction = db.beginTx()) {
Config config = Config.defaults();
KernelTransaction ktx = ((InternalTransaction) transaction).kernelTransaction();
JobScheduler scheduler = getJobScheduler();
NullLogProvider nullLogProvider = NullLogProvider.getInstance();
IndexStoreViewFactory indexStoreViewFactory = mock(IndexStoreViewFactory.class);
when(indexStoreViewFactory.createTokenIndexStoreView(any())).thenAnswer(invocation -> dynamicIndexStoreViewWrapper(customAction, storageEngine::newReader, invocation.getArgument(0), config, scheduler));
IndexProviderMap providerMap = getIndexProviderMap();
indexService = IndexingServiceFactory.createIndexingService(config, scheduler, providerMap, indexStoreViewFactory, ktx.tokenRead(), initialSchemaRulesLoader(storageEngine), nullLogProvider, nullLogProvider, IndexingService.NO_MONITOR, getSchemaState(), mock(IndexStatisticsStore.class), PageCacheTracer.NULL, INSTANCE, "", writable());
indexService.start();
rules = createIndexRules(schemaIndex, labelNameIdMap, propertyId);
schemaCache = new SchemaCache(new StandardConstraintSemantics(), providerMap);
schemaCache.load(iterable(rules));
indexService.createIndexes(AUTH_DISABLED, rules);
transaction.commit();
}
}
use of org.neo4j.kernel.impl.api.index.IndexProviderMap in project neo4j by neo4j.
the class MultiIndexPopulationConcurrentUpdatesIT method createIndexRules.
private IndexDescriptor[] createIndexRules(GraphDatabaseSettings.SchemaIndex schemaIndex, Map<String, Integer> labelNameIdMap, int propertyId) {
final IndexProviderMap indexProviderMap = getIndexProviderMap();
IndexProvider indexProvider = indexProviderMap.lookup(schemaIndex.providerName());
IndexProviderDescriptor providerDescriptor = indexProvider.getProviderDescriptor();
List<IndexDescriptor> list = new ArrayList<>();
for (Integer labelId : labelNameIdMap.values()) {
final LabelSchemaDescriptor schema = SchemaDescriptor.forLabel(labelId, propertyId);
IndexDescriptor index = IndexPrototype.forSchema(schema, providerDescriptor).withName("index_" + labelId).materialise(labelId);
index = indexProvider.completeConfiguration(index);
list.add(index);
}
return list.toArray(new IndexDescriptor[0]);
}
use of org.neo4j.kernel.impl.api.index.IndexProviderMap in project neo4j by neo4j.
the class CheckerTestBase method context.
CheckerContext context(int numberOfThreads, ConsistencyFlags consistencyFlags, ConsistencySummaryStatistics inconsistenciesSummary) throws Exception {
if (context != null) {
return context;
}
// We do this as late as possible because of how it eagerly caches which indexes exist so if the test creates an index
// this lazy instantiation allows the context to pick it up
Config config = Config.defaults(neo4j_home, directory.homePath());
DependencyResolver dependencies = db.getDependencyResolver();
IndexProviderMap indexProviders = dependencies.resolveDependency(IndexProviderMap.class);
IndexingService indexingService = dependencies.resolveDependency(IndexingService.class);
IndexAccessors indexAccessors = new IndexAccessors(indexProviders, neoStores, new IndexSamplingConfig(config), new LookupAccessorsFromRunningDb(indexingService), PageCacheTracer.NULL, tokenHolders, neoStores.getMetaDataStore());
InconsistencyReport report = new InconsistencyReport(new InconsistencyMessageLogger(NullLog.getInstance()), inconsistenciesSummary);
monitor = mock(ConsistencyReporter.Monitor.class);
reporter = new ConsistencyReporter(report, monitor);
countsState = new CountsState(neoStores, cacheAccess, INSTANCE);
NodeBasedMemoryLimiter limiter = new NodeBasedMemoryLimiter(pageCache.pageSize() * pageCache.maxCachedPages(), Runtime.getRuntime().maxMemory(), Long.MAX_VALUE, CacheSlots.CACHE_LINE_SIZE_BYTES, nodeStore.getHighId(), 1);
ProgressMonitorFactory.MultiPartBuilder progress = ProgressMonitorFactory.NONE.multipleParts("Test");
ParallelExecution execution = new ParallelExecution(numberOfThreads, NOOP_EXCEPTION_HANDLER, IDS_PER_CHUNK);
context = new CheckerContext(neoStores, indexAccessors, execution, reporter, cacheAccess, tokenHolders, new RecordLoading(neoStores), countsState, limiter, progress, pageCache, PageCacheTracer.NULL, INSTANCE, DebugContext.NO_DEBUG, consistencyFlags);
context.initialize();
return context;
}
use of org.neo4j.kernel.impl.api.index.IndexProviderMap in project neo4j by neo4j.
the class DatabaseMigrator method migrate.
/**
* Performs construction of {@link StoreUpgrader} and all of the necessary participants and performs store
* migration if that is required.
*
* @param forceUpgrade Ignore the value of the {@link GraphDatabaseSettings#allow_upgrade} setting.
*/
public void migrate(boolean forceUpgrade) throws IOException {
StoreVersionCheck versionCheck = storageEngineFactory.versionCheck(fs, databaseLayout, config, pageCache, logService, pageCacheTracer);
LogsUpgrader logsUpgrader = new LogsUpgrader(fs, storageEngineFactory, databaseLayout, pageCache, legacyLogsLocator, config, dependencyResolver, pageCacheTracer, memoryTracker, databaseHealth, forceUpgrade);
Log userLog = logService.getUserLog(DatabaseMigrator.class);
VisibleMigrationProgressMonitor progress = new VisibleMigrationProgressMonitor(userLog);
LogProvider logProvider = logService.getInternalLogProvider();
StoreUpgrader storeUpgrader = new StoreUpgrader(versionCheck, progress, config, fs, logProvider, logsUpgrader, pageCacheTracer);
// Get all the participants from the storage engine and add them where they want to be
var storeParticipants = storageEngineFactory.migrationParticipants(fs, config, pageCache, jobScheduler, logService, pageCacheTracer, memoryTracker);
storeParticipants.forEach(storeUpgrader::addParticipant);
IndexProviderMap indexProviderMap = dependencyResolver.resolveDependency(IndexProviderMap.class);
IndexConfigMigrator indexConfigMigrator = new IndexConfigMigrator(fs, config, pageCache, logService, storageEngineFactory, indexProviderMap, logService.getUserLog(IndexConfigMigrator.class), pageCacheTracer, memoryTracker);
storeUpgrader.addParticipant(indexConfigMigrator);
IndexProviderMigrator indexProviderMigrator = new IndexProviderMigrator(fs, config, pageCache, logService, storageEngineFactory, pageCacheTracer, memoryTracker);
storeUpgrader.addParticipant(indexProviderMigrator);
// Do individual index provider migration last because they may delete files that we need in earlier steps.
indexProviderMap.accept(provider -> storeUpgrader.addParticipant(provider.storeMigrationParticipant(fs, pageCache, storageEngineFactory)));
try {
storeUpgrader.migrateIfNeeded(databaseLayout, forceUpgrade);
} catch (Exception e) {
userLog.error("Error upgrading database. Database left intact and will likely not be able to start: " + e.toString());
throw e;
}
}
Aggregations