Search in sources :

Example 21 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class TokenStoreTestTemplate method setUp.

@BeforeEach
void setUp() throws IOException {
    Path file = dir.file("label-tokens.db");
    Path idFile = dir.file("label-tokens.db.id");
    Path namesFile = dir.file("label-tokens.db.names");
    Path namesIdFile = dir.file("label-tokens.db.names.id");
    IdGeneratorFactory generatorFactory = new DefaultIdGeneratorFactory(fs, immediate(), DEFAULT_DATABASE_NAME);
    LogProvider logProvider = NullLogProvider.getInstance();
    RecordFormats formats = RecordFormatSelector.defaultFormat();
    Config config = Config.defaults();
    nameStore = new DynamicStringStore(namesFile, namesIdFile, config, IdType.LABEL_TOKEN_NAME, generatorFactory, pageCache, logProvider, TokenStore.NAME_STORE_BLOCK_SIZE, formats.dynamic(), formats.storeVersion(), writable(), DEFAULT_DATABASE_NAME, immutable.empty());
    store = instantiateStore(file, idFile, generatorFactory, pageCache, logProvider, nameStore, formats, config);
    nameStore.initialise(true, NULL);
    store.initialise(true, NULL);
    nameStore.start(NULL);
    store.start(NULL);
}
Also used : Path(java.nio.file.Path) LogProvider(org.neo4j.logging.LogProvider) NullLogProvider(org.neo4j.logging.NullLogProvider) RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) Config(org.neo4j.configuration.Config) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) IdGeneratorFactory(org.neo4j.internal.id.IdGeneratorFactory) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 22 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class IdGeneratorMigrator method migrate.

@Override
public void migrate(DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progress, String versionToMigrateFrom, String versionToMigrateTo, IndexImporterFactory indexImporterFactory) throws IOException {
    RecordFormats oldFormat = selectForVersion(versionToMigrateFrom);
    RecordFormats newFormat = selectForVersion(versionToMigrateTo);
    if (requiresIdFilesMigration(oldFormat, newFormat)) {
        try (var cursorContext = new CursorContext(cacheTracer.createPageCursorTracer(ID_GENERATOR_MIGRATION_TAG))) {
            migrateIdFiles(directoryLayout, migrationLayout, oldFormat, newFormat, progress, cursorContext);
        }
    }
}
Also used : RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) CursorContext(org.neo4j.io.pagecache.context.CursorContext)

Example 23 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class RecordStoreVersionCheck method checkUpgrade.

@Override
public Result checkUpgrade(String desiredVersion, CursorContext cursorContext) {
    String version;
    try {
        version = readVersion(cursorContext);
    } catch (IllegalStateException e) {
        // somehow a corrupt neostore file
        return new Result(Outcome.storeVersionNotFound, null, metaDataFile.getFileName().toString());
    } catch (IOException e) {
        // since we cannot read let's assume the file is not there
        return new Result(Outcome.missingStoreFile, null, metaDataFile.getFileName().toString());
    }
    if (desiredVersion.equals(version)) {
        return new Result(Outcome.ok, version, metaDataFile.getFileName().toString());
    } else {
        RecordFormats fromFormat;
        try {
            RecordFormats toFormat = RecordFormatSelector.selectForVersion(desiredVersion);
            fromFormat = RecordFormatSelector.selectForVersion(version);
            // of the config setting to change since downgrades aren't possible but the store can still be opened.
            if (fromFormat.getFormatFamily().isHigherThan(toFormat.getFormatFamily())) {
                return new Result(Outcome.unexpectedUpgradingVersion, version, metaDataFile.toAbsolutePath().toString());
            }
            if (fromFormat.getFormatFamily() == toFormat.getFormatFamily() && fromFormat.generation() > toFormat.generation()) {
                // Tried to downgrade, that isn't supported
                return new Result(Outcome.attemptedStoreDowngrade, fromFormat.storeVersion(), metaDataFile.toAbsolutePath().toString());
            } else {
                return new Result(Outcome.ok, version, metaDataFile.toAbsolutePath().toString());
            }
        } catch (IllegalArgumentException e) {
            return new Result(Outcome.unexpectedStoreVersion, version, metaDataFile.toAbsolutePath().toString());
        }
    }
}
Also used : RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) IOException(java.io.IOException)

Example 24 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats 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 25 with RecordFormats

use of org.neo4j.kernel.impl.store.format.RecordFormats in project neo4j by neo4j.

the class RecordStorageEngineFactory method schemaRuleMigrationAccess.

@Override
public SchemaRuleMigrationAccess schemaRuleMigrationAccess(FileSystemAbstraction fs, PageCache pageCache, Config config, DatabaseLayout databaseLayout, LogService logService, String recordFormats, PageCacheTracer cacheTracer, CursorContext cursorContext, MemoryTracker memoryTracker) {
    RecordFormats formats = selectForVersion(recordFormats);
    StoreFactory factory = new StoreFactory(databaseLayout, config, new DefaultIdGeneratorFactory(fs, immediate(), databaseLayout.getDatabaseName()), pageCache, fs, formats, logService.getInternalLogProvider(), cacheTracer, writable(), immutable.empty());
    NeoStores stores = factory.openNeoStores(true, StoreType.SCHEMA, StoreType.PROPERTY_KEY_TOKEN, StoreType.PROPERTY);
    try {
        stores.start(cursorContext);
    } catch (IOException e) {
        throw new UncheckedIOException(e);
    }
    return createMigrationTargetSchemaRuleAccess(stores, cursorContext, memoryTracker);
}
Also used : RecordFormats(org.neo4j.kernel.impl.store.format.RecordFormats) NeoStores(org.neo4j.kernel.impl.store.NeoStores) DefaultIdGeneratorFactory(org.neo4j.internal.id.DefaultIdGeneratorFactory) UncheckedIOException(java.io.UncheckedIOException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException) StoreFactory(org.neo4j.kernel.impl.store.StoreFactory)

Aggregations

RecordFormats (org.neo4j.kernel.impl.store.format.RecordFormats)43 Test (org.junit.jupiter.api.Test)13 IOException (java.io.IOException)10 Config (org.neo4j.configuration.Config)8 PageCache (org.neo4j.io.pagecache.PageCache)8 DefaultIdGeneratorFactory (org.neo4j.internal.id.DefaultIdGeneratorFactory)7 NullLogProvider (org.neo4j.logging.NullLogProvider)7 Config (org.neo4j.kernel.configuration.Config)6 StoreFactory (org.neo4j.kernel.impl.store.StoreFactory)6 File (java.io.File)5 Path (java.nio.file.Path)5 FileSystemAbstraction (org.neo4j.io.fs.FileSystemAbstraction)5 NeoStores (org.neo4j.kernel.impl.store.NeoStores)5 ForcedSecondaryUnitRecordFormats (org.neo4j.kernel.impl.store.format.ForcedSecondaryUnitRecordFormats)5 ArrayList (java.util.ArrayList)4 Test (org.junit.Test)4 IdGeneratorFactory (org.neo4j.internal.id.IdGeneratorFactory)4 PagedFile (org.neo4j.io.pagecache.PagedFile)4 LogProvider (org.neo4j.logging.LogProvider)4 NoSuchFileException (java.nio.file.NoSuchFileException)3