Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void setup()
        public virtual void Setup()
        {
            _desiredBackupLayout          = TestDirectory.databaseLayout("desiredBackupLayout");
            _reportDir                    = TestDirectory.directory("reportDir").toPath();
            _availableFreshBackupLocation = TestDirectory.directory("availableFreshBackupLocation").toPath();
            Path availableOldBackupLocation = TestDirectory.directory("availableOldBackupLocation").toPath();

            when(_outsideWorld.fileSystem()).thenReturn(_fileSystemAbstraction);
            when(_backupCopyService.findAnAvailableLocationForNewFullBackup(any())).thenReturn(_availableFreshBackupLocation);
            when(_backupCopyService.findNewBackupLocationForBrokenExisting(any())).thenReturn(availableOldBackupLocation);
            when(_backupStrategyImplementation.performFullBackup(any(), any(), any())).thenReturn(_success);
            when(_logProvider.getLog(( Type )any())).thenReturn(_log);

            _subject = new BackupStrategyWrapper(_backupStrategyImplementation, _backupCopyService, _pageCache, _config, _backupRecoveryService, _logProvider);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// This will perform a full backup with some directory renaming if necessary.
        /// <para>
        /// If there is no existing backup, then no renaming will occur.
        /// Otherwise the full backup will be done into a temporary directory and renaming
        /// will occur if everything was successful.
        /// </para>
        /// </summary>
        /// <param name="onlineBackupContext"> command line arguments, config etc. </param>
        /// <returns> outcome of full backup </returns>
        private Fallible <BackupStageOutcome> FullBackupWithTemporaryFolderResolutions(OnlineBackupContext onlineBackupContext)
        {
            Path userSpecifiedBackupLocation = onlineBackupContext.ResolvedLocationFromName;
            Path temporaryFullBackupLocation = _backupCopyService.findAnAvailableLocationForNewFullBackup(userSpecifiedBackupLocation);

            OptionalHostnamePort          address = onlineBackupContext.RequiredArguments.Address;
            Fallible <BackupStageOutcome> state   = _backupStrategy.performFullBackup(DatabaseLayout.of(temporaryFullBackupLocation.toFile()), _config, address);

            // NOTE temporaryFullBackupLocation can be equal to desired
            bool backupWasMadeToATemporaryLocation = !userSpecifiedBackupLocation.Equals(temporaryFullBackupLocation);

            if (BackupStageOutcome.Success.Equals(state.State))
            {
                _backupRecoveryService.recoverWithDatabase(temporaryFullBackupLocation, _pageCache, _config);
                if (backupWasMadeToATemporaryLocation)
                {
                    try
                    {
                        RenameTemporaryBackupToExpected(temporaryFullBackupLocation, userSpecifiedBackupLocation);
                    }
                    catch (IOException e)
                    {
                        return(new Fallible <BackupStageOutcome>(BackupStageOutcome.UnrecoverableFailure, e));
                    }
                }
                ClearIdFiles(userSpecifiedBackupLocation);
            }
            return(state);
        }