From 4c19eb762e6d4fdc398ccdd77fbf5cb8d0496afc Mon Sep 17 00:00:00 2001 From: MishaDemianenko Date: Tue, 17 Jul 2018 19:20:14 +0200 Subject: [PATCH] Rename methods that expose database directory and not a store dir to represent that. Clean some related tests. --- .../checking/IndexConsistencyIT.java | 4 +- .../ImportToolNumericalFailureTest.java | 4 +- .../org/neo4j/tooling/ImportToolTest.java | 10 +- .../index/IndexFailureOnStartupTest.java | 2 +- .../lucene/explicit/BatchInsertionIT.java | 12 +- .../impl/lucene/explicit/RecoveryTest.java | 6 +- .../kernel/api/impl/schema/FusionIndexIT.java | 2 +- .../neo4j/test/ImpermanentGraphDatabase.java | 4 +- .../org/neo4j/test/rule/DatabaseRule.java | 19 +- .../neo4j/test/rule/EmbeddedDatabaseRule.java | 6 +- .../NativeLabelScanStoreStartupIT.java | 4 +- .../impl/core/TestShutdownSequence.java | 4 +- .../transaction/log/pruning/LogPruningIT.java | 2 +- .../state/NeoStoreFileListingTest.java | 14 +- .../impl/factory/GraphDatabaseFacade.java | 8 +- .../kernel/internal/GraphDatabaseAPI.java | 5 +- .../internal/KernelDiagnosticsTest.java | 4 - .../org/neo4j/harness/JUnitRuleTestIT.java | 4 +- .../graphdb/facade/spi/ClassicCoreSPI.java | 2 +- .../facade/spi/ProcedureGDBFacadeSPI.java | 14 +- .../factory/module/ProcedureGDSFactory.java | 4 +- .../server/database/WrappedDatabase.java | 2 +- .../kernel/ReadOnlyGraphDatabaseProxy.java | 4 +- .../src/test/java/org/neo4j/shell/AppsIT.java | 2 +- .../java/org/neo4j/shell/StartClientIT.java | 6 +- .../backup/OnlineBackupKernelExtension.java | 2 +- .../neo4j/restore/RestoreDatabaseCommand.java | 2 +- .../backup/impl/BackupProtocolServiceIT.java | 31 +- .../catchup/storecopy/CatchupServerIT.java | 2 +- .../scenarios/ReadReplicaReplicationIT.java | 2 +- .../neo4j/com/storecopy/StoreCopyServer.java | 8 +- .../ha/HighlyAvailableGraphDatabase.java | 5 - .../ha/cluster/DefaultMasterImplSPI.java | 6 +- .../java/org/neo4j/ha/BranchedDataIT.java | 4 +- .../neo4j/ha/upgrade/LegacyDatabaseImpl.java | 6 +- .../neo4j/ha/upgrade/RollingUpgradeIT.java | 544 ------------------ .../org/neo4j/kernel/api/SchemaIndexHaIT.java | 6 +- .../neo4j/kernel/impl/ha/ClusterManager.java | 4 +- .../java/org/neo4j/test/ha/ClusterIT.java | 16 +- ...ConsistencyCheckServiceRecordFormatIT.java | 4 +- .../ext/udc/impl/UdcExtensionImplIT.java | 2 +- .../java/org/neo4j/ha/HAClusterStartupIT.java | 6 +- .../PageCacheWarmupEnterpriseEditionIT.java | 8 +- .../neo4j/storeupgrade/StoreUpgradeIT.java | 4 +- .../stresstests/StartStopRandomCore.java | 4 +- .../stresstests/StartStopRandomMember.java | 4 +- .../tools/applytx/DatabaseRebuildTool.java | 8 +- 47 files changed, 134 insertions(+), 692 deletions(-) delete mode 100644 enterprise/ha/src/test/java/org/neo4j/ha/upgrade/RollingUpgradeIT.java diff --git a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/IndexConsistencyIT.java b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/IndexConsistencyIT.java index f38ddffc0ba9c..e1e7118f2355c 100644 --- a/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/IndexConsistencyIT.java +++ b/community/community-it/consistency-it/src/test/java/org/neo4j/consistency/checking/IndexConsistencyIT.java @@ -102,10 +102,10 @@ public void reportNotCleanNativeIndex() throws IOException, ConsistencyCheckInco @Test public void reportNotCleanNativeIndexWithCorrectData() throws IOException, ConsistencyCheckIncompleteException { - File storeDir = db.getStoreDir(); + File databaseDir = db.databaseDirectory(); someData(); resolveComponent( CheckPointer.class ).forceCheckPoint( new SimpleTriggerInfo( "forcedCheckpoint" ) ); - File indexesCopy = new File( storeDir, "indexesCopy" ); + File indexesCopy = new File( databaseDir, "indexesCopy" ); File indexSources = resolveComponent( DefaultIndexProviderMap.class ).getDefaultProvider().directoryStructure().rootDirectory(); copyRecursively( indexSources, indexesCopy, SOURCE_COPY_FILE_FILTER ); diff --git a/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolNumericalFailureTest.java b/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolNumericalFailureTest.java index 00e66ab522e31..837fd2cfe6cc6 100644 --- a/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolNumericalFailureTest.java +++ b/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolNumericalFailureTest.java @@ -115,7 +115,7 @@ public void test() throws Exception try { // WHEN - importTool( "--into", dbRule.getStoreDirAbsolutePath(), "--quote", "'", "--nodes", data.getAbsolutePath() ); + importTool( "--into", dbRule.getDatabaseDirAbsolutePath(), "--quote", "'", "--nodes", data.getAbsolutePath() ); // THEN fail( "Expected import to fail" ); } @@ -132,6 +132,6 @@ private String fileName( String name ) private File file( String localname ) { - return new File( dbRule.getStoreDir(), localname ); + return new File( dbRule.databaseDirectory(), localname ); } } diff --git a/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolTest.java b/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolTest.java index 1fd1293a3be28..8433670d6eb23 100644 --- a/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolTest.java +++ b/community/community-it/import-it/src/test/java/org/neo4j/tooling/ImportToolTest.java @@ -1927,11 +1927,11 @@ public void shouldKeepStoreFilesAfterFailedImport() throws Exception // WHEN data file contains more columns than header file int extraColumns = 3; - String storeDir = dbRule.getStoreDirAbsolutePath(); + String databaseDir = dbRule.getDatabaseDirAbsolutePath(); try { importTool( - "--into", storeDir, + "--into", databaseDir, "--nodes", nodeHeader( config ).getAbsolutePath() + MULTI_FILE_DELIMITER + nodeData( false, config, nodeIds, TRUE, Charset.defaultCharset(), extraColumns ).getAbsolutePath() ); fail( "Should have thrown exception" ); @@ -1943,7 +1943,7 @@ public void shouldKeepStoreFilesAfterFailedImport() throws Exception { if ( storeType.isRecordStore() ) { - assertTrue( new File( storeDir, MetaDataStore.DEFAULT_NAME + storeType.getStoreName() ).exists() ); + assertTrue( new File( databaseDir, MetaDataStore.DEFAULT_NAME + storeType.getStoreName() ).exists() ); } } @@ -1984,7 +1984,7 @@ public void shouldFailIfSupplyingBothFileArgumentAndAnyOtherArgument() throws Ex String arguments = format( "--into %s%n" + "--nodes %s --relationships %s", - dbRule.getStoreDirAbsolutePath(), + dbRule.getDatabaseDirAbsolutePath(), nodeData( true, config, nodeIds, TRUE ).getAbsolutePath(), relationshipData( true, config, nodeIds, TRUE, true ).getAbsolutePath() ); writeToFile( argumentFile, arguments, false ); @@ -1992,7 +1992,7 @@ public void shouldFailIfSupplyingBothFileArgumentAndAnyOtherArgument() throws Ex try { // when - importTool( "-f", argumentFile.getAbsolutePath(), "--into", dbRule.getStoreDirAbsolutePath() ); + importTool( "-f", argumentFile.getAbsolutePath(), "--into", dbRule.getDatabaseDirAbsolutePath() ); fail( "Should have failed" ); } catch ( IllegalArgumentException e ) diff --git a/community/community-it/index-it/src/test/java/org/neo4j/index/IndexFailureOnStartupTest.java b/community/community-it/index-it/src/test/java/org/neo4j/index/IndexFailureOnStartupTest.java index bd9badb244993..6fb0336caca35 100644 --- a/community/community-it/index-it/src/test/java/org/neo4j/index/IndexFailureOnStartupTest.java +++ b/community/community-it/index-it/src/test/java/org/neo4j/index/IndexFailureOnStartupTest.java @@ -144,7 +144,7 @@ private File archiveFile() throws IOException { try ( FileSystemAbstraction fs = new DefaultFileSystemAbstraction() ) { - File indexDir = indexRootDirectory( db.getStoreDir() ); + File indexDir = indexRootDirectory( db.databaseDirectory() ); File[] files = indexDir.listFiles( pathname -> pathname.isFile() && pathname.getName().startsWith( "archive-" ) ); if ( files == null || files.length == 0 ) { diff --git a/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/BatchInsertionIT.java b/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/BatchInsertionIT.java index fb71db1909eff..55ac13fabad4e 100644 --- a/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/BatchInsertionIT.java +++ b/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/BatchInsertionIT.java @@ -30,7 +30,6 @@ import org.neo4j.graphdb.Transaction; import org.neo4j.kernel.impl.store.id.IdGeneratorImpl; import org.neo4j.kernel.impl.store.id.validation.ReservedIdException; -import org.neo4j.kernel.impl.transaction.state.DataSourceManager; import org.neo4j.test.rule.EmbeddedDatabaseRule; import org.neo4j.test.rule.fs.DefaultFileSystemRule; import org.neo4j.unsafe.batchinsert.BatchInserter; @@ -53,7 +52,7 @@ public class BatchInsertionIT public void shouldIndexNodesWithMultipleLabels() throws Exception { // Given - File path = new File( dbRule.getStoreDirAbsolutePath(), DataSourceManager.DEFAULT_DATABASE_NAME ); + File path = dbRule.databaseDirectory(); BatchInserter inserter = BatchInserters.inserter( path, fileSystemRule.get() ); inserter.createNode( map( "name", "Bob" ), label( "User" ), label( "Admin" ) ); @@ -75,14 +74,13 @@ public void shouldIndexNodesWithMultipleLabels() throws Exception { db.shutdown(); } - } @Test public void shouldNotIndexNodesWithWrongLabel() throws Exception { // Given - File file = new File( dbRule.getStoreDirAbsolutePath() ); + File file = new File( dbRule.getDatabaseDirAbsolutePath() ); BatchInserter inserter = BatchInserters.inserter( file, fileSystemRule.get() ); inserter.createNode( map("name", "Bob"), label( "User" ), label("Admin")); @@ -108,7 +106,7 @@ public void shouldNotIndexNodesWithWrongLabel() throws Exception @Test public void shouldBeAbleToMakeRepeatedCallsToSetNodeProperty() throws Exception { - File file = dbRule.getStoreDirFile(); + File file = dbRule.databaseDirectory(); BatchInserter inserter = BatchInserters.inserter( file, fileSystemRule.get() ); long nodeId = inserter.createNode( Collections.emptyMap() ); @@ -134,7 +132,7 @@ public void shouldBeAbleToMakeRepeatedCallsToSetNodeProperty() throws Exception @Test public void shouldBeAbleToMakeRepeatedCallsToSetNodePropertyWithMultiplePropertiesPerBlock() throws Exception { - File file = new File( dbRule.getStoreDirAbsolutePath(), DataSourceManager.DEFAULT_DATABASE_NAME ); + File file = dbRule.databaseDirectory(); BatchInserter inserter = BatchInserters.inserter( file, fileSystemRule.get() ); long nodeId = inserter.createNode( Collections.emptyMap() ); @@ -164,7 +162,7 @@ public void shouldBeAbleToMakeRepeatedCallsToSetNodePropertyWithMultipleProperti public void makeSureCantCreateNodeWithMagicNumber() throws IOException { // given - File path = new File( dbRule.getStoreDirAbsolutePath() ); + File path = dbRule.databaseDirectory(); BatchInserter inserter = BatchInserters.inserter( path, fileSystemRule.get() ); try diff --git a/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/RecoveryTest.java b/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/RecoveryTest.java index 99288c10bb94a..50bd4defe625a 100644 --- a/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/RecoveryTest.java +++ b/community/community-it/index-it/src/test/java/org/neo4j/index/impl/lucene/explicit/RecoveryTest.java @@ -146,7 +146,7 @@ public void testIndexDeleteIssue() throws Exception public void recoveryForRelationshipCommandsOnly() throws Throwable { // shutdown db here - File storeDir = db.getStoreDirFile(); + File databaseDir = db.databaseDirectory(); shutdownDB(); try ( Transaction tx = db.beginTx() ) @@ -163,8 +163,8 @@ public void recoveryForRelationshipCommandsOnly() throws Throwable db.shutdown(); Config config = Config.defaults(); - IndexConfigStore indexStore = new IndexConfigStore( storeDir, fileSystemRule.get() ); - LuceneDataSource ds = new LuceneDataSource( storeDir, config, indexStore, fileSystemRule.get(), OperationalMode.single ); + IndexConfigStore indexStore = new IndexConfigStore( databaseDir, fileSystemRule.get() ); + LuceneDataSource ds = new LuceneDataSource( databaseDir, config, indexStore, fileSystemRule.get(), OperationalMode.single ); ds.start(); ds.stop(); } diff --git a/community/community-it/index-it/src/test/java/org/neo4j/kernel/api/impl/schema/FusionIndexIT.java b/community/community-it/index-it/src/test/java/org/neo4j/kernel/api/impl/schema/FusionIndexIT.java index 344cfc0d5455c..3953d962a474e 100644 --- a/community/community-it/index-it/src/test/java/org/neo4j/kernel/api/impl/schema/FusionIndexIT.java +++ b/community/community-it/index-it/src/test/java/org/neo4j/kernel/api/impl/schema/FusionIndexIT.java @@ -64,7 +64,7 @@ public class FusionIndexIT @Before public void setup() { - databaseDirectory = db.getStoreDir(); + databaseDirectory = db.databaseDirectory(); fs = db.getDependencyResolver().resolveDependency( FileSystemAbstraction.class ); } diff --git a/community/community-it/it-test-support/src/main/java/org/neo4j/test/ImpermanentGraphDatabase.java b/community/community-it/it-test-support/src/main/java/org/neo4j/test/ImpermanentGraphDatabase.java index a2146c81fe51d..1600282c21994 100644 --- a/community/community-it/it-test-support/src/main/java/org/neo4j/test/ImpermanentGraphDatabase.java +++ b/community/community-it/it-test-support/src/main/java/org/neo4j/test/ImpermanentGraphDatabase.java @@ -157,7 +157,7 @@ protected PlatformModule createPlatform( File storeDir, Config config, Dependenc }.initFacade( storeDir, params, dependencies, this ); } - private void trackUnclosedUse( File storeDir ) + private static void trackUnclosedUse( File storeDir ) { if ( TRACK_UNCLOSED_DATABASE_INSTANCES ) { @@ -175,7 +175,7 @@ public void shutdown() { if ( TRACK_UNCLOSED_DATABASE_INSTANCES ) { - startedButNotYetClosed.remove( getStoreDir() ); + startedButNotYetClosed.remove( databaseDirectory() ); } super.shutdown(); diff --git a/community/community-it/it-test-support/src/main/java/org/neo4j/test/rule/DatabaseRule.java b/community/community-it/it-test-support/src/main/java/org/neo4j/test/rule/DatabaseRule.java index bfd57b54d37d7..b0098cd10d33a 100644 --- a/community/community-it/it-test-support/src/main/java/org/neo4j/test/rule/DatabaseRule.java +++ b/community/community-it/it-test-support/src/main/java/org/neo4j/test/rule/DatabaseRule.java @@ -67,7 +67,7 @@ public abstract class DatabaseRule extends ExternalResource implements GraphData { private GraphDatabaseBuilder databaseBuilder; private GraphDatabaseAPI database; - private File storeDir; + private File databaseDir; private Supplier statementSupplier; private boolean startEagerly = true; private Map, String> config; @@ -342,7 +342,7 @@ public synchronized void ensureStarted( String... additionalConfig ) { applyConfigChanges( additionalConfig ); database = (GraphDatabaseAPI) databaseBuilder.newGraphDatabase(); - storeDir = database.getStoreDir(); + databaseDir = database.databaseDirectory(); statementSupplier = resolveDependency( ThreadToStatementContextBridge.class ); } } @@ -386,7 +386,7 @@ public GraphDatabaseAPI restartDatabase( RestartAction action, String... configC { FileSystemAbstraction fs = resolveDependency( FileSystemAbstraction.class ); database.shutdown(); - action.run( fs, storeDir ); + action.run( fs, databaseDir ); database = null; applyConfigChanges( configChanges ); return getGraphDatabaseAPI(); @@ -459,19 +459,14 @@ public StoreId storeId() } @Override - public File getStoreDir() + public File databaseDirectory() { - return database.getStoreDir(); + return database.databaseDirectory(); } - public String getStoreDirAbsolutePath() + public String getDatabaseDirAbsolutePath() { - return getStoreDir().getAbsolutePath(); - } - - public File getStoreDirFile() - { - return getStoreDir(); + return databaseDirectory().getAbsolutePath(); } @Override diff --git a/community/community-it/it-test-support/src/main/java/org/neo4j/test/rule/EmbeddedDatabaseRule.java b/community/community-it/it-test-support/src/main/java/org/neo4j/test/rule/EmbeddedDatabaseRule.java index 75e9933b9e4f1..cba2c75ea09fd 100644 --- a/community/community-it/it-test-support/src/main/java/org/neo4j/test/rule/EmbeddedDatabaseRule.java +++ b/community/community-it/it-test-support/src/main/java/org/neo4j/test/rule/EmbeddedDatabaseRule.java @@ -51,15 +51,15 @@ public EmbeddedDatabaseRule startLazily() } @Override - public File getStoreDir() + public File databaseDirectory() { return testDirectory.graphDbDir(); } @Override - public String getStoreDirAbsolutePath() + public String getDatabaseDirAbsolutePath() { - return testDirectory.directory().getAbsolutePath(); + return databaseDirectory().getAbsolutePath(); } @Override diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/NativeLabelScanStoreStartupIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/NativeLabelScanStoreStartupIT.java index 4c36e28c516b2..107b7f95ea372 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/NativeLabelScanStoreStartupIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/graphdb/NativeLabelScanStoreStartupIT.java @@ -63,7 +63,7 @@ public void scanStoreStartWithoutExistentIndex() throws Throwable labelScanStore.shutdown(); workCollector.shutdown(); - deleteLabelScanStoreFiles( dbRule.getStoreDir() ); + deleteLabelScanStoreFiles( dbRule.databaseDirectory() ); workCollector.init(); labelScanStore.init(); @@ -86,7 +86,7 @@ public void scanStoreRecreateCorruptedIndexOnStartup() throws Throwable labelScanStore.shutdown(); workCollector.shutdown(); - corruptLabelScanStoreFiles( dbRule.getStoreDir() ); + corruptLabelScanStoreFiles( dbRule.databaseDirectory() ); workCollector.init(); labelScanStore.init(); diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestShutdownSequence.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestShutdownSequence.java index 644012d5a4e02..f8c55704e082a 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestShutdownSequence.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/core/TestShutdownSequence.java @@ -92,7 +92,7 @@ public void canRemoveFilesAndReinvokeShutdown() throws IOException GraphDatabaseAPI databaseAPI = (GraphDatabaseAPI) this.graphDb; FileSystemAbstraction fileSystemAbstraction = getDatabaseFileSystem( databaseAPI ); graphDb.shutdown(); - fileSystemAbstraction.deleteRecursively( databaseAPI.getStoreDir() ); + fileSystemAbstraction.deleteRecursively( databaseAPI.databaseDirectory() ); graphDb.shutdown(); } @@ -128,7 +128,7 @@ public ExecutionOrder orderComparedTo( KernelEventHandler other ) graphDb.shutdown(); } - private FileSystemAbstraction getDatabaseFileSystem( GraphDatabaseAPI databaseAPI ) + private static FileSystemAbstraction getDatabaseFileSystem( GraphDatabaseAPI databaseAPI ) { return databaseAPI.getDependencyResolver().resolveDependency( FileSystemAbstraction.class ); } diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/transaction/log/pruning/LogPruningIT.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/transaction/log/pruning/LogPruningIT.java index fd169abeff710..ec47d22cb2b06 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/transaction/log/pruning/LogPruningIT.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/transaction/log/pruning/LogPruningIT.java @@ -55,7 +55,7 @@ public void pruningStrategyShouldBeDynamic() throws IOException Config config = getInstanceFromDb( Config.class ); FileSystemAbstraction fs = getInstanceFromDb( FileSystemAbstraction.class ); - LogFiles logFiles = LogFilesBuilder.builder( db.getStoreDir(), fs ) + LogFiles logFiles = LogFilesBuilder.builder( db.databaseDirectory(), fs ) .withLogVersionRepository( new SimpleLogVersionRepository() ) .withLastCommittedTransactionIdSupplier( () -> 1 ) .withTransactionIdStore( new SimpleTransactionIdStore() ).build(); diff --git a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/transaction/state/NeoStoreFileListingTest.java b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/transaction/state/NeoStoreFileListingTest.java index b421d1c4e412b..f3a9b5d5185d2 100644 --- a/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/transaction/state/NeoStoreFileListingTest.java +++ b/community/community-it/kernel-it/src/test/java/org/neo4j/kernel/impl/transaction/state/NeoStoreFileListingTest.java @@ -238,7 +238,7 @@ private void verifyLogFilesWithCustomPathListing( String path ) throws IOExcepti graphDatabase.shutdown(); } - private void filesInStoreDirAre( File storeDir, String[] filenames, String[] dirs ) + private static void filesInStoreDirAre( File storeDir, String[] filenames, String[] dirs ) { ArrayList files = new ArrayList<>(); mockFiles( filenames, files, false ); @@ -246,7 +246,7 @@ private void filesInStoreDirAre( File storeDir, String[] filenames, String[] dir when( storeDir.listFiles() ).thenReturn( files.toArray( new File[files.size()] ) ); } - private ResourceIterator scanStoreFilesAre( LabelScanStore labelScanStore, String[] fileNames ) + private static ResourceIterator scanStoreFilesAre( LabelScanStore labelScanStore, String[] fileNames ) { ArrayList files = new ArrayList<>(); mockFiles( fileNames, files, false ); @@ -255,7 +255,7 @@ private ResourceIterator scanStoreFilesAre( LabelScanStore labelScanStore, return snapshot; } - private ResourceIterator indexFilesAre( IndexingService indexingService, String[] fileNames ) + private static ResourceIterator indexFilesAre( IndexingService indexingService, String[] fileNames ) throws IOException { ArrayList files = new ArrayList<>(); @@ -267,15 +267,15 @@ private ResourceIterator indexFilesAre( IndexingService indexingService, S private void createIndexDbFile() throws IOException { - File storeDir = db.getStoreDir(); - final File indexFile = new File( storeDir, "index.db" ); + File databaseDir = db.databaseDirectory(); + final File indexFile = new File( databaseDir, "index.db" ); if ( !indexFile.exists() ) { assertTrue( indexFile.createNewFile() ); } } - private void mockFiles( String[] filenames, ArrayList files, boolean isDirectories ) + private static void mockFiles( String[] filenames, ArrayList files, boolean isDirectories ) { for ( String filename : filenames ) { @@ -295,7 +295,7 @@ private void mockFiles( String[] filenames, ArrayList files, boolean isDir private static class MarkerFileProvider implements NeoStoreFileListing.StoreFileProvider { @Override - public Resource addFilesTo( Collection fileMetadataCollection ) throws IOException + public Resource addFilesTo( Collection fileMetadataCollection ) { fileMetadataCollection.add( new StoreFileMetadata( new File( "marker" ), 0 ) ); return Resource.EMPTY; diff --git a/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java b/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java index e9a21c846a339..00705ee48ca1a 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/impl/factory/GraphDatabaseFacade.java @@ -157,7 +157,7 @@ public interface SPI StoreId storeId(); - File storeDir(); + File databaseDirectory(); /** Eg. Neo4j Enterprise HA, Neo4j Community Standalone.. */ String name(); @@ -916,15 +916,15 @@ public URL validateURLAccess( URL url ) throws URLAccessValidationError } @Override - public File getStoreDir() + public File databaseDirectory() { - return spi.storeDir(); + return spi.databaseDirectory(); } @Override public String toString() { - return spi.name() + " [" + getStoreDir() + "]"; + return spi.name() + " [" + databaseDirectory() + "]"; } @Override diff --git a/community/kernel/src/main/java/org/neo4j/kernel/internal/GraphDatabaseAPI.java b/community/kernel/src/main/java/org/neo4j/kernel/internal/GraphDatabaseAPI.java index d7bbe2d8080fe..e9f7590640e0f 100644 --- a/community/kernel/src/main/java/org/neo4j/kernel/internal/GraphDatabaseAPI.java +++ b/community/kernel/src/main/java/org/neo4j/kernel/internal/GraphDatabaseAPI.java @@ -53,7 +53,10 @@ public interface GraphDatabaseAPI extends GraphDatabaseService */ URL validateURLAccess( URL url ) throws URLAccessValidationError; - File getStoreDir(); + /** + * @return underlying database directory + */ + File databaseDirectory(); /** * Begin internal transaction with specified type and access mode diff --git a/community/kernel/src/test/java/org/neo4j/kernel/internal/KernelDiagnosticsTest.java b/community/kernel/src/test/java/org/neo4j/kernel/internal/KernelDiagnosticsTest.java index 85aa77314c01f..2d99330ebd2f8 100644 --- a/community/kernel/src/test/java/org/neo4j/kernel/internal/KernelDiagnosticsTest.java +++ b/community/kernel/src/test/java/org/neo4j/kernel/internal/KernelDiagnosticsTest.java @@ -46,10 +46,6 @@ public void shouldPrintDiskUsage() @Test public void shouldCountFileSizeRecursively() { - // Mock a file structure: - // storeDir/indexDir/indexFile (1 kB) - // storeDir/neostore (3 kB) - File indexFile = Mockito.mock( File.class ); Mockito.when( indexFile.isDirectory() ).thenReturn( false ); Mockito.when( indexFile.getName() ).thenReturn( "indexFile" ); diff --git a/community/neo4j-harness/src/test/java/org/neo4j/harness/JUnitRuleTestIT.java b/community/neo4j-harness/src/test/java/org/neo4j/harness/JUnitRuleTestIT.java index a3d73cde0994a..d78e5a14d75c5 100644 --- a/community/neo4j-harness/src/test/java/org/neo4j/harness/JUnitRuleTestIT.java +++ b/community/neo4j-harness/src/test/java/org/neo4j/harness/JUnitRuleTestIT.java @@ -164,8 +164,8 @@ public void shouldUseSystemTimeZoneForLogging() throws Exception private String contentOf( String file ) throws IOException { - Path storeDir = ((GraphDatabaseAPI) neo4j.getGraphDatabaseService()).getStoreDir().toPath(); - Path testDir = storeDir.getParent().getParent(); + Path databaseDirectory = ((GraphDatabaseAPI) neo4j.getGraphDatabaseService()).databaseDirectory().toPath(); + Path testDir = databaseDirectory.getParent().getParent(); return new String( Files.readAllBytes( testDir.resolve( file ) ), UTF_8 ); } diff --git a/community/neo4j/src/main/java/org/neo4j/graphdb/facade/spi/ClassicCoreSPI.java b/community/neo4j/src/main/java/org/neo4j/graphdb/facade/spi/ClassicCoreSPI.java index b35871141bd70..a86edf4fee5e5 100644 --- a/community/neo4j/src/main/java/org/neo4j/graphdb/facade/spi/ClassicCoreSPI.java +++ b/community/neo4j/src/main/java/org/neo4j/graphdb/facade/spi/ClassicCoreSPI.java @@ -129,7 +129,7 @@ public StoreId storeId() } @Override - public File storeDir() + public File databaseDirectory() { return dataSource.neoStoreDataSource.getDatabaseDirectory(); } diff --git a/community/neo4j/src/main/java/org/neo4j/graphdb/facade/spi/ProcedureGDBFacadeSPI.java b/community/neo4j/src/main/java/org/neo4j/graphdb/facade/spi/ProcedureGDBFacadeSPI.java index 76fab63831601..97ff9ac39e109 100644 --- a/community/neo4j/src/main/java/org/neo4j/graphdb/facade/spi/ProcedureGDBFacadeSPI.java +++ b/community/neo4j/src/main/java/org/neo4j/graphdb/facade/spi/ProcedureGDBFacadeSPI.java @@ -28,7 +28,6 @@ import org.neo4j.graphdb.event.KernelEventHandler; import org.neo4j.graphdb.event.TransactionEventHandler; import org.neo4j.graphdb.factory.module.DataSourceModule; -import org.neo4j.graphdb.factory.module.PlatformModule; import org.neo4j.graphdb.security.URLAccessValidationError; import org.neo4j.internal.kernel.api.Kernel; import org.neo4j.internal.kernel.api.exceptions.TransactionFailureException; @@ -46,18 +45,17 @@ public class ProcedureGDBFacadeSPI implements GraphDatabaseFacade.SPI { - private final File storeDir; + private final File databaseDirectory; private final DataSourceModule sourceModule; private final DependencyResolver resolver; private final CoreAPIAvailabilityGuard availability; private final ThrowingFunction urlValidator; private final SecurityContext securityContext; - public ProcedureGDBFacadeSPI( PlatformModule platform, DataSourceModule sourceModule, DependencyResolver resolver, - CoreAPIAvailabilityGuard availability, ThrowingFunction urlValidator, - SecurityContext securityContext ) + public ProcedureGDBFacadeSPI( DataSourceModule sourceModule, DependencyResolver resolver, CoreAPIAvailabilityGuard availability, + ThrowingFunction urlValidator, SecurityContext securityContext ) { - this.storeDir = platform.storeDir; + this.databaseDirectory = sourceModule.neoStoreDataSource.getDatabaseDirectory(); this.sourceModule = sourceModule; this.resolver = resolver; this.availability = availability; @@ -84,9 +82,9 @@ public StoreId storeId() } @Override - public File storeDir() + public File databaseDirectory() { - return storeDir; + return databaseDirectory; } @Override diff --git a/community/neo4j/src/main/java/org/neo4j/graphdb/factory/module/ProcedureGDSFactory.java b/community/neo4j/src/main/java/org/neo4j/graphdb/factory/module/ProcedureGDSFactory.java index 1fd06ca938152..d370766d1b692 100644 --- a/community/neo4j/src/main/java/org/neo4j/graphdb/factory/module/ProcedureGDSFactory.java +++ b/community/neo4j/src/main/java/org/neo4j/graphdb/factory/module/ProcedureGDSFactory.java @@ -65,9 +65,7 @@ public GraphDatabaseService apply( Context context ) throws ProcedureException } GraphDatabaseFacade facade = new GraphDatabaseFacade(); facade.init( - new ProcedureGDBFacadeSPI( - platform, - dataSource, + new ProcedureGDBFacadeSPI( dataSource, dataSource.neoStoreDataSource.getDependencyResolver(), availability, urlValidator, diff --git a/community/server/src/main/java/org/neo4j/server/database/WrappedDatabase.java b/community/server/src/main/java/org/neo4j/server/database/WrappedDatabase.java index 23c4552ac806c..73dbbc8fa6477 100644 --- a/community/server/src/main/java/org/neo4j/server/database/WrappedDatabase.java +++ b/community/server/src/main/java/org/neo4j/server/database/WrappedDatabase.java @@ -44,7 +44,7 @@ public WrappedDatabase( GraphDatabaseFacade graph ) @Override public File getLocation() { - return graph.getStoreDir(); + return graph.databaseDirectory(); } @Override diff --git a/community/shell/src/main/java/org/neo4j/shell/kernel/ReadOnlyGraphDatabaseProxy.java b/community/shell/src/main/java/org/neo4j/shell/kernel/ReadOnlyGraphDatabaseProxy.java index aa682e08e0278..5f2d2f8669aa0 100644 --- a/community/shell/src/main/java/org/neo4j/shell/kernel/ReadOnlyGraphDatabaseProxy.java +++ b/community/shell/src/main/java/org/neo4j/shell/kernel/ReadOnlyGraphDatabaseProxy.java @@ -1062,9 +1062,9 @@ public DependencyResolver getDependencyResolver() } @Override - public File getStoreDir() + public File databaseDirectory() { - return actual.getStoreDir(); + return actual.databaseDirectory(); } @Override diff --git a/community/shell/src/test/java/org/neo4j/shell/AppsIT.java b/community/shell/src/test/java/org/neo4j/shell/AppsIT.java index c60aeb50e55cb..cac3e90666c02 100644 --- a/community/shell/src/test/java/org/neo4j/shell/AppsIT.java +++ b/community/shell/src/test/java/org/neo4j/shell/AppsIT.java @@ -1340,7 +1340,7 @@ private void verifyNumberOfCommits( String query, long expectedCommitCount ) long txIdBeforeQuery = lastClosedTxId(); // When - startClient.start( new String[]{"-path", db.getStoreDir().getAbsolutePath(), "-c", query}, ctrlCHandler ); + startClient.start( new String[]{"-path", db.databaseDirectory().getAbsolutePath(), "-c", query}, ctrlCHandler ); // then long txId = lastClosedTxId(); diff --git a/community/shell/src/test/java/org/neo4j/shell/StartClientIT.java b/community/shell/src/test/java/org/neo4j/shell/StartClientIT.java index a8481c3af5a41..82f5eb46c3a49 100644 --- a/community/shell/src/test/java/org/neo4j/shell/StartClientIT.java +++ b/community/shell/src/test/java/org/neo4j/shell/StartClientIT.java @@ -152,7 +152,7 @@ protected GraphDatabaseShellServer getGraphDatabaseShellServer( File path, boole }; // when - startClient.start( new String[]{"-path", db.getStoreDir().getAbsolutePath(), "-c", "CREATE (n {foo:'bar'});"}, + startClient.start( new String[]{"-path", db.databaseDirectory().getAbsolutePath(), "-c", "CREATE (n {foo:'bar'});"}, ctrlCHandler ); // verify @@ -169,7 +169,7 @@ public void shouldReportEditionThroughDbInfoApp() StartClient client = new StartClient( new PrintStream( out ), new PrintStream( err ) ); // when - client.start( new String[]{"-path", db.getStoreDir().getAbsolutePath() + "testDb", "-c", + client.start( new String[]{"-path", db.databaseDirectory().getAbsolutePath() + "testDb", "-c", "dbinfo -g Configuration unsupported.dbms.edition"}, ctrlCHandler ); // then @@ -212,7 +212,7 @@ protected GraphDatabaseShellServer getGraphDatabaseShellServer( File path, boole shellServer = new GraphDatabaseShellServer( factory, path, readOnly, configFile ); return shellServer; } - }.start( new String[]{"-c", "RETURN 1;", "-path", db.getStoreDir().getAbsolutePath() + "test-db", "-config", + }.start( new String[]{"-c", "RETURN 1;", "-path", db.databaseDirectory().getAbsolutePath() + "test-db", "-config", getClass().getResource( "/config-with-bolt-connector.conf" ).getFile()}, mock( CtrlCHandler.class ) ); try { diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupKernelExtension.java b/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupKernelExtension.java index 332178f22776a..0af562e1c01cb 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupKernelExtension.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/OnlineBackupKernelExtension.java @@ -92,7 +92,7 @@ public OnlineBackupKernelExtension( Config config, final GraphDatabaseAPI graphD DependencyResolver dependencyResolver = graphDatabaseAPI.getDependencyResolver(); TransactionIdStore transactionIdStore = dependencyResolver.resolveDependency( TransactionIdStore.class ); StoreCopyServer copier = new StoreCopyServer( neoStoreDataSource, dependencyResolver.resolveDependency( CheckPointer.class ), - fileSystemAbstraction, graphDatabaseAPI.getStoreDir(), + fileSystemAbstraction, graphDatabaseAPI.databaseDirectory(), monitors.newMonitor( StoreCopyServer.Monitor.class ) ); LogicalTransactionStore logicalTransactionStore = dependencyResolver.resolveDependency( LogicalTransactionStore.class ); LogFileInformation logFileInformation = dependencyResolver.resolveDependency( LogFileInformation.class ); diff --git a/enterprise/backup/src/main/java/org/neo4j/restore/RestoreDatabaseCommand.java b/enterprise/backup/src/main/java/org/neo4j/restore/RestoreDatabaseCommand.java index e665b721d6309..75efda6d67f8a 100644 --- a/enterprise/backup/src/main/java/org/neo4j/restore/RestoreDatabaseCommand.java +++ b/enterprise/backup/src/main/java/org/neo4j/restore/RestoreDatabaseCommand.java @@ -54,7 +54,7 @@ public RestoreDatabaseCommand( FileSystemAbstraction fs, File fromDatabasePath, this.fromDatabasePath = fromDatabasePath; this.forceOverwrite = forceOverwrite; this.toDatabaseName = toDatabaseName; - this.toDatabaseDir = new File(config.get( database_path ), toDatabaseName ).getAbsoluteFile(); + this.toDatabaseDir = new File( config.get( database_path ), toDatabaseName ).getAbsoluteFile(); this.transactionLogsDirectory = config.get( GraphDatabaseSettings.logical_logs_location ).getAbsoluteFile(); } diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/impl/BackupProtocolServiceIT.java b/enterprise/backup/src/test/java/org/neo4j/backup/impl/BackupProtocolServiceIT.java index 1d6ccdc1b1558..5b69afb31422b 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/impl/BackupProtocolServiceIT.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/impl/BackupProtocolServiceIT.java @@ -147,7 +147,7 @@ public void write( int b ) private final Monitors monitors = new Monitors(); private final IOLimiter limiter = IOLimiter.UNLIMITED; private FileSystemAbstraction fileSystem; - private Path storeDir; + private Path databaseDirectory; private Path backupDatabaseDir; private Path backupStoreDir; private int backupPort = -1; @@ -170,7 +170,7 @@ public void setup() throws IOException { fileSystem = fileSystemRule.get(); backupPort = PortAuthority.allocatePort(); - storeDir = dbRule.getStoreDirFile().getParentFile().toPath(); + databaseDirectory = dbRule.databaseDirectory().getParentFile().toPath(); backupStoreDir = target.directory( "backupStore" ).toPath(); backupDatabaseDir = backupStoreDir.resolve( DataSourceManager.DEFAULT_DATABASE_NAME ); Files.createDirectories( backupDatabaseDir ); @@ -232,7 +232,8 @@ public Log getLog( String name ) } }; - backupService( logProvider ).doIncrementalBackupOrFallbackToFull( BACKUP_HOST, backupPort, backupDatabaseDir, ConsistencyCheck.NONE, Config.defaults(), BackupClient.BIG_READ_TIMEOUT, false ); + backupService( logProvider ).doIncrementalBackupOrFallbackToFull( BACKUP_HOST, backupPort, backupDatabaseDir, ConsistencyCheck.NONE, Config.defaults(), + BackupClient.BIG_READ_TIMEOUT, false ); verify( log ).info( "Previous backup not found, a new full backup will be performed." ); } @@ -277,7 +278,8 @@ public Log getLog( String name ) } }; - backupService( logProvider ).doIncrementalBackupOrFallbackToFull( BACKUP_HOST, backupPort, backupDatabaseDir, ConsistencyCheck.NONE, Config.defaults(), BackupClient.BIG_READ_TIMEOUT, false ); + backupService( logProvider ).doIncrementalBackupOrFallbackToFull( BACKUP_HOST, backupPort, backupDatabaseDir, ConsistencyCheck.NONE, Config.defaults(), + BackupClient.BIG_READ_TIMEOUT, false ); verify( log ).info( "Previous backup found, trying incremental backup." ); verify( log ).info( "Existing backup is too far out of date, a new full backup will be performed." ); @@ -894,11 +896,9 @@ public void shouldContainTransactionsThatHappenDuringBackupProcess() throws Thro Dependencies dependencies = new Dependencies( resolver ); dependencies.satisfyDependencies( defaultConfig, monitors, NullLogProvider.getInstance() ); - OnlineBackupKernelExtension backup = (OnlineBackupKernelExtension) - new OnlineBackupExtensionFactory().newInstance( - new SimpleKernelContext( storeDir.toFile(), DatabaseInfo.UNKNOWN, dependencies ), - DependenciesProxy.dependencies( dependencies, OnlineBackupExtensionFactory.Dependencies.class ) - ); + OnlineBackupKernelExtension backup = (OnlineBackupKernelExtension) new OnlineBackupExtensionFactory().newInstance( + new SimpleKernelContext( databaseDirectory.toFile(), DatabaseInfo.UNKNOWN, dependencies ), + DependenciesProxy.dependencies( dependencies, OnlineBackupExtensionFactory.Dependencies.class ) ); backup.start(); // when @@ -914,8 +914,8 @@ public void shouldContainTransactionsThatHappenDuringBackupProcess() throws Thro barrier.release(); } ); - BackupOutcome backupOutcome = backupProtocolService.doFullBackup( BACKUP_HOST, backupPort, backupDatabaseDir, ConsistencyCheck.FULL, withOnlineBackupDisabled, - BackupClient.BIG_READ_TIMEOUT, false ); + BackupOutcome backupOutcome = backupProtocolService.doFullBackup( BACKUP_HOST, backupPort, backupDatabaseDir, ConsistencyCheck.FULL, + withOnlineBackupDisabled, BackupClient.BIG_READ_TIMEOUT, false ); backup.stop(); executor.shutdown(); @@ -923,7 +923,7 @@ public void shouldContainTransactionsThatHappenDuringBackupProcess() throws Thro // then checkPreviousCommittedTxIdFromLog( 0, expectedLastTxId ); - Path neoStore = db.getStoreDir().toPath().resolve( MetaDataStore.DEFAULT_NAME ); + Path neoStore = db.databaseDirectory().toPath().resolve( MetaDataStore.DEFAULT_NAME ); PageCache pageCache = resolver.resolveDependency( PageCache.class ); long txIdFromOrigin = MetaDataStore.getRecord( pageCache, neoStore.toFile(), Position.LAST_TRANSACTION_ID ); checkLastCommittedTxIdInLogAndNeoStore( expectedLastTxId + 1, txIdFromOrigin ); @@ -967,7 +967,7 @@ public Log getLog( String name ) OnlineBackupKernelExtension backup = (OnlineBackupKernelExtension) new OnlineBackupExtensionFactory().newInstance( - new SimpleKernelContext( storeDir.toFile(), DatabaseInfo.UNKNOWN, dependencies ), + new SimpleKernelContext( databaseDirectory.toFile(), DatabaseInfo.UNKNOWN, dependencies ), DependenciesProxy.dependencies( dependencies, OnlineBackupExtensionFactory.Dependencies.class ) ); try @@ -1146,7 +1146,8 @@ private void deleteAllBackedUpTransactionLogs() throws IOException private void doIncrementalBackupOrFallbackToFull() { BackupProtocolService backupProtocolService = backupService(); - backupProtocolService.doIncrementalBackupOrFallbackToFull( BACKUP_HOST, backupPort, backupDatabaseDir, ConsistencyCheck.NONE, Config.defaults(), BackupClient.BIG_READ_TIMEOUT, false ); + backupProtocolService.doIncrementalBackupOrFallbackToFull( BACKUP_HOST, backupPort, backupDatabaseDir, ConsistencyCheck.NONE, Config.defaults(), + BackupClient.BIG_READ_TIMEOUT, false ); } private static Node findNodeByLabel( GraphDatabaseAPI graphDatabase, Label label ) @@ -1166,7 +1167,7 @@ private DbRepresentation getBackupDbRepresentation() private DbRepresentation getDbRepresentation() { Config config = Config.defaults( OnlineBackupSettings.online_backup_enabled, Settings.FALSE ); - return DbRepresentation.of( storeDir.toFile(), config ); + return DbRepresentation.of( databaseDirectory.toFile(), config ); } private static final class StoreSnoopingMonitor extends StoreCopyServer.Monitor.Adapter diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/CatchupServerIT.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/CatchupServerIT.java index a92b9650861d5..93997db209a3a 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/CatchupServerIT.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/catchup/storecopy/CatchupServerIT.java @@ -227,7 +227,7 @@ public void individualFileCopyFailsIfStoreIdMismatch() throws Exception { // given a file exists on the server addData( graphDb ); - File expectedExistingFile = new File( graphDb.getStoreDir(), EXISTING_FILE_NAME ); + File expectedExistingFile = new File( graphDb.databaseDirectory(), EXISTING_FILE_NAME ); // and SimpleCatchupClient simpleCatchupClient = new SimpleCatchupClient( graphDb, fsa, catchupClient, catchupServer, temporaryDirectory, LOG_PROVIDER ); diff --git a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/scenarios/ReadReplicaReplicationIT.java b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/scenarios/ReadReplicaReplicationIT.java index 39e3e2402a802..eb66eb2f660a7 100644 --- a/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/scenarios/ReadReplicaReplicationIT.java +++ b/enterprise/causal-clustering/src/test/java/org/neo4j/causalclustering/scenarios/ReadReplicaReplicationIT.java @@ -227,7 +227,7 @@ public void shouldEventuallyPullTransactionDownToAllReadReplicas() throws Except private static void gatherLabelScanStoreFiles( GraphDatabaseAPI db, Set labelScanStoreFiles ) { - Path dbStoreDirectory = db.getStoreDir().toPath().toAbsolutePath(); + Path dbStoreDirectory = db.databaseDirectory().toPath().toAbsolutePath(); LabelScanStore labelScanStore = db.getDependencyResolver().resolveDependency( LabelScanStore.class ); try ( ResourceIterator files = labelScanStore.snapshotStoreFiles() ) { diff --git a/enterprise/com/src/main/java/org/neo4j/com/storecopy/StoreCopyServer.java b/enterprise/com/src/main/java/org/neo4j/com/storecopy/StoreCopyServer.java index 8238f5644da4f..d93e5fa077f99 100644 --- a/enterprise/com/src/main/java/org/neo4j/com/storecopy/StoreCopyServer.java +++ b/enterprise/com/src/main/java/org/neo4j/com/storecopy/StoreCopyServer.java @@ -119,16 +119,16 @@ public void finishStreamingTransactions( long endTxId, String storeCopyIdentifie private final NeoStoreDataSource dataSource; private final CheckPointer checkPointer; private final FileSystemAbstraction fileSystem; - private final File storeDirectory; + private final File databaseDirectory; private final Monitor monitor; public StoreCopyServer( NeoStoreDataSource dataSource, CheckPointer checkPointer, FileSystemAbstraction fileSystem, - File storeDirectory, Monitor monitor ) + File databaseDirectory, Monitor monitor ) { this.dataSource = dataSource; this.checkPointer = checkPointer; this.fileSystem = fileSystem; - this.storeDirectory = getMostCanonicalFile( storeDirectory ); + this.databaseDirectory = getMostCanonicalFile( databaseDirectory ); this.monitor = monitor; } @@ -199,7 +199,7 @@ private void doWrite( StoreWriter writer, ByteBuffer temporaryBuffer, File file, ReadableByteChannel fileChannel, long fileSize, String storeCopyIdentifier, boolean isLogFile ) throws IOException { monitor.startStreamingStoreFile( file, storeCopyIdentifier ); - String path = isLogFile ? file.getName() : relativePath( storeDirectory, file ); + String path = isLogFile ? file.getName() : relativePath( databaseDirectory, file ); writer.write( path, fileChannel, temporaryBuffer, fileSize > 0, recordSize ); monitor.finishStreamingStoreFile( file, storeCopyIdentifier ); } diff --git a/enterprise/ha/src/main/java/org/neo4j/kernel/ha/HighlyAvailableGraphDatabase.java b/enterprise/ha/src/main/java/org/neo4j/kernel/ha/HighlyAvailableGraphDatabase.java index 38c56016fb742..2de7f7db82800 100644 --- a/enterprise/ha/src/main/java/org/neo4j/kernel/ha/HighlyAvailableGraphDatabase.java +++ b/enterprise/ha/src/main/java/org/neo4j/kernel/ha/HighlyAvailableGraphDatabase.java @@ -78,9 +78,4 @@ public boolean isMaster() { return HighAvailabilityModeSwitcher.MASTER.equalsIgnoreCase( role() ); } - - public File getStoreDirectory() - { - return getStoreDir(); - } } diff --git a/enterprise/ha/src/main/java/org/neo4j/kernel/ha/cluster/DefaultMasterImplSPI.java b/enterprise/ha/src/main/java/org/neo4j/kernel/ha/cluster/DefaultMasterImplSPI.java index 88a047def6e98..27195ec50a356 100644 --- a/enterprise/ha/src/main/java/org/neo4j/kernel/ha/cluster/DefaultMasterImplSPI.java +++ b/enterprise/ha/src/main/java/org/neo4j/kernel/ha/cluster/DefaultMasterImplSPI.java @@ -65,7 +65,7 @@ public class DefaultMasterImplSPI implements MasterImpl.SPI private final TokenHolders tokenHolders; private final IdGeneratorFactory idGeneratorFactory; private final NeoStoreDataSource neoStoreDataSource; - private final File storeDir; + private final File databaseDirectory; private final ResponsePacker responsePacker; private final Monitors monitors; @@ -91,7 +91,7 @@ public DefaultMasterImplSPI( final GraphDatabaseAPI graphDb, this.transactionCommitProcess = transactionCommitProcess; this.checkPointer = checkPointer; this.neoStoreDataSource = neoStoreDataSource; - this.storeDir = graphDb.getStoreDir(); + this.databaseDirectory = graphDb.databaseDirectory(); this.txChecksumLookup = new TransactionChecksumLookup( transactionIdStore, logicalTransactionStore ); this.responsePacker = new ResponsePacker( logicalTransactionStore, transactionIdStore, graphDb::storeId ); this.monitors = monitors; @@ -155,7 +155,7 @@ public long getTransactionChecksum( long txId ) throws IOException @Override public RequestContext flushStoresAndStreamStoreFiles( StoreWriter writer ) { - StoreCopyServer streamer = new StoreCopyServer( neoStoreDataSource, checkPointer, fileSystem, storeDir, + StoreCopyServer streamer = new StoreCopyServer( neoStoreDataSource, checkPointer, fileSystem, databaseDirectory, monitors.newMonitor( StoreCopyServer.Monitor.class, StoreCopyServer.class.getName() ) ); return streamer.flushStoresAndStreamStoreFiles( STORE_COPY_CHECKPOINT_TRIGGER, writer, false ); } diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/BranchedDataIT.java b/enterprise/ha/src/test/java/org/neo4j/ha/BranchedDataIT.java index 681eb323a7163..64d8df6c8f3f3 100644 --- a/enterprise/ha/src/test/java/org/neo4j/ha/BranchedDataIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/ha/BranchedDataIT.java @@ -131,12 +131,12 @@ public void shouldCopyStoreFromMasterIfBranched() throws Throwable // WHEN HighlyAvailableGraphDatabase slave = cluster.getAnySlave(); - File storeDir = slave.getStoreDir(); + File databaseDir = slave.databaseDirectory(); RepairKit starter = cluster.shutdown( slave ); HighlyAvailableGraphDatabase master = cluster.getMaster(); createNode( master, "B1" ); createNode( master, "C" ); - createNodeOffline( storeDir, "B2" ); + createNodeOffline( databaseDir, "B2" ); slave = starter.repair(); // THEN diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/LegacyDatabaseImpl.java b/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/LegacyDatabaseImpl.java index b0e948d2103bb..7d5d5dbab7fdf 100644 --- a/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/LegacyDatabaseImpl.java +++ b/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/LegacyDatabaseImpl.java @@ -35,6 +35,7 @@ import org.neo4j.graphdb.Node; import org.neo4j.graphdb.Relationship; +import org.neo4j.graphdb.RelationshipType; import org.neo4j.graphdb.Transaction; import org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory; import org.neo4j.helpers.Args; @@ -52,12 +53,13 @@ import static java.util.concurrent.Executors.newSingleThreadExecutor; import static java.util.concurrent.TimeUnit.SECONDS; import static org.junit.Assert.fail; -import static org.neo4j.ha.upgrade.RollingUpgradeIT.type1; -import static org.neo4j.ha.upgrade.RollingUpgradeIT.type2; import static org.neo4j.ha.upgrade.Utils.execJava; public class LegacyDatabaseImpl extends UnicastRemoteObject implements LegacyDatabase { + private RelationshipType type1 = RelationshipType.withName( "type1" ); + private RelationshipType type2 = RelationshipType.withName( "type2" ); + // This has to be adapted to the way HA GDB is started in the specific old version it's used for. public static void main( String[] args ) throws Exception { diff --git a/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/RollingUpgradeIT.java b/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/RollingUpgradeIT.java deleted file mode 100644 index 78a6973582041..0000000000000 --- a/enterprise/ha/src/test/java/org/neo4j/ha/upgrade/RollingUpgradeIT.java +++ /dev/null @@ -1,544 +0,0 @@ -/* - * Copyright (c) 2002-2018 "Neo4j," - * Neo4j Sweden AB [http://neo4j.com] - * - * This file is part of Neo4j Enterprise Edition. The included source - * code can be redistributed and/or modified under the terms of the - * GNU AFFERO GENERAL PUBLIC LICENSE Version 3 - * (http://www.fsf.org/licensing/licenses/agpl-3.0.html) with the - * Commons Clause, as found in the associated LICENSE.txt file. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU Affero General Public License for more details. - * - * Neo4j object code can be licensed independently from the source - * under separate terms from the AGPL. Inquiries can be directed to: - * licensing@neo4j.com - * - * More information is also available at: - * https://neo4j.com/licensing/ - */ -package org.neo4j.ha.upgrade; - -import org.junit.After; -import org.junit.Ignore; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.Parameterized; -import org.junit.runners.Parameterized.Parameters; - -import java.io.File; -import java.net.InetAddress; -import java.net.UnknownHostException; -import java.rmi.RemoteException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.List; -import java.util.Map; -import java.util.concurrent.Future; -import java.util.concurrent.TimeUnit; - -import org.neo4j.backup.OnlineBackup; -import org.neo4j.graphdb.GraphDatabaseService; -import org.neo4j.graphdb.Node; -import org.neo4j.graphdb.Relationship; -import org.neo4j.graphdb.RelationshipType; -import org.neo4j.graphdb.Transaction; -import org.neo4j.graphdb.factory.GraphDatabaseSettings; -import org.neo4j.graphdb.factory.TestHighlyAvailableGraphDatabaseFactory; -import org.neo4j.helpers.collection.MapUtil; -import org.neo4j.helpers.collection.Pair; -import org.neo4j.io.fs.FileUtils; -import org.neo4j.kernel.ha.UpdatePuller; -import org.neo4j.kernel.impl.enterprise.configuration.OnlineBackupSettings; -import org.neo4j.kernel.internal.GraphDatabaseAPI; -import org.neo4j.test.TestGraphDatabaseFactory; -import org.neo4j.test.rule.TestDirectory; - -import static java.util.concurrent.TimeUnit.MINUTES; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; -import static org.neo4j.cluster.ClusterSettings.cluster_server; -import static org.neo4j.cluster.ClusterSettings.initial_hosts; -import static org.neo4j.cluster.ClusterSettings.server_id; -import static org.neo4j.ha.upgrade.Utils.assembleClassPathFromPackage; -import static org.neo4j.ha.upgrade.Utils.downloadAndUnpack; -import static org.neo4j.kernel.ha.HaSettings.ha_server; - -@Ignore( "Keep this test around as it's a very simple and 'close' test to quickly verify rolling upgrades" ) -@RunWith( Parameterized.class ) -public class RollingUpgradeIT -{ - private static final int CLUSTER_SIZE = 3; - - public static final RelationshipType type1 = RelationshipType.withName( "type1" ); - public static final RelationshipType type2 = RelationshipType.withName( "type2" ); - - @Rule - public TestDirectory testDirectory = TestDirectory.testDirectory(); - - private LegacyDatabase[] legacyDbs; - private GraphDatabaseAPI[] newDbs; - private long centralNode; - - private final String oldVersion; - - public RollingUpgradeIT( String oldVersion ) - { - this.oldVersion = oldVersion; - } - - @Parameters - public static Iterable oldVersions() - { - return Arrays.asList( new Object[][]{ - {"2.1.2"} - } ); - } - - @Test - public void doRollingUpgradeFromPreviousVersionWithMasterLast() throws Throwable - { - /* High level scenario: - * 1 Have a cluster of 3 instances running - * 1.1 Download a package - * 1.2 Unpack the package - * 1.4 Assembly classpath and start 3 JVMs running - * 1.5 Create some data in the cluster - * 2 Go over each one restarting into - * 2.1 Grab a JVM and kill it - * 2.2 Start that db inside this test JVM, which will run - * 2.3 Perform a write transaction to the current master and see that it picks it up - * 2.4 Perform a write transaction to to this instance and see that master picks it up - * 3 Make sure the cluster functions after each one has been restarted - * 3.1 Do basic transactions on master/slaves. - * 3.2 Do a master switch - * 3.3 Restart one slave - * 3.4 Take down the instances and do consistency check */ - - try - { - startOldVersionCluster(); - rollOverToNewVersion(); - shutdownAndDoConsistencyChecks(); - } - catch ( Throwable e ) - { - e.printStackTrace(); - throw e; - } - } - - private void shutdownAndDoConsistencyChecks() - { -/* - Collection storeDirs = new ArrayList<>( newDbs.length ); - for ( GraphDatabaseAPI item : newDbs ) - { - if ( item != null ) - { - storeDirs.add( item.getDatabaseDirectory() ); - item.shutdown(); - } - } - - ConsistencyCheckService service = new ConsistencyCheckService(); - for ( String storeDir : storeDirs ) - { - service.runFullConsistencyCheck( storeDir, Config.defaults(), - ProgressMonitorFactory.textual(System.out), StringLogger.SYSTEM ); - } -*/ - } - - private void debug( String message ) - { - debug( message, true ); - } - - private void debug( String message, boolean enter ) - { - // TODO come on, tests should not output to the screen. - String string = "RUT " + message; - if ( enter ) - { - System.out.println( string ); - } - else - { - System.out.print( string ); - } - } - - @After - public void cleanUp() - { - if ( legacyDbs != null ) - { - for ( int i = 0; i < legacyDbs.length; i++ ) - { - stop( i ); - } - } - if ( newDbs != null ) - { - for ( GraphDatabaseService db : newDbs ) - { - if ( db != null ) - { - db.shutdown(); - } - } - } - } - - private void startOldVersionCluster() throws Exception - { - debug( "Downloading " + oldVersion + " package" ); - File oldVersionPackage = downloadAndUnpack( - "http://neo4j.com/customer/download/neo4j-enterprise-" + oldVersion + "-windows.zip", - testDirectory.directory( "download" ), oldVersion + "-enterprise" ); - String classpath = assembleClassPathFromPackage( oldVersionPackage ); - debug( "Starting " + oldVersion + " cluster in separate jvms" ); - List> legacyDbFutures = new ArrayList<>( CLUSTER_SIZE ); - for ( int i = 0; i < CLUSTER_SIZE; i++ ) - { - Future dbStart = LegacyDatabaseImpl.start( classpath, storeDir( i ), config( i ) ); - legacyDbFutures.add( dbStart ); - debug( " Started " + i ); - } - legacyDbs = new LegacyDatabase[CLUSTER_SIZE]; - for ( int i = 0; i < CLUSTER_SIZE; i++ ) - { - legacyDbs[i] = legacyDbFutures.get( i ).get(); - } - - for ( LegacyDatabase db : legacyDbs ) - { - debug( " Awaiting " + db.getStoreDir() + " to start" ); - db.awaitStarted( 10, TimeUnit.SECONDS ); - debug( " " + db.getStoreDir() + " fully started" ); - } - for ( LegacyDatabase legacyDb : legacyDbs ) - { - long node = legacyDb.createNode(); - for ( LegacyDatabase db : legacyDbs ) - { - db.verifyNodeExists( node ); - } - } - debug( oldVersion + " cluster fully operational" ); - - centralNode = legacyDbs[0].initialize(); - } - - private File storeDir( int serverId ) - { - return new File( testDirectory.directory( "dbs" ), "" + serverId ); - } - - private Map config( int serverId ) throws UnknownHostException - { - String localhost = localhost(); - Map result = MapUtil.stringMap( - server_id.name(), "" + serverId, - cluster_server.name(), localhost + ":" + (5000 + serverId), - ha_server.name(), localhost + ":" + (6000 + serverId), - GraphDatabaseSettings.allow_upgrade.name(), "true", - GraphDatabaseSettings.pagecache_memory.name(), "8m", - OnlineBackupSettings.online_backup_server.name(), localhost + ":" + backupPort( serverId ), - initial_hosts.name(), localhost + ":" + 5000 + "," + localhost + ":" + 5001 + "," + localhost + ":" + 5002 ); - return result; - } - - private String localhost() throws UnknownHostException - { - return InetAddress.getLocalHost().getHostAddress(); - } - - private int backupPort( int serverId ) - { - return 6362 + serverId; - } - - private void rollOverToNewVersion() throws Exception - { - debug( "Starting to roll over to current version" ); - Pair master = findOutWhoIsMaster(); - newDbs = new GraphDatabaseAPI[legacyDbs.length]; - int authoritativeSlaveId = -1; - for ( int i = 0; i < legacyDbs.length; i++ ) - { - LegacyDatabase legacyDb = legacyDbs[i]; - if ( legacyDb == master.first() ) - { // Roll over the master last - debug( "master is " + master.first().getStoreDir() ); - continue; - } - - rollOver( legacyDb, i, master.other(), authoritativeSlaveId ); - if ( authoritativeSlaveId == -1 ) - { - authoritativeSlaveId = i; - } - } - rollOver( master.first(), master.other(), master.other(), -2 ); - } - - private void rollOver( LegacyDatabase legacyDb, int i, int masterServerId, int authoritativeSlaveId ) - throws Exception - { - String storeDir = legacyDb.getStoreDir(); - if ( i == 0 ) - { - storeDir += "new"; - } - stop( i ); - - File storeDirFile = new File( storeDir ); - debug( "Starting " + i + " as current version" ); - switch ( authoritativeSlaveId ) - { - case -1: - break; - case -2: - debug( "At last master starting, deleting store so that it fetches from the new master" ); - FileUtils.deleteRecursively( storeDirFile ); - break; - default: - debug( "Consecutive slave starting, making it so that I will copy store from " + authoritativeSlaveId ); - FileUtils.deleteRecursively( storeDirFile ); - storeDirFile.mkdirs(); - backup( authoritativeSlaveId, storeDirFile ); - break; - } - - startStandaloneDbToRunUpgrade( storeDirFile, i ); - - // start that db up in this JVM - newDbs[i] = (GraphDatabaseAPI) new TestHighlyAvailableGraphDatabaseFactory() - .newEmbeddedDatabaseBuilder( storeDirFile ) - .setConfig( config( i ) ) - .newGraphDatabase(); - debug( "Started " + i + " as current version" ); - legacyDbs[i] = null; - - // issue transaction and see that it propagates - if ( i != masterServerId ) - { - // if the instance is not the old master, create on the old master - legacyDbs[masterServerId].doComplexLoad( centralNode ); - debug( "Node created on " + i ); - } - else - { - doComplexLoad( newDbs[1], centralNode ); - } - for ( int j = 0; j < legacyDbs.length; j++ ) - { - if ( legacyDbs[j] != null ) - { - legacyDbs[j].verifyComplexLoad( centralNode ); - debug( "Verified on legacy db " + j ); - } - } - for ( int j = 0; j < newDbs.length; j++ ) - { - if ( newDbs[j] != null ) - { - assertTrue( "Rolled over database " + j + " not available within 1 minute", - newDbs[i].isAvailable( MINUTES.toMillis( 1 ) ) ); - verifyComplexLoad( newDbs[j], centralNode ); - debug( "Verified on new db " + j ); - } - } - } - - private void startStandaloneDbToRunUpgrade( File storeDir, int dbIndex ) - { - GraphDatabaseService tempDbForUpgrade = null; - try - { - debug( "Starting standalone db " + dbIndex + " to run upgrade" ); - tempDbForUpgrade = new TestGraphDatabaseFactory() - .newEmbeddedDatabaseBuilder( storeDir ) - .setConfig( GraphDatabaseSettings.allow_upgrade, "true" ) - .newGraphDatabase(); - } - finally - { - if ( tempDbForUpgrade != null ) - { - tempDbForUpgrade.shutdown(); - } - } - } - - private void backup( int sourceServerId, File targetDir ) throws UnknownHostException - { - OnlineBackup backup = OnlineBackup.from(localhost(), backupPort(sourceServerId)).backup( targetDir.getPath() ); - assertTrue( "Something wrong with the backup", backup.isConsistent() ); - } - - public void doComplexLoad( GraphDatabaseAPI db, long center ) - { - try ( Transaction tx = db.beginTx() ) - { - Node central = db.getNodeById( center ); - - long type1RelCount = central.getDegree( type1 ); - long type2RelCount = central.getDegree( type2 ); - - long[] type1RelId = new long[(int) type1RelCount]; - long[] type2RelId = new long[(int) type2RelCount]; - - int index = 0; - for ( Relationship relationship : central.getRelationships( type1 ) ) - { - type1RelId[index++] = relationship.getId(); - } - index = 0; - for ( Relationship relationship : central.getRelationships( type2 ) ) - { - type2RelId[index++] = relationship.getId(); - } - - // Delete the first half of each type - Arrays.sort( type1RelId ); - Arrays.sort( type2RelId ); - - for ( int i = 0; i < type1RelId.length / 2; i++ ) - { - db.getRelationshipById( type1RelId[i] ).delete(); - } - for ( int i = 0; i < type2RelId.length / 2; i++ ) - { - db.getRelationshipById( type2RelId[i] ).delete(); - } - - // Go ahead and create relationships to make up for these deletes - for ( int i = 0; i < type1RelId.length / 2; i++ ) - { - central.createRelationshipTo( db.createNode(), type1 ); - } - - long largestCreated = 0; - // The result is the id of the latest created relationship. We'll use that to set the properties - for ( int i = 0; i < type2RelId.length / 2; i++ ) - { - long current = central.createRelationshipTo( db.createNode(), type2 ).getId(); - if ( current > largestCreated ) - { - largestCreated = current; - } - } - - for ( Relationship relationship : central.getRelationships() ) - { - relationship.setProperty( "relProp", "relProp" + relationship.getId() + "-" + largestCreated ); - Node end = relationship.getEndNode(); - end.setProperty( "nodeProp", "nodeProp" + end.getId() + "-" + largestCreated ); - } - - tx.success(); - } - } - - public void verifyComplexLoad( GraphDatabaseAPI db, long centralNode ) throws InterruptedException - { - db.getDependencyResolver().resolveDependency( UpdatePuller.class ).pullUpdates(); - try ( Transaction tx = db.beginTx() ) - { - Node center = db.getNodeById( centralNode ); - long maxRelId = -1; - for ( Relationship relationship : center.getRelationships() ) - { - if ( relationship.getId() > maxRelId ) - { - maxRelId = relationship.getId(); - } - } - - int typeCount = 0; - for ( Relationship relationship : center.getRelationships( type1 ) ) - { - typeCount++; - if ( !relationship.getProperty( "relProp" ) - .equals( "relProp" + relationship.getId() + "-" + maxRelId ) ) - { - fail( "damn" ); - } - Node other = relationship.getEndNode(); - if ( !other.getProperty( "nodeProp" ).equals( "nodeProp" + other.getId() + "-" + maxRelId ) ) - { - fail( "double damn" ); - } - } - if ( typeCount != 100 ) - { - fail( "tripled damn" ); - } - - typeCount = 0; - for ( Relationship relationship : center.getRelationships( type2 ) ) - { - typeCount++; - if ( !relationship.getProperty( "relProp" ) - .equals( "relProp" + relationship.getId() + "-" + maxRelId ) ) - { - fail( "damn" ); - } - Node other = relationship.getEndNode(); - if ( !other.getProperty( "nodeProp" ).equals( "nodeProp" + other.getId() + "-" + maxRelId ) ) - { - fail( "double damn" ); - } - } - if ( typeCount != 100 ) - { - fail( "tripled damn" ); - } - tx.success(); - } - } - - private Pair findOutWhoIsMaster() - { - try - { - for ( int i = 0; i < legacyDbs.length; i++ ) - { - LegacyDatabase db = legacyDbs[i]; - if ( db.isMaster() ) - { - return Pair.of( db, i ); - } - } - } - catch ( RemoteException e ) - { - throw new RuntimeException( e ); - } - throw new IllegalStateException( "No master" ); - } - - private void stop( int i ) - { - try - { - LegacyDatabase legacyDb = legacyDbs[i]; - if ( legacyDb != null ) - { - legacyDb.stop(); - legacyDbs[i] = null; - } - } - catch ( RemoteException e ) - { - // OK - } - } -} diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/api/SchemaIndexHaIT.java b/enterprise/ha/src/test/java/org/neo4j/kernel/api/SchemaIndexHaIT.java index 257ee09b30a74..736ef6598b313 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/api/SchemaIndexHaIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/api/SchemaIndexHaIT.java @@ -320,9 +320,9 @@ private ClusterManager.RepairKit bringSlaveOfflineAndRemoveStoreFiles( ManagedCl { ClusterManager.RepairKit slaveDown = cluster.shutdown( slave ); - File storeDir = slave.getStoreDir(); - deleteRecursively( storeDir ); - storeDir.mkdir(); + File databaseDir = slave.databaseDirectory(); + deleteRecursively( databaseDir ); + databaseDir.mkdir(); return slaveDown; } diff --git a/enterprise/ha/src/test/java/org/neo4j/kernel/impl/ha/ClusterManager.java b/enterprise/ha/src/test/java/org/neo4j/kernel/impl/ha/ClusterManager.java index 5b40ee380d388..e69df76daa42a 100644 --- a/enterprise/ha/src/test/java/org/neo4j/kernel/impl/ha/ClusterManager.java +++ b/enterprise/ha/src/test/java/org/neo4j/kernel/impl/ha/ClusterManager.java @@ -888,7 +888,7 @@ public void stop() throws Throwable { if ( consistencyCheck ) { - consistencyCheck( db.getStoreDirectory() ); + consistencyCheck( db.databaseDirectory() ); } } } @@ -1356,7 +1356,7 @@ public InstanceId getServerId( HighlyAvailableGraphDatabase member ) public File getStoreDir( HighlyAvailableGraphDatabase member ) { assertMember( member ); - return member.getStoreDirectory(); + return member.databaseDirectory(); } public void sync( HighlyAvailableGraphDatabase... except ) diff --git a/enterprise/ha/src/test/java/org/neo4j/test/ha/ClusterIT.java b/enterprise/ha/src/test/java/org/neo4j/test/ha/ClusterIT.java index bab5e958fb3b8..93a41cec79b6c 100644 --- a/enterprise/ha/src/test/java/org/neo4j/test/ha/ClusterIT.java +++ b/enterprise/ha/src/test/java/org/neo4j/test/ha/ClusterIT.java @@ -290,10 +290,10 @@ public void lastTxCommitTimestampShouldGetInitializedOnSlaveIfNotPresent() throw cluster.sync(); HighlyAvailableGraphDatabase slave = cluster.getAnySlave(); - File storeDir = slave.getStoreDir(); + File databaseDir = slave.databaseDirectory(); ClusterManager.RepairKit slaveRepairKit = cluster.shutdown( slave ); - clearLastTransactionCommitTimestampField( storeDir ); + clearLastTransactionCommitTimestampField( databaseDir ); HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.repair(); cluster.await( allSeesAllAsAvailable() ); @@ -324,11 +324,11 @@ public void lastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent cluster.sync(); HighlyAvailableGraphDatabase slave = cluster.getAnySlave(); - File storeDir = slave.getStoreDir(); + File databaseDir = slave.databaseDirectory(); ClusterManager.RepairKit slaveRepairKit = cluster.shutdown( slave ); - clearLastTransactionCommitTimestampField( storeDir ); - deleteLogs( storeDir ); + clearLastTransactionCommitTimestampField( databaseDir ); + deleteLogs( databaseDir ); HighlyAvailableGraphDatabase repairedSlave = slaveRepairKit.repair(); cluster.await( allSeesAllAsAvailable() ); @@ -341,7 +341,7 @@ public void lastTxCommitTimestampShouldBeUnknownAfterStartIfNoFiledOrLogsPresent } } - private void createClusterWithNode( ClusterManager clusterManager ) throws Throwable + private static void createClusterWithNode( ClusterManager clusterManager ) throws Throwable { try { @@ -399,12 +399,12 @@ private static void runSomeTransactions( HighlyAvailableGraphDatabase db ) } } - private static void clearLastTransactionCommitTimestampField( File storeDir ) throws IOException + private static void clearLastTransactionCommitTimestampField( File databaseDirectory ) throws IOException { try ( FileSystemAbstraction fileSystem = new DefaultFileSystemAbstraction(); PageCache pageCache = createPageCache( fileSystem ) ) { - File neoStore = new File( storeDir, MetaDataStore.DEFAULT_NAME ); + File neoStore = new File( databaseDirectory, MetaDataStore.DEFAULT_NAME ); MetaDataStore.setRecord( pageCache, neoStore, LAST_TRANSACTION_COMMIT_TIMESTAMP, MetaDataStore.BASE_TX_COMMIT_TIMESTAMP ); } diff --git a/enterprise/neo4j-enterprise/src/test/java/org/neo4j/consistency/ConsistencyCheckServiceRecordFormatIT.java b/enterprise/neo4j-enterprise/src/test/java/org/neo4j/consistency/ConsistencyCheckServiceRecordFormatIT.java index a43a94f3a4544..eb75221361c6b 100644 --- a/enterprise/neo4j-enterprise/src/test/java/org/neo4j/consistency/ConsistencyCheckServiceRecordFormatIT.java +++ b/enterprise/neo4j-enterprise/src/test/java/org/neo4j/consistency/ConsistencyCheckServiceRecordFormatIT.java @@ -117,8 +117,8 @@ private static void assertConsistentStore( GraphDatabaseAPI db ) throws Exceptio { ConsistencyCheckService service = new ConsistencyCheckService(); - File storeDir = db.getStoreDir(); - ConsistencyCheckService.Result result = service.runFullConsistencyCheck( storeDir, Config.defaults(), + File databaseDir = db.databaseDirectory(); + ConsistencyCheckService.Result result = service.runFullConsistencyCheck( databaseDir, Config.defaults(), ProgressMonitorFactory.textual( System.out ), FormattedLogProvider.toOutputStream( System.out ), true ); assertTrue( "Store is inconsistent", result.isSuccessful() ); diff --git a/integrationtests/src/test/java/org/neo4j/ext/udc/impl/UdcExtensionImplIT.java b/integrationtests/src/test/java/org/neo4j/ext/udc/impl/UdcExtensionImplIT.java index bc2f3efec1876..131fc700abdc7 100644 --- a/integrationtests/src/test/java/org/neo4j/ext/udc/impl/UdcExtensionImplIT.java +++ b/integrationtests/src/test/java/org/neo4j/ext/udc/impl/UdcExtensionImplIT.java @@ -524,7 +524,7 @@ private void cleanup( GraphDatabaseService gdb ) throws IOException { GraphDatabaseAPI db = (GraphDatabaseAPI) gdb; gdb.shutdown(); - FileUtils.deleteDirectory( db.getStoreDir() ); + FileUtils.deleteDirectory( db.databaseDirectory() ); } } diff --git a/integrationtests/src/test/java/org/neo4j/ha/HAClusterStartupIT.java b/integrationtests/src/test/java/org/neo4j/ha/HAClusterStartupIT.java index a1e029a4948ba..1c10dc0b2fa34 100644 --- a/integrationtests/src/test/java/org/neo4j/ha/HAClusterStartupIT.java +++ b/integrationtests/src/test/java/org/neo4j/ha/HAClusterStartupIT.java @@ -246,12 +246,12 @@ private static void createSomeData( GraphDatabaseService oldMaster ) private static void deleteAllFilesOn( HighlyAvailableGraphDatabase instance ) throws IOException { - FileUtils.deleteRecursively( instance.getStoreDirectory() ); + FileUtils.deleteRecursively( instance.databaseDirectory() ); } private static void deleteAllLogsOn( HighlyAvailableGraphDatabase instance ) throws IOException { - deleteAllLogsOn( instance.getStoreDirectory() ); + deleteAllLogsOn( instance.databaseDirectory() ); } private static void deleteAllLogsOn( File storeDirectory ) throws IOException @@ -286,7 +286,7 @@ private static void assertAllStoreConsistent( ClusterManager.ManagedCluster clus { for ( HighlyAvailableGraphDatabase slave : cluster.getAllMembers() ) { - assertConsistentStore( slave.getStoreDirectory() ); + assertConsistentStore( slave.databaseDirectory() ); } } } diff --git a/integrationtests/src/test/java/org/neo4j/kernel/PageCacheWarmupEnterpriseEditionIT.java b/integrationtests/src/test/java/org/neo4j/kernel/PageCacheWarmupEnterpriseEditionIT.java index 61409dd9815e3..6a5f48ec2c79d 100644 --- a/integrationtests/src/test/java/org/neo4j/kernel/PageCacheWarmupEnterpriseEditionIT.java +++ b/integrationtests/src/test/java/org/neo4j/kernel/PageCacheWarmupEnterpriseEditionIT.java @@ -174,13 +174,13 @@ public void exit( int status ) } }, true ); - File storeDir = db.getStoreDir(); + File databaseDir = db.databaseDirectory(); File data = dir.cleanDirectory( "data" ); File databases = new File( data, "databases" ); File graphdb = new File( databases, DataSourceManager.DEFAULT_DATABASE_NAME ); assertTrue( graphdb.mkdirs() ); - FileUtils.copyRecursively( storeDir, graphdb ); - FileUtils.deleteRecursively( storeDir ); + FileUtils.copyRecursively( databaseDir, graphdb ); + FileUtils.deleteRecursively( databaseDir ); Path homePath = data.toPath().getParent(); File dumpDir = dir.cleanDirectory( "dump-dir" ); adminTool.execute( homePath, homePath, "dump", "--database=" + DataSourceManager.DEFAULT_DATABASE_NAME, "--to=" + dumpDir ); @@ -188,7 +188,7 @@ public void exit( int status ) FileUtils.deleteRecursively( graphdb ); File dumpFile = new File( dumpDir, "graph.db.dump" ); adminTool.execute( homePath, homePath, "load", "--database=" + DataSourceManager.DEFAULT_DATABASE_NAME, "--from=" + dumpFile ); - FileUtils.copyRecursively( graphdb, storeDir ); + FileUtils.copyRecursively( graphdb, databaseDir ); FileUtils.deleteRecursively( graphdb ); File metricsDirectory = dir.cleanDirectory( "metrics" ); diff --git a/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIT.java b/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIT.java index 4cf22649b3bc5..143c794c3e430 100644 --- a/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIT.java +++ b/integrationtests/src/test/java/org/neo4j/storeupgrade/StoreUpgradeIT.java @@ -265,8 +265,8 @@ public void migratingOlderDataAndThanStartAClusterUsingTheNewerDataShouldWork() clusterManager.safeShutdown(); } - assertConsistentStore( master.getStoreDir() ); - assertConsistentStore( slave.getStoreDir() ); + assertConsistentStore( master.databaseDirectory() ); + assertConsistentStore( slave.databaseDirectory() ); } } diff --git a/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/StartStopRandomCore.java b/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/StartStopRandomCore.java index 5d5f52f0620af..0a1fa9b0b8d28 100644 --- a/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/StartStopRandomCore.java +++ b/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/StartStopRandomCore.java @@ -56,10 +56,10 @@ class StartStopRandomCore extends RepeatOnRandomCore @Override protected void doWorkOnMember( ClusterMember member ) throws InterruptedException { - File storeDir = member.database().getStoreDir(); + File databaseDirectory = member.database().databaseDirectory(); log.info( "Stopping: " + member ); member.shutdown(); - assertStoreConsistent( storeDir ); + assertStoreConsistent( databaseDirectory ); Thread.sleep( 5000 ); log.info( "Starting: " + member ); member.start(); diff --git a/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/StartStopRandomMember.java b/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/StartStopRandomMember.java index 872d24c0c894f..89ee6628997c0 100644 --- a/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/StartStopRandomMember.java +++ b/stresstests/src/test/java/org/neo4j/causalclustering/stresstests/StartStopRandomMember.java @@ -56,10 +56,10 @@ class StartStopRandomMember extends RepeatOnRandomMember @Override protected void doWorkOnMember( ClusterMember member ) throws InterruptedException { - File storeDir = member.database().getStoreDir(); + File databaseDirectory = member.database().databaseDirectory(); log.info( "Stopping: " + member ); member.shutdown(); - assertStoreConsistent( storeDir ); + assertStoreConsistent( databaseDirectory ); Thread.sleep( 5000 ); log.info( "Starting: " + member ); member.start(); diff --git a/tools/src/main/java/org/neo4j/tools/applytx/DatabaseRebuildTool.java b/tools/src/main/java/org/neo4j/tools/applytx/DatabaseRebuildTool.java index db6ef0cb8c2bc..f926184a81b8d 100644 --- a/tools/src/main/java/org/neo4j/tools/applytx/DatabaseRebuildTool.java +++ b/tools/src/main/java/org/neo4j/tools/applytx/DatabaseRebuildTool.java @@ -168,14 +168,14 @@ private static class Store { private final GraphDatabaseAPI db; private final StoreAccess access; - private final File storeDir; + private final File databaseDirectory; Store( GraphDatabaseBuilder dbBuilder ) { this.db = (GraphDatabaseAPI) dbBuilder.newGraphDatabase(); this.access = new StoreAccess( db.getDependencyResolver() .resolveDependency( RecordStorageEngine.class ).testAccessNeoStores() ).initialize(); - this.storeDir = db.getStoreDir(); + this.databaseDirectory = db.databaseDirectory(); } public void shutdown() @@ -203,11 +203,11 @@ private ConsoleInput console( final File fromPath, final GraphDatabaseBuilder db @Override public void run( Args action, PrintStream out ) throws Exception { - File storeDir = store.get().storeDir; + File databaseDirectory = store.get().databaseDirectory; store.get().shutdown(); try { - Result result = new ConsistencyCheckService().runFullConsistencyCheck( storeDir, + Result result = new ConsistencyCheckService().runFullConsistencyCheck( databaseDirectory, Config.defaults(), ProgressMonitorFactory.textual( out ), FormattedLogProvider.toOutputStream( System.out ), false ); out.println( result.isSuccessful() ? "consistent" : "INCONSISTENT" );