Esempio n. 1
0
 /// <summary>
 /// The entry point for neo4j admin tool's online backup functionality.
 /// </summary>
 /// <param name="outsideWorld"> provides a way to interact with the filesystem and output streams </param>
 /// <param name="contextBuilder"> helper class to validate, process and return a grouped result of processing the command line arguments </param>
 /// <param name="backupSupportingClassesFactory"> necessary for constructing the strategy for backing up over the causal clustering transaction protocol </param>
 /// <param name="backupStrategyCoordinatorFactory"> class that actually handles the logic of performing a backup </param>
 internal OnlineBackupCommand(OutsideWorld outsideWorld, OnlineBackupContextFactory contextBuilder, BackupSupportingClassesFactory backupSupportingClassesFactory, BackupStrategyCoordinatorFactory backupStrategyCoordinatorFactory)
 {
     this._outsideWorld   = outsideWorld;
     this._contextBuilder = contextBuilder;
     this._backupSupportingClassesFactory   = backupSupportingClassesFactory;
     this._backupStrategyCoordinatorFactory = backupStrategyCoordinatorFactory;
 }
Esempio n. 2
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void reportDirMustBeAPath() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ReportDirMustBeAPath()
        {
            Expected.expect(typeof(IncorrectUsage));
            Expected.expectMessage("cc-report-dir must be a path");
            OnlineBackupContextFactory handler = new OnlineBackupContextFactory(_homeDir, _configDir);

            handler.CreateContext(RequiredAnd("--check-consistency", "--cc-report-dir"));
        }
Esempio n. 3
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldParseATimeoutWithUnits() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldParseATimeoutWithUnits()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--timeout=10h"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals(HOURS.toMillis(10), requiredArguments.Timeout);
        }
Esempio n. 4
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldInterpretAUnitlessTimeoutAsSeconds() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldInterpretAUnitlessTimeoutAsSeconds()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext("--timeout=10", "--backup-dir=/", "--name=mybackup");
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals(SECONDS.toMillis(10), requiredArguments.Timeout);
        }
Esempio n. 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldDefaultTimeoutToTwentyMinutes() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldDefaultTimeoutToTwentyMinutes()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext("--backup-dir=/", "--name=mybackup");
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals(MINUTES.toMillis(20), requiredArguments.Timeout);
        }
Esempio n. 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustRespectPageCacheConfigFromCommandLineArguments() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustRespectPageCacheConfigFromCommandLineArguments()
        {
            // when
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context = builder.CreateContext(RequiredAnd("--pagecache=42m"));

            // then
            assertThat(context.Config.get(pagecache_memory), @is("42m"));
        }
Esempio n. 7
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void unspecifiedPortIsEmptyOptional() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UnspecifiedPortIsEmptyOptional()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--from=abc"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals("abc", requiredArguments.Address.Hostname.get());
            assertFalse(requiredArguments.Address.Port.HasValue);
        }
Esempio n. 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void unspecifiedHostnameIsEmptyOptional() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void UnspecifiedHostnameIsEmptyOptional()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--from=:1234"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertFalse(requiredArguments.Address.Hostname.Present);
            assertEquals(1234, requiredArguments.Address.Port.Value.intValue());
        }
Esempio n. 9
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void shouldTreatNameArgumentAsMandatory() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ShouldTreatNameArgumentAsMandatory()
        {
            Expected.expect(typeof(IncorrectUsage));
            Expected.expectMessage("Missing argument 'name'");

            OnlineBackupContextFactory handler = new OnlineBackupContextFactory(_homeDir, _configDir);

            handler.CreateContext("--backup-dir=/");
        }
Esempio n. 10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void acceptBothIfSpecified() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AcceptBothIfSpecified()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--from=foo.bar.server:1234"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals("foo.bar.server", requiredArguments.Address.Hostname.get());
            assertEquals(1234, requiredArguments.Address.Port.Value.intValue());
        }
Esempio n. 11
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void acceptHostWithTrailingPort() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void AcceptHostWithTrailingPort()
        {
            OnlineBackupContextFactory    handler           = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext           context           = handler.CreateContext(RequiredAnd("--from=foo.bar.server:"));
            OnlineBackupRequiredArguments requiredArguments = context.RequiredArguments;

            assertEquals("foo.bar.server", requiredArguments.Address.Hostname.get());
            assertFalse(requiredArguments.Address.Port.HasValue);
        }
