Exemplo n.º 1
0
        /// <summary>
        /// Performs a backup and returns the path to it. Benign failures are swallowed and an empty optional gets returned.
        /// </summary>
        /// <param name="member"> The member to perform the backup against. </param>
        /// <returns> The optional backup. </returns>
        /// <exception cref="Exception"> If any unexpected exceptions happen. </exception>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: java.util.Optional<java.io.File> backup(org.neo4j.causalclustering.discovery.ClusterMember member) throws Exception
        internal virtual Optional <File> Backup(ClusterMember member)
        {
            AdvertisedSocketAddress address = member.config().Get(transaction_advertised_address);
            string backupName = "backup-" + BackupNumber.AndIncrement;

            OnlineBackupCommandBuilder backupCommand = (new OnlineBackupCommandBuilder()).withOutput(NULL_OUTPUT_STREAM).withSelectedBackupStrategy(CATCHUP).withConsistencyCheck(true).withHost(address.Hostname).withPort(address.Port);

            try
            {
                backupCommand.Backup(_baseBackupDir, backupName);
                _log.info(string.Format("Created backup {0} from {1}", backupName, member));

                SuccessfulBackups.incrementAndGet();

                return(new File(_baseBackupDir, backupName));
            }
            catch (CommandFailed e)
            {
                Optional <Exception> benignException = findCauseOrSuppressed(e, t => _benignExceptions.Contains(t.GetType()));
                if (benignException.Present)
                {
                    _log.info("Benign failure: " + benignException.get().Message);
                }
                else
                {
                    throw e;
                }
            }
            return(null);
        }
Exemplo n.º 2
0
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in C#:
//ORIGINAL LINE: public static void restoreFromBackup(java.io.File backup, org.neo4j.io.fs.FileSystemAbstraction fsa, org.neo4j.causalclustering.discovery.ClusterMember clusterMember) throws java.io.IOException, org.neo4j.commandline.admin.CommandFailed
        public static void RestoreFromBackup(File backup, FileSystemAbstraction fsa, ClusterMember clusterMember)
        {
            Config config = clusterMember.config();
            RestoreDatabaseCommand restoreDatabaseCommand = new RestoreDatabaseCommand(fsa, backup, config, GraphDatabaseSettings.DEFAULT_DATABASE_NAME, true);

            restoreDatabaseCommand.Execute();
        }