diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommand.java b/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommand.java index 15d1e3311529f..3f053fc893727 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommand.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommand.java @@ -32,7 +32,7 @@ class OnlineBackupCommand implements AdminCommand { private final OutsideWorld outsideWorld; - private final OnlineBackupContextBuilder contextBuilder; + private final OnlineBackupContextFactory contextBuilder; private final BackupStrategyCoordinatorFactory backupStrategyCoordinatorFactory; private final BackupSupportingClassesFactory backupSupportingClassesFactory; @@ -44,7 +44,7 @@ class OnlineBackupCommand implements AdminCommand * @param backupSupportingClassesFactory necessary for constructing the strategy for backing up over the causal clustering transaction protocol * @param backupStrategyCoordinatorFactory class that actually handles the logic of performing a backup */ - OnlineBackupCommand( OutsideWorld outsideWorld, OnlineBackupContextBuilder contextBuilder, + OnlineBackupCommand( OutsideWorld outsideWorld, OnlineBackupContextFactory contextBuilder, BackupSupportingClassesFactory backupSupportingClassesFactory, BackupStrategyCoordinatorFactory backupStrategyCoordinatorFactory ) { diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommandBuilder.java b/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommandBuilder.java index 33fe82ba7ede3..c49daec49845f 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommandBuilder.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommandBuilder.java @@ -260,7 +260,7 @@ private String argSelectedProtocol() { return Optional.ofNullable( selectedBackupProtocol ) .map( SelectedBackupProtocol::getName ) - .map( argValue -> format( "--%s=%s", OnlineBackupContextBuilder.ARG_NAME_PROTO_OVERRIDE, argValue ) ) + .map( argValue -> format( "--%s=%s", OnlineBackupContextFactory.ARG_NAME_PROTO_OVERRIDE, argValue ) ) .orElse( "" ); } diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommandProvider.java b/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommandProvider.java index e1d24feca2a3c..405d3771daca7 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommandProvider.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupCommandProvider.java @@ -50,7 +50,7 @@ public OnlineBackupCommandProvider() @Nonnull public Arguments allArguments() { - return OnlineBackupContextBuilder.arguments(); + return OnlineBackupContextFactory.arguments(); } @Override @@ -89,7 +89,7 @@ public AdminCommand create( Path homeDir, Path configDir, OutsideWorld outsideWo LogProvider logProvider = FormattedLogProvider.withDefaultLogLevel( debug ? Level.DEBUG : Level.NONE ).toOutputStream( outsideWorld.outStream() ); Monitors monitors = new Monitors(); - OnlineBackupContextBuilder contextBuilder = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory contextBuilder = new OnlineBackupContextFactory( homeDir, configDir ); BackupModule backupModule = new BackupModule( outsideWorld, logProvider, monitors ); BackupSupportingClassesFactoryProvider classesFactoryProvider = diff --git a/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupContextBuilder.java b/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupContextFactory.java similarity index 99% rename from enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupContextBuilder.java rename to enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupContextFactory.java index e8c6503377584..dc20ec98db0a4 100644 --- a/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupContextBuilder.java +++ b/enterprise/backup/src/main/java/org/neo4j/backup/impl/OnlineBackupContextFactory.java @@ -55,7 +55,7 @@ import static org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_memory; import static org.neo4j.kernel.impl.util.Converters.toOptionalHostnamePortFromRawAddress; -class OnlineBackupContextBuilder +class OnlineBackupContextFactory { static final String ARG_NAME_BACKUP_DIRECTORY = "backup-dir"; static final String ARG_DESC_BACKUP_DIRECTORY = "Directory to place backup in."; @@ -114,7 +114,7 @@ class OnlineBackupContextBuilder private final Path homeDir; private final Path configDir; - OnlineBackupContextBuilder( Path homeDir, Path configDir ) + OnlineBackupContextFactory( Path homeDir, Path configDir ) { this.homeDir = homeDir; this.configDir = configDir; 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 65827aea6d5c2..11184d88db86e 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 @@ -99,17 +99,6 @@ public static List recordFormats() private static final String PROP_NAME = "name"; private static final String PROP_RANDOM = "random"; - private static void createSomeData( GraphDatabaseService db ) - { - try ( Transaction tx = db.beginTx() ) - { - Node node = db.createNode(); - node.setProperty( "name", "Neo" ); - db.createNode().createRelationshipTo( node, RelationshipType.withName( "KNOWS" ) ); - tx.success(); - } - } - @Before public void resetTasks() { @@ -289,6 +278,17 @@ public void reportsProgress() throws Exception assertFalse( output.contains( "Finished receiving index snapshots" ) ); } + private static void createSomeData( GraphDatabaseService db ) + { + try ( Transaction tx = db.beginTx() ) + { + Node node = db.createNode(); + node.setProperty( "name", "Neo" ); + db.createNode().createRelationshipTo( node, RelationshipType.withName( "KNOWS" ) ); + tx.success(); + } + } + private void repeatedlyPopulateDatabase( GraphDatabaseService db, AtomicBoolean continueFlagReference ) { while ( continueFlagReference.get() ) diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandTest.java b/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandTest.java index c559c73cbf2c9..226507d225e19 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandTest.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupCommandTest.java @@ -77,7 +77,7 @@ public class OnlineBackupCommandTest @Before public void setup() throws Exception { - OnlineBackupContextBuilder contextBuilder = mock( OnlineBackupContextBuilder.class ); + OnlineBackupContextFactory contextBuilder = mock( OnlineBackupContextFactory.class ); when( contextBuilder.createContext( any() ) ).thenReturn( onlineBackupContext ); when( outsideWorld.fileSystem() ).thenReturn( fileSystemAbstraction ); diff --git a/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupContextBuilderTest.java b/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupContextFactoryTest.java similarity index 86% rename from enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupContextBuilderTest.java rename to enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupContextFactoryTest.java index 9b93bef53eb5c..ebcead36284c8 100644 --- a/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupContextBuilderTest.java +++ b/enterprise/backup/src/test/java/org/neo4j/backup/impl/OnlineBackupContextFactoryTest.java @@ -59,7 +59,7 @@ import static org.neo4j.graphdb.factory.GraphDatabaseSettings.logical_logs_location; import static org.neo4j.graphdb.factory.GraphDatabaseSettings.pagecache_memory; -public class OnlineBackupContextBuilderTest +public class OnlineBackupContextFactoryTest { @Rule public TestDirectory testDirectory = TestDirectory.testDirectory(); @@ -85,7 +85,7 @@ public void setUp() throws IOException @Test public void unspecifiedHostnameIsEmptyOptional() throws Exception { - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( requiredAnd( "--from=:1234" ) ); OnlineBackupRequiredArguments requiredArguments = context.getRequiredArguments(); @@ -96,7 +96,7 @@ public void unspecifiedHostnameIsEmptyOptional() throws Exception @Test public void unspecifiedPortIsEmptyOptional() throws Exception { - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( requiredAnd( "--from=abc" ) ); OnlineBackupRequiredArguments requiredArguments = context.getRequiredArguments(); @@ -107,7 +107,7 @@ public void unspecifiedPortIsEmptyOptional() throws Exception @Test public void acceptHostWithTrailingPort() throws Exception { - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( requiredAnd( "--from=foo.bar.server:" ) ); OnlineBackupRequiredArguments requiredArguments = context.getRequiredArguments(); assertEquals( "foo.bar.server", requiredArguments.getAddress().getHostname().get() ); @@ -117,7 +117,7 @@ public void acceptHostWithTrailingPort() throws Exception @Test public void acceptPortWithPrecedingEmptyHost() throws Exception { - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( requiredAnd( "--from=:1234" ) ); OnlineBackupRequiredArguments requiredArguments = context.getRequiredArguments(); assertFalse( requiredArguments.getAddress().getHostname().isPresent() ); @@ -127,7 +127,7 @@ public void acceptPortWithPrecedingEmptyHost() throws Exception @Test public void acceptBothIfSpecified() throws Exception { - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( requiredAnd( "--from=foo.bar.server:1234" ) ); OnlineBackupRequiredArguments requiredArguments = context.getRequiredArguments(); assertEquals( "foo.bar.server", requiredArguments.getAddress().getHostname().get() ); @@ -139,13 +139,13 @@ public void backupDirectoryArgumentIsMandatory() throws Exception { expected.expect( IncorrectUsage.class ); expected.expectMessage( "Missing argument 'backup-dir'" ); - new OnlineBackupContextBuilder( homeDir, configDir ).createContext(); + new OnlineBackupContextFactory( homeDir, configDir ).createContext(); } @Test public void shouldDefaultTimeoutToTwentyMinutes() throws Exception { - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( "--backup-dir=/", "--name=mybackup" ); OnlineBackupRequiredArguments requiredArguments = context.getRequiredArguments(); @@ -155,7 +155,7 @@ public void shouldDefaultTimeoutToTwentyMinutes() throws Exception @Test public void shouldInterpretAUnitlessTimeoutAsSeconds() throws Exception { - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( "--timeout=10", "--backup-dir=/", "--name=mybackup" ); OnlineBackupRequiredArguments requiredArguments = context.getRequiredArguments(); @@ -165,7 +165,7 @@ public void shouldInterpretAUnitlessTimeoutAsSeconds() throws Exception @Test public void shouldParseATimeoutWithUnits() throws Exception { - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( requiredAnd( "--timeout=10h" ) ); OnlineBackupRequiredArguments requiredArguments = context.getRequiredArguments(); @@ -178,7 +178,7 @@ public void shouldTreatNameArgumentAsMandatory() throws Exception expected.expect( IncorrectUsage.class ); expected.expectMessage( "Missing argument 'name'" ); - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); handler.createContext( "--backup-dir=/" ); } @@ -187,7 +187,7 @@ public void reportDirMustBeAPath() throws Exception { expected.expect( IncorrectUsage.class ); expected.expectMessage( "cc-report-dir must be a path" ); - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); handler.createContext( requiredAnd( "--check-consistency", "--cc-report-dir" ) ); } @@ -202,7 +202,7 @@ public void errorHandledForNonExistingAdditionalConfigFile() throws Exception expected.expectCause( hasCause( any( NoSuchFileException.class ) ) ); // expect - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); handler.createContext( requiredAnd( "--additional-config=" + additionalConf ) ); } @@ -217,7 +217,7 @@ public void prioritiseConfigDirOverHomeDir() throws Exception Files.write( homeDirConfigFile, asList( "causal_clustering.minimum_core_cluster_size_at_startup=5", "causal_clustering.raft_in_queue_max_batch=21" ) ); // when - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); Config config = handler.createContext( requiredAnd() ).getConfig(); // then @@ -236,7 +236,7 @@ public void prioritiseAdditionalOverConfigDir() throws Exception Files.write( additionalConf, singletonList( "causal_clustering.minimum_core_cluster_size_at_startup=5" ) ); // when - OnlineBackupContextBuilder handler = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory handler = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = handler.createContext( requiredAnd( "--additional-config=" + additionalConf ) ); Config config = context.getConfig(); @@ -252,7 +252,7 @@ public void mustIgnorePageCacheConfigInConfigFile() throws Exception Files.write( configFile, singletonList( pagecache_memory.name() + "=42m" ) ); // when - OnlineBackupContextBuilder contextBuilder = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory contextBuilder = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = contextBuilder.createContext( requiredAnd() ); // then @@ -267,7 +267,7 @@ public void mustIgnorePageCacheConfigInAdditionalConfigFile() throws Exception Files.write( additionalConf, singletonList( pagecache_memory.name() + "=42m" ) ); // when - OnlineBackupContextBuilder builder = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory builder = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = builder.createContext( requiredAnd( "--additional-config=" + additionalConf ) ); // then @@ -278,7 +278,7 @@ public void mustIgnorePageCacheConfigInAdditionalConfigFile() throws Exception public void mustRespectPageCacheConfigFromCommandLineArguments() throws Exception { // when - OnlineBackupContextBuilder builder = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory builder = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = builder.createContext( requiredAnd( "--pagecache=42m" ) ); // then @@ -293,7 +293,7 @@ public void logsMustBePlacedInTargetBackupDirectory() throws Exception Path backupDir = homeDir.resolve( "poke" ); Path backupPath = backupDir.resolve( name ); Files.createDirectories( backupDir ); - OnlineBackupContextBuilder builder = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory builder = new OnlineBackupContextFactory( homeDir, configDir ); OnlineBackupContext context = builder.createContext( "--backup-dir=" + backupDir, "--name=" + name ); assertThat( context.getConfig().get( logical_logs_location ).getAbsolutePath(), is( backupPath.toString() ) ); } @@ -302,7 +302,7 @@ public void logsMustBePlacedInTargetBackupDirectory() throws Exception public void defaultProtocolIsAny() throws CommandFailed, IncorrectUsage { // given - OnlineBackupContextBuilder builder = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory builder = new OnlineBackupContextFactory( homeDir, configDir ); // when context resolved without proto override value OnlineBackupContext context = builder.createContext( requiredAnd() ); @@ -321,7 +321,7 @@ public void overrideWithLegacy() throws CommandFailed, IncorrectUsage for ( int useCase = 0; useCase < input.size(); useCase++ ) { // given - OnlineBackupContextBuilder builder = new OnlineBackupContextBuilder( homeDir, configDir ); + OnlineBackupContextFactory builder = new OnlineBackupContextFactory( homeDir, configDir ); // when OnlineBackupContext context = builder.createContext( requiredAnd( "--protocol=" + input.get( useCase ) ) );