Esempio n. 12
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void defaultProtocolIsAny() throws org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void DefaultProtocolIsAny()
        {
            // given
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);

            // when context resolved without proto override value
            OnlineBackupContext context = builder.CreateContext(RequiredAnd());

            // then
            assertEquals(ANY, context.RequiredArguments.SelectedBackupProtocol);
        }
Esempio n. 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustIgnorePageCacheConfigInConfigFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustIgnorePageCacheConfigInConfigFile()
        {
            // given
            Files.write(_configFile, singletonList(pagecache_memory.name() + "=42m"));

            // when
            OnlineBackupContextFactory contextBuilder = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context        = contextBuilder.CreateContext(RequiredAnd());

            // then
            assertThat(context.Config.get(pagecache_memory), @is("8m"));
        }
Esempio n. 14
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void ipv6CanBeProcessed() throws org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void Ipv6CanBeProcessed()
        {
            // given
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);

            // when
            OnlineBackupContext context = builder.CreateContext(RequiredAnd("--from=[fd00:ce10::2]:6362"));

            // then
            assertEquals("fd00:ce10::2", context.RequiredArguments.Address.Hostname.get());
            assertEquals(Convert.ToInt32(6362), context.RequiredArguments.Address.Port.Value);
        }
Esempio n. 15
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void logsMustBePlacedInTargetBackupDirectory() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void LogsMustBePlacedInTargetBackupDirectory()
        {
            // when
            string name       = "mybackup";
            Path   backupDir  = _homeDir.resolve("poke");
            Path   backupPath = backupDir.resolve(name);

            Files.createDirectories(backupDir);
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context = builder.CreateContext("--backup-dir=" + backupDir, "--name=" + name);

            assertThat(context.Config.get(logical_logs_location).AbsolutePath, @is(backupPath.ToString()));
        }
Esempio n. 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void mustIgnorePageCacheConfigInAdditionalConfigFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void MustIgnorePageCacheConfigInAdditionalConfigFile()
        {
            // given
            Path additionalConf = _homeDir.resolve("additional-neo4j.conf");

            Files.write(additionalConf, singletonList(pagecache_memory.name() + "=42m"));

            // when
            OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context = builder.CreateContext(RequiredAnd("--additional-config=" + additionalConf));

            // then
            assertThat(context.Config.get(pagecache_memory), @is("8m"));
        }
Esempio n. 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void errorHandledForNonExistingAdditionalConfigFile() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void ErrorHandledForNonExistingAdditionalConfigFile()
        {
            // given
            Path additionalConf = _homeDir.resolve("neo4j.conf");

            // and
            Expected.expect(typeof(CommandFailed));
            Expected.expectCause(hasCause(any(typeof(IOException))));

            // expect
            OnlineBackupContextFactory handler = new OnlineBackupContextFactory(_homeDir, _configDir);

            handler.CreateContext(RequiredAnd("--additional-config=" + additionalConf));
        }
Esempio n. 18
0
        private static OnlineBackupCommand NewOnlineBackupCommand(OutsideWorld outsideWorld, OnlineBackupContext onlineBackupContext, BackupSupportingClassesFactory backupSupportingClassesFactory, BackupStrategyCoordinatorFactory backupStrategyCoordinatorFactory)
        {
            OnlineBackupContextFactory contextBuilder = mock(typeof(OnlineBackupContextFactory));

            try
            {
                when(contextBuilder.CreateContext(any())).thenReturn(onlineBackupContext);
            }
            catch (Exception e) when(e is IncorrectUsage || e is CommandFailed)
            {
                throw new Exception("Shouldn't happen", e);
            }

            return(new OnlineBackupCommand(outsideWorld, contextBuilder, backupSupportingClassesFactory, backupStrategyCoordinatorFactory));
        }
