Search in sources :

Example 1 with ScanOnOpenReadOnlyIdGeneratorFactory

use of org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory in project neo4j by neo4j.

the class RecordStorageEngineFactory method transactionMetaDataStore.

@Override
public MetadataProvider transactionMetaDataStore(FileSystemAbstraction fs, DatabaseLayout databaseLayout, Config config, PageCache pageCache, PageCacheTracer cacheTracer) {
    RecordFormats recordFormats = selectForStoreOrConfig(Config.defaults(), databaseLayout, fs, pageCache, NullLogProvider.getInstance(), cacheTracer);
    var readOnlyChecker = new DatabaseReadOnlyChecker.Default(new DbmsReadOnlyChecker.Default(config), databaseLayout.getDatabaseName());
    var idGeneratorFactory = readOnlyChecker.isReadOnly() ? new ScanOnOpenReadOnlyIdGeneratorFactory() : new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName());
    return new StoreFactory(databaseLayout, config, idGeneratorFactory, pageCache, fs, recordFormats, NullLogProvider.getInstance(), cacheTracer, readOnlyChecker, immutable.empty()).openNeoStores(META_DATA).getMetaDataStore();
}
Also used : DbmsReadOnlyChecker(org.neo4j.configuration.helpers.DbmsReadOnlyChecker) ScanOnOpenReadOnlyIdGeneratorFactory(org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory)

Example 2 with ScanOnOpenReadOnlyIdGeneratorFactory

use of org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory in project neo4j by neo4j.

the class IdGeneratorMigrator method createEmptyPlaceHolderStoreFiles.

private Set<Path> createEmptyPlaceHolderStoreFiles(DatabaseLayout layout, RecordFormats format) {
    Set<Path> createdStores = new HashSet<>();
    StoreType[] storesToCreate = Stream.of(StoreType.values()).filter(t -> {
        Path file = layout.file(t.getDatabaseFile());
        boolean exists = fileSystem.fileExists(file);
        if (!exists) {
            createdStores.add(file);
        }
        return !exists;
    }).toArray(StoreType[]::new);
    createStoreFactory(layout, format, new ScanOnOpenReadOnlyIdGeneratorFactory()).openNeoStores(true, storesToCreate).close();
    return createdStores;
}
Also used : Path(java.nio.file.Path) StoreType(org.neo4j.kernel.impl.store.StoreType) Sets.immutable(org.eclipse.collections.api.factory.Sets.immutable) LongSupplier(java.util.function.LongSupplier) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) ProgressReporter(org.neo4j.common.ProgressReporter) CursorContext(org.neo4j.io.pagecache.context.CursorContext) Config(org.neo4j.configuration.Config) NullLogProvider(org.neo4j.logging.NullLogProvider) DatabaseLayout(org.neo4j.io.layout.DatabaseLayout) ArrayList(java.util.ArrayList) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) HashSet(java.util.HashSet) ScanOnOpenReadOnlyIdGeneratorFactory(org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory) NeoStores(org.neo4j.kernel.impl.store.NeoStores) Iterables(org.neo4j.internal.helpers.collection.Iterables) IdGenerator(org.neo4j.internal.id.IdGenerator) PageCacheTracer(org.neo4j.io.pagecache.tracing.PageCacheTracer) Path(java.nio.file.Path) AbstractStoreMigrationParticipant(org.neo4j.storageengine.migration.AbstractStoreMigrationParticipant) DatabaseFile(org.neo4j.io.layout.DatabaseFile) PageCache(org.neo4j.io.pagecache.PageCache) OpenOption(java.nio.file.OpenOption) DatabaseReadOnlyChecker.writable(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker.writable) Set(java.util.Set) RecordFormatSelector.selectForVersion(org.neo4j.kernel.impl.store.format.RecordFormatSelector.selectForVersion) GBPTREE_ID_FILES(org.neo4j.kernel.impl.store.format.RecordStorageCapability.GBPTREE_ID_FILES) IOException(java.io.IOException) MOVE(org.neo4j.kernel.impl.storemigration.FileOperation.MOVE) StoreMigratorFileOperation.fileOperation(org.neo4j.kernel.impl.storemigration.StoreMigratorFileOperation.fileOperation) IndexImporterFactory(org.neo4j.internal.batchimport.IndexImporterFactory) IdType(org.neo4j.internal.id.IdType) RecoveryCleanupWorkCollector.immediate(org.neo4j.index.internal.gbptree.RecoveryCleanupWorkCollector.immediate) List(java.util.List) Stream(java.util.stream.Stream) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) StoreType(org.neo4j.kernel.impl.store.StoreType) ImmutableSet(org.eclipse.collections.api.set.ImmutableSet) DatabaseReadOnlyChecker(org.neo4j.configuration.helpers.DatabaseReadOnlyChecker) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory) FileSystemAbstraction(org.neo4j.io.fs.FileSystemAbstraction) ScanOnOpenReadOnlyIdGeneratorFactory(org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory) HashSet(java.util.HashSet)

