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);
}
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);
}
}
}
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());
}
}
}
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();
}
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);
}
Aggregations