Esempio n. 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void onlyTheLatestTransactionIsKeptAfterIncrementalBackup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OnlyTheLatestTransactionIsKeptAfterIncrementalBackup()
        {
            // given database exists with data
//JAVA TO C# CONVERTER WARNING: Java wildcard generics have no direct equivalent in .NET:
//ORIGINAL LINE: org.neo4j.causalclustering.discovery.Cluster<?> cluster = startCluster(recordFormat);
            Cluster <object> cluster = StartCluster(RecordFormat);

            CreateSomeData(cluster);

            // and backup client is told to rotate conveniently
            Config config             = Config.builder().withSetting(GraphDatabaseSettings.logical_log_rotation_threshold, "1m").build();
            File   configOverrideFile = _testDirectory.file("neo4j-backup.conf");

            OnlineBackupCommandBuilder.WriteConfigToFile(config, configOverrideFile);

            // and we have a full backup
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String backupName = "backupName" + recordFormat;
            string backupName = "backupName" + RecordFormat;
            string address    = CausalClusteringTestHelpers.backupAddress(ClusterLeader(cluster).database());

            assertEquals(0, RunBackupToolFromOtherJvmToGetExitCode("--from", address, "--cc-report-dir=" + _backupStoreDir, "--backup-dir=" + _backupStoreDir, "--additional-config=" + configOverrideFile, "--name=" + backupName));

            // and the database contains a few more transactions
            Transactions1M(cluster);
            Transactions1M(cluster);                 // rotation, second tx log file

            // when we perform an incremental backup
            assertEquals(0, RunBackupToolFromOtherJvmToGetExitCode("--from", address, "--cc-report-dir=" + _backupStoreDir, "--backup-dir=" + _backupStoreDir, "--additional-config=" + configOverrideFile, "--name=" + backupName, Arg(ARG_NAME_FALLBACK_FULL, false)));

            // then there has been a rotation
            LogFiles logFiles = BackupTransactionLogFilesHelper.ReadLogFiles(DatabaseLayout.of(new File(_backupStoreDir, backupName)));
            long     highestTxIdInLogFiles = logFiles.HighestLogVersion;

            assertEquals(2, highestTxIdInLogFiles);

            // and the original log has not been removed since the transactions are applied at start
            long lowestTxIdInLogFiles = logFiles.LowestLogVersion;

            assertEquals(0, lowestTxIdInLogFiles);
        }
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 onlyTheLatestTransactionIsKeptAfterIncrementalBackup() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
        public virtual void OnlyTheLatestTransactionIsKeptAfterIncrementalBackup()
        {
            // given database exists with data
            int port = PortAuthority.allocatePort();

            StartDb(port);
            CreateSomeData(_db);

            // and backup client is told to rotate conveniently
            Config config             = Config.builder().withSetting(GraphDatabaseSettings.logical_log_rotation_threshold, "1m").build();
            File   configOverrideFile = _testDirectory.file("neo4j-backup.conf");

            OnlineBackupCommandBuilder.WriteConfigToFile(config, configOverrideFile);

            // and we have a full backup
            string backupName = "backupName" + RecordFormat;
            string address    = "localhost:" + port;

            assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(_backupDir, "--from", address, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--protocol=common", "--additional-config=" + configOverrideFile, "--name=" + backupName));

            // and the database contains a few more transactions
            Transactions1M(_db);
            Transactions1M(_db);                 // rotation, second tx log file

            // when we perform an incremental backup
            assertEquals(0, runBackupToolFromOtherJvmToGetExitCode(_backupDir, "--from", address, "--cc-report-dir=" + _backupDir, "--backup-dir=" + _backupDir, "--protocol=common", "--additional-config=" + configOverrideFile, "--name=" + backupName));

            // then there has been a rotation
            BackupTransactionLogFilesHelper backupTransactionLogFilesHelper = new BackupTransactionLogFilesHelper();
            LogFiles logFiles = BackupTransactionLogFilesHelper.ReadLogFiles(StoreLayout.of(_backupDir).databaseLayout(backupName));
            long     highestTxIdInLogFiles = logFiles.HighestLogVersion;

            assertEquals(2, highestTxIdInLogFiles);

            // and the original log has not been removed since the transactions are applied at start
            long lowestTxIdInLogFiles = logFiles.LowestLogVersion;

            assertEquals(0, lowestTxIdInLogFiles);
        }