Example 3 with ScanOnOpenReadOnlyIdGeneratorFactory

use of org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory in project neo4j by neo4j.

the class DirectRecordStoreMigrator method migrate.

public void migrate(DatabaseLayout fromDirectoryStructure, RecordFormats fromFormat, DatabaseLayout toDirectoryStructure, RecordFormats toFormat, ProgressReporter progressReporter, StoreType[] types, StoreType... additionalTypesToOpen) throws IOException {
    StoreType[] storesToOpen = ArrayUtil.concat(types, additionalTypesToOpen);
    progressReporter.start(storesToOpen.length);
    try (NeoStores fromStores = new StoreFactory(fromDirectoryStructure, config, new ScanOnOpenReadOnlyIdGeneratorFactory(), pageCache, fs, fromFormat, NullLogProvider.getInstance(), cacheTracer, readOnly(), immutable.empty()).openNeoStores(true, storesToOpen);
        NeoStores toStores = new StoreFactory(toDirectoryStructure, withPersistedStoreHeadersAsConfigFrom(fromStores, storesToOpen), new DefaultIdGeneratorFactory(fs, immediate(), toDirectoryStructure.getDatabaseName()), pageCache, fs, toFormat, NullLogProvider.getInstance(), cacheTracer, writable(), immutable.empty()).openNeoStores(true, storesToOpen);
        var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer(DIRECT_STORE_MIGRATOR_TAG))) {
        toStores.start(cursorContext);
        for (StoreType type : types) {
            // This condition will exclude counts store first and foremost.
            migrate(fromStores.getRecordStore(type), toStores.getRecordStore(type), cursorContext);
            progressReporter.progress(1);
        }
    }
}
Also used : StoreType(org.neo4j.kernel.impl.store.StoreType) ScanOnOpenReadOnlyIdGeneratorFactory(org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory) NeoStores(org.neo4j.kernel.impl.store.NeoStores) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) CursorContext(org.neo4j.io.pagecache.context.CursorContext) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory)

Aggregations

DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)3 ScanOnOpenReadOnlyIdGeneratorFactory (org.neo4j.internal.id.ScanOnOpenReadOnlyIdGeneratorFactory)3 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)3 CursorContext (org.neo4j.io.pagecache.context.CursorContext)2 NeoStores (org.neo4j.kernel.impl.store.NeoStores)2 StoreType (org.neo4j.kernel.impl.store.StoreType)2 RecordFormats (org.neo4j.kernel.impl.store.format.RecordFormats)2 IOException (java.io.IOException)1 OpenOption (java.nio.file.OpenOption)1 Path (java.nio.file.Path)1 ArrayList (java.util.ArrayList)1 HashSet (java.util.HashSet)1 List (java.util.List)1 Set (java.util.Set)1 LongSupplier (java.util.function.LongSupplier)1 Stream (java.util.stream.Stream)1 Sets.immutable (org.eclipse.collections.api.factory.Sets.immutable)1 ImmutableSet (org.eclipse.collections.api.set.ImmutableSet)1 ProgressReporter (org.neo4j.common.ProgressReporter)1 Config (org.neo4j.configuration.Config)1