Esempio n. 19
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @Nonnull public org.neo4j.commandline.admin.AdminCommand create(java.nio.file.Path homeDir, java.nio.file.Path configDir, org.neo4j.commandline.admin.OutsideWorld outsideWorld)
        public override AdminCommand Create(Path homeDir, Path configDir, OutsideWorld outsideWorld)
        {
            bool        debug       = System.getenv().get("NEO4J_DEBUG") != null;
            LogProvider logProvider = FormattedLogProvider.withDefaultLogLevel(debug ? Level.DEBUG : Level.NONE).toOutputStream(outsideWorld.OutStream());
            Monitors    monitors    = new Monitors();

            OnlineBackupContextFactory contextBuilder = new OnlineBackupContextFactory(homeDir, configDir);
            BackupModule backupModule = new BackupModule(outsideWorld, logProvider, monitors);

            BackupSupportingClassesFactoryProvider classesFactoryProvider   = ProvidersByPriority.findFirst().orElseThrow(NoProviderException());
            BackupSupportingClassesFactory         supportingClassesFactory = classesFactoryProvider.GetFactory(backupModule);
            BackupStrategyCoordinatorFactory       coordinatorFactory       = new BackupStrategyCoordinatorFactory(backupModule);

            return(new OnlineBackupCommand(outsideWorld, contextBuilder, supportingClassesFactory, coordinatorFactory));
        }
Esempio n. 20
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void prioritiseConfigDirOverHomeDir() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PrioritiseConfigDirOverHomeDir()
        {
            // given
            Files.write(_configFile, singletonList("causal_clustering.minimum_core_cluster_size_at_startup=4"), WRITE);

            // and
            Path homeDirConfigFile = _homeDir.resolve("neo4j.conf");

            Files.write(homeDirConfigFile, asList("causal_clustering.minimum_core_cluster_size_at_startup=5", "causal_clustering.raft_in_queue_max_batch=21"));

            // when
            OnlineBackupContextFactory handler = new OnlineBackupContextFactory(_homeDir, _configDir);
            Config config = handler.CreateContext(RequiredAnd()).Config;

            // then
            assertEquals(Convert.ToInt32(3), config.Get(CausalClusteringSettings.minimum_core_cluster_size_at_formation));
            assertEquals(Convert.ToInt32(128), config.Get(CausalClusteringSettings.raft_in_queue_max_batch));
        }
Esempio n. 21
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void overrideWithLegacy() throws org.neo4j.commandline.admin.CommandFailed, org.neo4j.commandline.admin.IncorrectUsage
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OverrideWithLegacy()
        {
            // with
            IList <string> input = Arrays.asList("common", "catchup");
            IList <SelectedBackupProtocol> expected = Arrays.asList(SelectedBackupProtocol.Common, SelectedBackupProtocol.Catchup);

            for (int useCase = 0; useCase < input.Count; useCase++)
            {
                // given
                OnlineBackupContextFactory builder = new OnlineBackupContextFactory(_homeDir, _configDir);

                // when
                OnlineBackupContext context = builder.CreateContext(RequiredAnd("--protocol=" + input[useCase]));

                // then
                assertEquals(expected[useCase], context.RequiredArguments.SelectedBackupProtocol);
            }
        }
Esempio n. 22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void prioritiseAdditionalOverConfigDir() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void PrioritiseAdditionalOverConfigDir()
        {
            // given
            Files.write(_configFile, asList("causal_clustering.minimum_core_cluster_size_at_startup=4", "causal_clustering.raft_in_queue_max_batch=21"));

            // and
            Path additionalConf = _homeDir.resolve("additional-neo4j.conf");

            Files.write(additionalConf, singletonList("causal_clustering.minimum_core_cluster_size_at_startup=5"));

            // when
            OnlineBackupContextFactory handler = new OnlineBackupContextFactory(_homeDir, _configDir);
            OnlineBackupContext        context = handler.CreateContext(RequiredAnd("--additional-config=" + additionalConf));
            Config config = context.Config;

            // then
            assertEquals(Convert.ToInt32(3), config.Get(CausalClusteringSettings.minimum_core_cluster_size_at_formation));
            assertEquals(Convert.ToInt32(21), config.Get(CausalClusteringSettings.raft_in_queue_max_batch));
        }
Esempio n. 23
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Override @Nonnull public org.neo4j.commandline.arguments.Arguments allArguments()
        public override Arguments AllArguments()
        {
            return(OnlineBackupContextFactory.Arguments());
        }