From 7e2512f119a91155e0769e00b65640a9061ed0c4 Mon Sep 17 00:00:00 2001 From: MishaDemianenko Date: Fri, 17 Aug 2018 13:24:38 +0200 Subject: [PATCH] Align naming and minor cleanups. --- .../StoreUpgraderInterruptionTestIT.java | 8 ++-- ...dGeneratorRebuildFailureEmulationTest.java | 6 +++ .../kernel/impl/store/NeoStoresTest.java | 41 ++++++++----------- .../org/neo4j/store/watch/FileWatchIT.java | 1 - .../org/neo4j/jmx/impl/StoreSizeBeanTest.java | 2 +- .../neo4j/kernel/DatabaseCreationContext.java | 2 +- .../org/neo4j/kernel/NeoStoreDataSource.java | 2 +- .../store/format/RecordFormatSelector.java | 26 ++++++------ .../store/kvstore/AbstractKeyValueStore.java | 2 +- .../kernel/impl/store/kvstore/Rotation.java | 14 ++----- .../impl/storemigration/FileOperation.java | 1 - .../StoreMigrationParticipant.java | 18 ++++---- .../impl/storemigration/StoreUpgrader.java | 34 +++++++-------- .../storemigration/UpgradableDatabase.java | 18 ++++---- .../AbstractStoreMigrationParticipant.java | 6 +-- .../participant/CountsMigrator.java | 21 +++++----- .../participant/ExplicitIndexMigrator.java | 10 ++--- .../NativeLabelScanStoreMigrator.java | 19 ++++----- .../participant/SchemaIndexMigrator.java | 4 +- .../participant/StoreMigrator.java | 24 +++++------ .../explicitindex/IndexImplementation.java | 4 +- .../impl/index/DummyIndexImplementation.java | 4 +- .../test/rule/NeoStoreDataSourceRule.java | 2 +- .../explicit/LuceneIndexImplementation.java | 4 +- .../ModularDatabaseCreationContext.java | 10 ++--- .../storemigration/StoreUpgraderTest.java | 3 +- .../impl/BackupStrategyWrapperTest.java | 4 +- .../backup/impl/OnlineBackupCommandCcIT.java | 2 +- .../backup/impl/OnlineBackupCommandHaIT.java | 3 +- .../neo4j/causalclustering/BackupCoreIT.java | 3 +- .../causalclustering/BackupReadReplicaIT.java | 3 +- .../catchup/storecopy/CommitStateHelper.java | 1 - .../storecopy/TemporaryStoreDirectory.java | 3 +- ...Test.java => GetStoreFileMarshalTest.java} | 2 +- 34 files changed, 147 insertions(+), 160 deletions(-) rename enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/{GetDatabaseStoreMarshalTest.java => GetStoreFileMarshalTest.java} (98%) diff --git a/community/community-it/community-it/src/test/java/upgrade/StoreUpgraderInterruptionTestIT.java b/community/community-it/community-it/src/test/java/upgrade/StoreUpgraderInterruptionTestIT.java index 63352602a10f0..a9bc3997d42cb 100644 --- a/community/community-it/community-it/src/test/java/upgrade/StoreUpgraderInterruptionTestIT.java +++ b/community/community-it/community-it/src/test/java/upgrade/StoreUpgraderInterruptionTestIT.java @@ -118,11 +118,11 @@ public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMigration() StoreMigrator failingStoreMigrator = new StoreMigrator( fs, pageCache, CONFIG, logService ) { @Override - public void migrate( DatabaseLayout sourceLayout, DatabaseLayout targetLayout, + public void migrate( DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progressReporter, String versionToMigrateFrom, String versionToMigrateTo ) throws IOException { - super.migrate( sourceLayout, targetLayout, progressReporter, versionToMigrateFrom, + super.migrate( directoryLayout, migrationLayout, progressReporter, versionToMigrateFrom, versionToMigrateTo ); throw new RuntimeException( "This upgrade is failing" ); } @@ -177,10 +177,10 @@ public void shouldSucceedWithUpgradeAfterPreviousAttemptDiedDuringMovingFiles() StoreMigrator failingStoreMigrator = new StoreMigrator( fs, pageCache, CONFIG, logService ) { @Override - public void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout storeLayout, String versionToUpgradeFrom, + public void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToUpgradeFrom, String versionToMigrateTo ) throws IOException { - super.moveMigratedFiles( migrationLayout, storeLayout, versionToUpgradeFrom, versionToMigrateTo ); + super.moveMigratedFiles( migrationLayout, directoryLayout, versionToUpgradeFrom, versionToMigrateTo ); throw new RuntimeException( "This upgrade is failing" ); } }; diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/IdGeneratorRebuildFailureEmulationTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/IdGeneratorRebuildFailureEmulationTest.java index 92ca9cb9f253d..f998dc0ad40bb 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/IdGeneratorRebuildFailureEmulationTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/IdGeneratorRebuildFailureEmulationTest.java @@ -271,6 +271,12 @@ public void neostore_relationshipstore_db() @Test public void neostore_relationshiptypestore_db() + { + performTest( databaseLayout.idRelationshipTypeTokenStore() ); + } + + @Test + public void neostore_relationshiptypestore_db_names() { performTest( databaseLayout.idRelationshipTypeTokenNamesStore() ); } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/NeoStoresTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/NeoStoresTest.java index 8d8ac46e86090..3a27e21d7da05 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/NeoStoresTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/store/NeoStoresTest.java @@ -37,7 +37,6 @@ import java.util.concurrent.TimeUnit; import java.util.concurrent.atomic.AtomicReference; -import org.neo4j.dbms.database.DatabaseManager; import org.neo4j.graphdb.GraphDatabaseService; import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Relationship; @@ -149,8 +148,7 @@ public void setUpNeoStores() databaseLayout = dir.databaseLayout(); Config config = Config.defaults(); pageCache = pageCacheRule.getPageCache( fs.get() ); - StoreFactory sf = new StoreFactory( databaseLayout, config, new DefaultIdGeneratorFactory( fs.get() ), pageCache, - fs.get(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); + StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); sf.openAllNeoStores( true ).close(); propertyKeyTokenHolder = new DelegatingTokenHolder( this::createPropertyKeyToken, TokenHolder.TYPE_PROPERTY_KEY ); } @@ -164,8 +162,7 @@ private int createPropertyKeyToken( String name ) public void impossibleToGetStoreFromClosedNeoStoresContainer() { Config config = Config.defaults(); - StoreFactory sf = new StoreFactory( databaseLayout, config, new DefaultIdGeneratorFactory( fs.get() ), pageCache, - fs.get(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); + StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); NeoStores neoStores = sf.openAllNeoStores( true ); assertNotNull( neoStores.getMetaDataStore() ); @@ -181,8 +178,7 @@ public void impossibleToGetStoreFromClosedNeoStoresContainer() public void notAllowCreateDynamicStoreWithNegativeBlockSize() { Config config = Config.defaults(); - StoreFactory sf = new StoreFactory( databaseLayout, config, new DefaultIdGeneratorFactory( fs.get() ), pageCache, - fs.get(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); + StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); exception.expect( IllegalArgumentException.class ); exception.expectMessage( "Block size of dynamic array store should be positive integer." ); @@ -197,8 +193,7 @@ public void notAllowCreateDynamicStoreWithNegativeBlockSize() public void impossibleToGetNotRequestedStore() { Config config = Config.defaults(); - StoreFactory sf = new StoreFactory( databaseLayout, config, new DefaultIdGeneratorFactory( fs.get() ), pageCache, - fs.get(), NullLogProvider.getInstance(), EmptyVersionContextSupplier.EMPTY ); + StoreFactory sf = getStoreFactory( config, databaseLayout, fs.get(), NullLogProvider.getInstance() ); exception.expect( IllegalStateException.class ); exception.expectMessage( @@ -538,8 +533,7 @@ public void setVersion() throws Exception assertEquals( 10, MetaDataStore.setRecord( pageCache, databaseLayout.metadataStore(), Position.LOG_VERSION, 12 ) ); Config config = Config.defaults(); - StoreFactory sf = new StoreFactory( databaseLayout, config, new DefaultIdGeneratorFactory( fileSystem ), pageCache, - fileSystem, LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); + StoreFactory sf = getStoreFactory( config, databaseLayout, fileSystem, LOG_PROVIDER ); NeoStores neoStores = sf.openAllNeoStores(); assertEquals( 12, neoStores.getMetaDataStore().getCurrentLogVersion() ); @@ -623,10 +617,7 @@ public void testSetLatestConstraintTx() @Test public void shouldInitializeTheTxIdToOne() { - StoreFactory factory = - new StoreFactory( dir.databaseLayout(), Config.defaults(), new DefaultIdGeneratorFactory( fs.get() ), - pageCache, fs.get(), - LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); + StoreFactory factory = getStoreFactory( Config.defaults(), dir.databaseLayout(), fs.get(), LOG_PROVIDER ); try ( NeoStores neoStores = factory.openAllNeoStores( true ) ) { neoStores.getMetaDataStore(); @@ -644,8 +635,7 @@ public void shouldThrowUnderlyingStorageExceptionWhenFailingToLoadStorage() { FileSystemAbstraction fileSystem = fs.get(); DatabaseLayout databaseLayout = dir.databaseLayout(); - StoreFactory factory = new StoreFactory( databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, - LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); + StoreFactory factory = getStoreFactory( Config.defaults(), databaseLayout, fileSystem, LOG_PROVIDER ); try ( NeoStores neoStores = factory.openAllNeoStores( true ) ) { @@ -720,8 +710,7 @@ public void shouldSetHighestTransactionIdWhenNeeded() { // GIVEN FileSystemAbstraction fileSystem = fs.get(); - StoreFactory factory = new StoreFactory( databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, - LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); + StoreFactory factory = getStoreFactory( Config.defaults(), databaseLayout, fileSystem, LOG_PROVIDER ); try ( NeoStores neoStore = factory.openAllNeoStores( true ) ) { @@ -744,8 +733,7 @@ public void shouldNotSetHighestTransactionIdWhenNeeded() { // GIVEN FileSystemAbstraction fileSystem = fs.get(); - StoreFactory factory = new StoreFactory( databaseLayout, Config.defaults(), new DefaultIdGeneratorFactory( fileSystem ), pageCache, fileSystem, - LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); + StoreFactory factory = getStoreFactory( Config.defaults(), databaseLayout, fileSystem, LOG_PROVIDER ); try ( NeoStores neoStore = factory.openAllNeoStores( true ) ) { @@ -769,9 +757,7 @@ public void shouldCloseAllTheStoreEvenIfExceptionsAreThrown() throws Exception // given FileSystemAbstraction fileSystem = fs.get(); Config defaults = Config.defaults( counts_store_rotation_timeout, "60m" ); - StoreFactory factory = - new StoreFactory( databaseLayout, defaults, new DefaultIdGeneratorFactory( fileSystem ), pageCache, - fileSystem, LOG_PROVIDER, EmptyVersionContextSupplier.EMPTY ); + StoreFactory factory = getStoreFactory( defaults, databaseLayout, fileSystem, LOG_PROVIDER ); NeoStores neoStore = factory.openAllNeoStores( true ); // let's hack the counts store so it fails to rotate and hence it fails to close as well... @@ -1511,4 +1497,11 @@ private void receivePropertyChain( RECEIVER } } } + + private StoreFactory getStoreFactory( Config config, DatabaseLayout databaseLayout, FileSystemAbstraction ephemeralFileSystemAbstraction, + NullLogProvider instance ) + { + return new StoreFactory( databaseLayout, config, new DefaultIdGeneratorFactory( ephemeralFileSystemAbstraction ), pageCache, + ephemeralFileSystemAbstraction, instance, EmptyVersionContextSupplier.EMPTY ); + } } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/store/watch/FileWatchIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/store/watch/FileWatchIT.java index 5d114534b4fe0..b1cbeb9cee6de 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/store/watch/FileWatchIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/store/watch/FileWatchIT.java @@ -328,7 +328,6 @@ private static void forceCheckpoint( CheckPointer checkPointer ) throws IOExcept checkPointer.forceCheckPoint( new SimpleTriggerInfo( "testForceCheckPoint" ) ); } - //TODO: private static String getExplicitIndexDirectory( DatabaseLayout databaseLayout ) { File schemaIndexDirectory = LuceneDataSource.getLuceneIndexStoreDirectory( databaseLayout ); diff --git a/community/jmx/src/test/java/org/neo4j/jmx/impl/StoreSizeBeanTest.java b/community/jmx/src/test/java/org/neo4j/jmx/impl/StoreSizeBeanTest.java index c2b6473442998..e89ff0b94da4a 100644 --- a/community/jmx/src/test/java/org/neo4j/jmx/impl/StoreSizeBeanTest.java +++ b/community/jmx/src/test/java/org/neo4j/jmx/impl/StoreSizeBeanTest.java @@ -258,7 +258,7 @@ void shouldCountAllIndexFiles() throws Exception when( indexProvider2.directoryStructure() ).thenReturn( directoryStructure2 ); // Label scan store - File labelScan = testDirectory.databaseLayout().file("labelScanStore" ); + File labelScan = testDirectory.databaseLayout().labelScanStore(); createFileOfSize( labelScan, 4 ); when( labelScanStore.getLabelScanStoreFile() ).thenReturn( labelScan ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/DatabaseCreationContext.java b/community/kernel/src/main/java/org/neo4j/kernel/DatabaseCreationContext.java index 5b0659d78a0ce..b42b7fc1cccc0 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/DatabaseCreationContext.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/DatabaseCreationContext.java @@ -66,7 +66,7 @@ public interface DatabaseCreationContext { String getDatabaseName(); - DatabaseLayout getDatabaseDirectoryStructure(); + DatabaseLayout getDatabaseLayout(); Config getConfig(); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/NeoStoreDataSource.java b/community/kernel/src/main/java/org/neo4j/kernel/NeoStoreDataSource.java index 35bbffe125513..6c52d46614834 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/NeoStoreDataSource.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/NeoStoreDataSource.java @@ -222,7 +222,7 @@ public class NeoStoreDataSource extends LifecycleAdapter public NeoStoreDataSource( DatabaseCreationContext context ) { this.databaseName = context.getDatabaseName(); - this.databaseLayout = context.getDatabaseDirectoryStructure(); + this.databaseLayout = context.getDatabaseLayout(); this.config = context.getConfig(); this.idGeneratorFactory = context.getIdGeneratorFactory(); this.tokenNameLookup = context.getTokenNameLookup(); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/RecordFormatSelector.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/RecordFormatSelector.java index 77898cf47e4c7..f99bc98e0f63b 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/RecordFormatSelector.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/format/RecordFormatSelector.java @@ -133,16 +133,16 @@ public static RecordFormats selectForConfig( Config config, LogProvider logProvi *

* Note: package private only for testing. * - * @param dbDirectoryStructure directory with the store + * @param databaseLayout directory with the store * @param fs file system used to access store files * @param pageCache page cache to read store files * @return record format of the given store or null if {@link DatabaseLayout#metadataStore()} file not * found or can't be read */ @Nullable - static RecordFormats selectForStore( DatabaseLayout dbDirectoryStructure, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider ) + static RecordFormats selectForStore( DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider ) { - File neoStoreFile = dbDirectoryStructure.metadataStore(); + File neoStoreFile = databaseLayout.metadataStore(); if ( fs.fileExists( neoStoreFile ) ) { try @@ -156,7 +156,7 @@ static RecordFormats selectForStore( DatabaseLayout dbDirectoryStructure, FileSy { if ( format.storeVersion().equals( storeVersion ) ) { - info( logProvider, "Selected " + format + " record format from store " + dbDirectoryStructure.databaseDirectory() ); + info( logProvider, "Selected " + format + " record format from store " + databaseLayout.databaseDirectory() ); return format; } } @@ -175,7 +175,7 @@ static RecordFormats selectForStore( DatabaseLayout dbDirectoryStructure, FileSy * record format is not configured than {@link #DEFAULT_FORMAT} is selected. * * @param config configuration parameters - * @param dbDirectoryStructure database directory structure + * @param databaseLayout database directory structure * @param fs file system used to access store files * @param pageCache page cache to read store files * @return record format from the store (if it can be read) or configured record format or {@link #DEFAULT_FORMAT} @@ -183,12 +183,12 @@ static RecordFormats selectForStore( DatabaseLayout dbDirectoryStructure, FileSy */ @Nonnull public static RecordFormats selectForStoreOrConfig( - Config config, DatabaseLayout dbDirectoryStructure, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider ) + Config config, DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider ) { RecordFormats configuredFormat = loadRecordFormat( configuredRecordFormat( config ) ); boolean formatConfigured = configuredFormat != null; - RecordFormats currentFormat = selectForStore( dbDirectoryStructure, fs, pageCache, logProvider ); + RecordFormats currentFormat = selectForStore( databaseLayout, fs, pageCache, logProvider ); boolean storeWithFormatExists = currentFormat != null; if ( formatConfigured && storeWithFormatExists ) @@ -223,18 +223,18 @@ public static RecordFormats selectForStoreOrConfig( * Check if store and configured formats are compatible. In case if format is not configured or store does not * exist yet - we consider formats as compatible. * @param config configuration parameters - * @param dbDirectoryStructure database directory structure + * @param databaseLayout database directory structure * @param fs file system used to access store files * @param pageCache page cache to read store files * @param logProvider log provider * @return true if configured and actual format is compatible, false otherwise. */ public static boolean isStoreAndConfigFormatsCompatible( - Config config, DatabaseLayout dbDirectoryStructure, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider ) + Config config, DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider ) { RecordFormats configuredFormat = loadRecordFormat( configuredRecordFormat( config ) ); - RecordFormats currentFormat = selectForStore( dbDirectoryStructure, fs, pageCache, logProvider ); + RecordFormats currentFormat = selectForStore( databaseLayout, fs, pageCache, logProvider ); return (configuredFormat == null) || (currentFormat == null) || (currentFormat.getFormatFamily().equals( configuredFormat.getFormatFamily() ) && @@ -247,7 +247,7 @@ public static boolean isStoreAndConfigFormatsCompatible( * {@link #DEFAULT_FORMAT}. * * @param config configuration parameters - * @param directoryStructure database directory structure + * @param databaseLayout database directory structure * @param fs file system used to access store files * @param pageCache page cache to read store files * @return record format from the store (if it can be read) or configured record format or {@link #DEFAULT_FORMAT} @@ -255,7 +255,7 @@ public static boolean isStoreAndConfigFormatsCompatible( */ @Nonnull public static RecordFormats selectNewestFormat( - Config config, DatabaseLayout directoryStructure, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider ) + Config config, DatabaseLayout databaseLayout, FileSystemAbstraction fs, PageCache pageCache, LogProvider logProvider ) { boolean formatConfigured = StringUtils.isNotEmpty( configuredRecordFormat( config ) ); if ( formatConfigured ) @@ -265,7 +265,7 @@ public static RecordFormats selectNewestFormat( } else { - RecordFormats result = selectForStore( directoryStructure, fs, pageCache, logProvider ); + RecordFormats result = selectForStore( databaseLayout, fs, pageCache, logProvider ); if ( result == null ) { // format was not explicitly configured and store does not exist, select default format diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/kvstore/AbstractKeyValueStore.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/kvstore/AbstractKeyValueStore.java index 47139887babac..df3d1337db7c4 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/kvstore/AbstractKeyValueStore.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/kvstore/AbstractKeyValueStore.java @@ -72,7 +72,7 @@ public AbstractKeyValueStore( FileSystemAbstraction fs, PageCache pages, Databas monitor = RotationMonitor.NONE; } this.format = new Format( headerFields ); - this.rotationStrategy = rotation.value().create( fs, pages, format, monitor, databaseLayout, rotation.parameters() ); + this.rotationStrategy = rotation.value().create( fs, pages, format, monitor, databaseLayout ); this.rotationTimerFactory = timerFactory; this.state = new DeadState.Stopped<>( format, getClass().getAnnotation( State.class ).value(), versionContextSupplier ); diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/kvstore/Rotation.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/kvstore/Rotation.java index 7718d1142d529..5909382af3b9c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/store/kvstore/Rotation.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/store/kvstore/Rotation.java @@ -37,21 +37,14 @@ { Strategy value(); - String[] parameters() default {".a", ".b"}; - enum Strategy { LEFT_RIGHT { @Override RotationStrategy create( FileSystemAbstraction fs, PageCache pages, ProgressiveFormat format, - RotationMonitor monitor, DatabaseLayout databaseLayout, - String[] parameters ) + RotationMonitor monitor, DatabaseLayout databaseLayout ) { - if ( parameters == null || parameters.length != 2 ) - { - throw new IllegalArgumentException( "Expected exactly 2 format parameters." ); - } final File left = databaseLayout.countStoreA(); final File right = databaseLayout.countStoreB(); return new RotationStrategy.LeftRight( fs, pages, format, monitor, left, right ); @@ -61,14 +54,13 @@ RotationStrategy create( FileSystemAbstraction fs, PageCache pages, ProgressiveF { @Override RotationStrategy create( FileSystemAbstraction fs, PageCache pages, ProgressiveFormat format, - RotationMonitor monitor, DatabaseLayout databaseLayout, - String[] parameters ) + RotationMonitor monitor, DatabaseLayout databaseLayout ) { return new RotationStrategy.Incrementing( fs, pages, format, monitor, databaseLayout ); } }; abstract RotationStrategy create( FileSystemAbstraction fs, PageCache pages, ProgressiveFormat format, - RotationMonitor monitor, DatabaseLayout databaseLayout, String... parameters ); + RotationMonitor monitor, DatabaseLayout databaseLayout ); } } diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/FileOperation.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/FileOperation.java index 98c3b972cc059..b6ced715c1043 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/FileOperation.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/FileOperation.java @@ -28,7 +28,6 @@ * Different operations on a file, for example copy or move, given a {@link FileSystemAbstraction} and * source/destination. */ -//TODO:use layouts directly instead public enum FileOperation { COPY diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreMigrationParticipant.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreMigrationParticipant.java index a191a338ba94f..de4cef2dd1541 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreMigrationParticipant.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreMigrationParticipant.java @@ -40,36 +40,36 @@ public interface StoreMigrationParticipant * Migrated data should go into {@code targetStoreDir}, where source and target dirs are * highest level database store dirs. * - * @param directoryStructure data to migrate. - * @param migrationStructure place to migrate to. + * @param directoryLayout data to migrate. + * @param migrationLayout place to migrate to. * @param progress migration progress monitor * @param versionToMigrateFrom the version to migrate from * @param versionToMigrateTo the version to migrate to * @throws IOException if there was an error migrating. * @throws UnsatisfiedDependencyException if one or more dependencies were unsatisfied. */ - void migrate( DatabaseLayout directoryStructure, DatabaseLayout migrationStructure, ProgressReporter progress, + void migrate( DatabaseLayout directoryLayout, DatabaseLayout migrationLayout, ProgressReporter progress, String versionToMigrateFrom, String versionToMigrateTo ) throws IOException; /** * After a successful migration, move all affected files from {@code upgradeDirectory} over to * the {@code workingDirectory}, effectively activating the migration changes. - * @param migrationStructure directory where the + * @param migrationLayout directory where the * {@link #migrate(DatabaseLayout, DatabaseLayout, ProgressReporter, String, String) migration} put its files. - * @param directoryStructure directory the store directory of the to move the migrated files to. + * @param directoryLayout directory the store directory of the to move the migrated files to. * @param versionToMigrateFrom the version we have migrated from * @param versionToMigrateTo the version we want to migrate to * @throws IOException if unable to move one or more files. */ - void moveMigratedFiles( DatabaseLayout migrationStructure, DatabaseLayout directoryStructure, String versionToMigrateFrom, String versionToMigrateTo ) + void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToMigrateFrom, String versionToMigrateTo ) throws IOException; /** - * Delete any file from {@code migrationStructure} produced during migration. - * @param migrationStructure the directory where migrated files end up. + * Delete any file from {@code migrationLayout} produced during migration. + * @param migrationLayout the directory where migrated files end up. * @throws IOException if unable to clean up one or more files. */ - void cleanup( DatabaseLayout migrationStructure ) throws IOException; + void cleanup( DatabaseLayout migrationLayout ) throws IOException; /** * @return descriptive name of this migration participant. diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreUpgrader.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreUpgrader.java index d9e759d5578d7..b3e579ec93c7c 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreUpgrader.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/storemigration/StoreUpgrader.java @@ -103,15 +103,15 @@ public void addParticipant( StoreMigrationParticipant participant ) } } - public void migrateIfNeeded( DatabaseLayout dbDirectoryStructure ) + public void migrateIfNeeded( DatabaseLayout layout ) { - DatabaseLayout migrationStructure = DatabaseLayout.of( dbDirectoryStructure.databaseDirectory(), MIGRATION_DIRECTORY ); + DatabaseLayout migrationStructure = DatabaseLayout.of( layout.databaseDirectory(), MIGRATION_DIRECTORY ); - cleanupLegacyLeftOverDirsIn( dbDirectoryStructure.databaseDirectory() ); + cleanupLegacyLeftOverDirsIn( layout.databaseDirectory() ); File migrationStateFile = migrationStructure.file( MIGRATION_STATUS_FILE ); // if migration directory exists than we might have failed to move files into the store dir so do it again - if ( upgradableDatabase.hasCurrentVersion( dbDirectoryStructure ) && !fileSystem.fileExists( migrationStateFile ) ) + if ( upgradableDatabase.hasCurrentVersion( layout ) && !fileSystem.fileExists( migrationStateFile ) ) { // No migration needed return; @@ -119,15 +119,15 @@ public void migrateIfNeeded( DatabaseLayout dbDirectoryStructure ) if ( isUpgradeAllowed() ) { - migrateStore( dbDirectoryStructure, migrationStructure, migrationStateFile ); + migrateStore( layout, migrationStructure, migrationStateFile ); } - else if ( !RecordFormatSelector.isStoreAndConfigFormatsCompatible( config, dbDirectoryStructure, fileSystem, pageCache, logProvider ) ) + else if ( !RecordFormatSelector.isStoreAndConfigFormatsCompatible( config, layout, fileSystem, pageCache, logProvider ) ) { throw new UpgradeNotAllowedByConfigurationException(); } } - private void migrateStore( DatabaseLayout dbDirectoryStructure, DatabaseLayout migrationStructure, File migrationStateFile ) + private void migrateStore( DatabaseLayout dbDirectoryLayout, DatabaseLayout migrationLayout, File migrationStateFile ) { // One or more participants would like to do migration progressMonitor.started( participants.size() ); @@ -138,10 +138,10 @@ private void migrateStore( DatabaseLayout dbDirectoryStructure, DatabaseLayout m // and it's just a matter of moving over the files to the storeDir. if ( MigrationStatus.migrating.isNeededFor( migrationStatus ) ) { - versionToMigrateFrom = upgradableDatabase.checkUpgradable( dbDirectoryStructure ).storeVersion(); - cleanMigrationDirectory( migrationStructure.databaseDirectory() ); + versionToMigrateFrom = upgradableDatabase.checkUpgradable( dbDirectoryLayout ).storeVersion(); + cleanMigrationDirectory( migrationLayout.databaseDirectory() ); MigrationStatus.migrating.setMigrationStatus( fileSystem, migrationStateFile, versionToMigrateFrom ); - migrateToIsolatedDirectory( dbDirectoryStructure, migrationStructure, versionToMigrateFrom ); + migrateToIsolatedDirectory( dbDirectoryLayout, migrationLayout, versionToMigrateFrom ); MigrationStatus.moving.setMigrationStatus( fileSystem, migrationStateFile, versionToMigrateFrom ); } @@ -149,11 +149,11 @@ private void migrateStore( DatabaseLayout dbDirectoryStructure, DatabaseLayout m { versionToMigrateFrom = MigrationStatus.moving.maybeReadInfo( fileSystem, migrationStateFile, versionToMigrateFrom ); - moveMigratedFilesToStoreDirectory( participants, migrationStructure, dbDirectoryStructure, + moveMigratedFilesToStoreDirectory( participants, migrationLayout, dbDirectoryLayout, versionToMigrateFrom, upgradableDatabase.currentVersion() ); } - cleanup( participants, migrationStructure ); + cleanup( participants, migrationLayout ); progressMonitor.completed(); } @@ -196,14 +196,14 @@ private static void cleanup( Iterable participants, D } } - private static void moveMigratedFilesToStoreDirectory( Iterable participants, DatabaseLayout migrationStructure, - DatabaseLayout directoryStructure, String versionToMigrateFrom, String versionToMigrateTo ) + private static void moveMigratedFilesToStoreDirectory( Iterable participants, DatabaseLayout migrationLayout, + DatabaseLayout directoryLayout, String versionToMigrateFrom, String versionToMigrateTo ) { try { for ( StoreMigrationParticipant participant : participants ) { - participant.moveMigratedFiles( migrationStructure, directoryStructure, versionToMigrateFrom, + participant.moveMigratedFiles( migrationLayout, directoryLayout, versionToMigrateFrom, versionToMigrateTo ); } } @@ -213,14 +213,14 @@ private static void moveMigratedFilesToStoreDirectory( Iterable watcherServiceFactory; private final GraphDatabaseFacade facade; private final Iterable engineProviders; - private final DatabaseLayout directoryStructure; + private final DatabaseLayout databaseLayout; ModularDatabaseCreationContext( String databaseName, PlatformModule platformModule, EditionModule editionModule, Procedures procedures, GraphDatabaseFacade facade, TokenHolders tokenHolders ) @@ -117,7 +117,7 @@ public class ModularDatabaseCreationContext implements DatabaseCreationContext this.databaseName = databaseName; this.config = platformModule.config; this.idGeneratorFactory = editionModule.idGeneratorFactory; - this.directoryStructure = platformModule.storeLayout.databaseLayout( databaseName ); + this.databaseLayout = platformModule.storeLayout.databaseLayout( databaseName ); this.logService = platformModule.logging; this.scheduler = platformModule.jobScheduler; this.globalDependencies = platformModule.dependencies; @@ -135,7 +135,7 @@ public class ModularDatabaseCreationContext implements DatabaseCreationContext this.transactionHeaderInformationFactory = editionModule.headerInformationFactory; this.commitProcessFactory = editionModule.commitProcessFactory; this.autoIndexing = new InternalAutoIndexing( platformModule.config, tokenHolders.propertyKeyTokens() ); - this.indexConfigStore = new IndexConfigStore( directoryStructure, fs ); + this.indexConfigStore = new IndexConfigStore( databaseLayout, fs ); this.explicitIndexProvider = new DefaultExplicitIndexProvider(); this.pageCache = platformModule.pageCache; this.constraintSemantics = editionModule.constraintSemantics; @@ -164,9 +164,9 @@ public String getDatabaseName() } @Override - public DatabaseLayout getDatabaseDirectoryStructure() + public DatabaseLayout getDatabaseLayout() { - return directoryStructure; + return databaseLayout; } @Override diff --git a/community/neo4j/src/test/java/org/neo4j/kernel/impl/storemigration/StoreUpgraderTest.java b/community/neo4j/src/test/java/org/neo4j/kernel/impl/storemigration/StoreUpgraderTest.java index 00fab9797d78e..315740a01bd73 100644 --- a/community/neo4j/src/test/java/org/neo4j/kernel/impl/storemigration/StoreUpgraderTest.java +++ b/community/neo4j/src/test/java/org/neo4j/kernel/impl/storemigration/StoreUpgraderTest.java @@ -35,7 +35,6 @@ import java.util.Collections; import java.util.List; -import org.neo4j.dbms.database.DatabaseManager; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.io.fs.FileSystemAbstraction; import org.neo4j.io.layout.DatabaseLayout; @@ -358,7 +357,7 @@ private StoreMigrationParticipant participantThatWillFailWhenMoving( final Strin return new AbstractStoreMigrationParticipant( "Failing" ) { @Override - public void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout storeLayout, String versionToUpgradeFrom, + public void moveMigratedFiles( DatabaseLayout migrationLayout, DatabaseLayout directoryLayout, String versionToUpgradeFrom, String versionToMigrateTo ) throws IOException { throw new IOException( failureMessage ); diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/impl/BackupStrategyWrapperTest.java b/enterprise/backup/src/test/java/org/neo4j/backup/impl/BackupStrategyWrapperTest.java index 395e12595922a..29b402c77d0ce 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/impl/BackupStrategyWrapperTest.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/impl/BackupStrategyWrapperTest.java @@ -523,8 +523,8 @@ private void fallbackToFullPasses() private OnlineBackupRequiredArguments requiredArguments( boolean fallbackToFull ) { File databaseDirectory = desiredBackupLayout.databaseDirectory(); - return new OnlineBackupRequiredArguments( userProvidedAddress, databaseDirectory.getParentFile().toPath(), databaseDirectory.getName(), - SelectedBackupProtocol.ANY, fallbackToFull, true, 1000, reportDir ); + return new OnlineBackupRequiredArguments( userProvidedAddress, desiredBackupLayout.getStoreLayout().storeDirectory().toPath(), + databaseDirectory.getName(), SelectedBackupProtocol.ANY, fallbackToFull, true, 1000, reportDir ); } private static ConsistencyFlags consistencyFlags() diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandCcIT.java b/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandCcIT.java index 423640b63b503..05c1df4876a92 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandCcIT.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandCcIT.java @@ -509,7 +509,7 @@ public static DbRepresentation getBackupDbRepresentation( String name, File stor { Config config = Config.defaults(); config.augment( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ); - return DbRepresentation.of( new File( storeDir, name ), config ); + return DbRepresentation.of( DatabaseLayout.of( storeDir, name ).databaseDirectory(), config ); } private int runBackupToolFromOtherJvmToGetExitCode( String... args ) throws Exception diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandHaIT.java b/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandHaIT.java index 14c6431d4e365..7b25c90b15647 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandHaIT.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandHaIT.java @@ -54,6 +54,7 @@ import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.io.ByteUnit; import org.neo4j.io.fs.DefaultFileSystemAbstraction; +import org.neo4j.io.layout.DatabaseLayout; import org.neo4j.io.layout.StoreLayout; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.configuration.Settings; @@ -486,6 +487,6 @@ private static int runSameJvm( File home, String name, String... args ) private DbRepresentation getBackupDbRepresentation( String name ) { Config config = Config.defaults( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ); - return DbRepresentation.of( new File( backupDir, name ), config ); + return DbRepresentation.of( DatabaseLayout.of( backupDir, name ).databaseDirectory(), config ); } } diff --git a/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupCoreIT.java b/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupCoreIT.java index 0e4a5bffa9cfe..c62e9ce63568a 100644 --- a/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupCoreIT.java +++ b/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupCoreIT.java @@ -39,6 +39,7 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.factory.GraphDatabaseSettings; import org.neo4j.helpers.collection.MapUtil; +import org.neo4j.io.layout.DatabaseLayout; import org.neo4j.kernel.configuration.Config; import org.neo4j.kernel.impl.enterprise.configuration.OnlineBackupSettings; import org.neo4j.kernel.impl.store.format.standard.Standard; @@ -87,7 +88,7 @@ public void makeSureBackupCanBePerformedFromAnyInstance() throws Throwable DbRepresentation afterChange = DbRepresentation.of( createSomeData( cluster ) ); // Verify that old data is back - DbRepresentation backupRepresentation = DbRepresentation.of( new File( backupsDir, "" + db.serverId() ), getConfig() ); + DbRepresentation backupRepresentation = DbRepresentation.of( DatabaseLayout.of( backupsDir, "" + db.serverId() ).databaseDirectory(), getConfig() ); assertEquals( beforeChange, backupRepresentation ); assertNotEquals( backupRepresentation, afterChange ); } diff --git a/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupReadReplicaIT.java b/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupReadReplicaIT.java index 8a3e04b3be53b..564254d03b38d 100644 --- a/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupReadReplicaIT.java +++ b/enterprise/backup/src/test/java/org/neo4j/causalclustering/BackupReadReplicaIT.java @@ -32,6 +32,7 @@ import org.neo4j.causalclustering.core.CoreGraphDatabase; import org.neo4j.causalclustering.discovery.Cluster; import org.neo4j.causalclustering.readreplica.ReadReplicaGraphDatabase; +import org.neo4j.io.layout.DatabaseLayout; import org.neo4j.kernel.configuration.Settings; import org.neo4j.kernel.impl.enterprise.configuration.OnlineBackupSettings; import org.neo4j.kernel.impl.transaction.log.TransactionIdStore; @@ -90,7 +91,7 @@ public void makeSureBackupCanBePerformed() throws Throwable DbRepresentation afterChange = DbRepresentation.of( createSomeData( cluster ) ); // Verify that backed up database can be started and compare representation - DbRepresentation backupRepresentation = DbRepresentation.of( new File( backupPath, "readreplica" ), getConfig() ); + DbRepresentation backupRepresentation = DbRepresentation.of( DatabaseLayout.of( backupPath, "readreplica" ).databaseDirectory(), getConfig() ); assertEquals( beforeChange, backupRepresentation ); assertNotEquals( backupRepresentation, afterChange ); } diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/CommitStateHelper.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/CommitStateHelper.java index 889cca4422c67..0c31cd4a2e05d 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/CommitStateHelper.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/CommitStateHelper.java @@ -101,7 +101,6 @@ private Optional getLatestTransactionLogIndex( long startTxId, DatabaseLay public boolean hasTxLogs( DatabaseLayout databaseLayout ) { - //TODO incorrect lookup of transaction logs File[] files = fs.listFiles( databaseLayout.databaseDirectory(), TransactionLogFiles.DEFAULT_FILENAME_FILTER ); if ( files == null ) { diff --git a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/TemporaryStoreDirectory.java b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/TemporaryStoreDirectory.java index a4319182170c2..49274cb6343e6 100644 --- a/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/TemporaryStoreDirectory.java +++ b/enterprise/causal-clustering/src/main/java/org/neo4j/causalclustering/catchup/storecopy/TemporaryStoreDirectory.java @@ -44,8 +44,7 @@ public class TemporaryStoreDirectory implements AutoCloseable public TemporaryStoreDirectory( FileSystemAbstraction fs, PageCache pageCache, File parent ) throws IOException { this.tempStoreDir = new File( parent, TEMP_COPY_DIRECTORY_NAME ); - // TODO - this.tempDatabaseLayout = DatabaseLayout.of( new File( tempStoreDir, DatabaseManager.DEFAULT_DATABASE_NAME ) ); + this.tempDatabaseLayout = DatabaseLayout.of( tempStoreDir, DatabaseManager.DEFAULT_DATABASE_NAME ); storeFiles = new StoreFiles( fs, pageCache, ( directory, name ) -> true ); tempLogFiles = LogFilesBuilder.logFilesBasedOnlyBuilder( tempDatabaseLayout.databaseDirectory(), fs ).build(); storeFiles.delete( tempStoreDir, tempLogFiles ); diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/GetDatabaseStoreMarshalTest.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/GetStoreFileMarshalTest.java similarity index 98% rename from enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/GetDatabaseStoreMarshalTest.java rename to enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/GetStoreFileMarshalTest.java index f350164a76c2c..bd2edce8b951f 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/GetDatabaseStoreMarshalTest.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/GetStoreFileMarshalTest.java @@ -33,7 +33,7 @@ import static org.junit.Assert.assertEquals; -public class GetDatabaseStoreMarshalTest +public class GetStoreFileMarshalTest { EmbeddedChannel embeddedChannel;