Exemplo n.º 1
0
        public static void SaveBackupStatus(PeriodicBackupStatus status, DocumentDatabase documentDatabase, Logger logger, BackupResult backupResult)
        {
            try
            {
                var command = new UpdatePeriodicBackupStatusCommand(documentDatabase.Name, RaftIdGenerator.NewId())
                {
                    PeriodicBackupStatus = status
                };

                var result = AsyncHelpers.RunSync(() => documentDatabase.ServerStore.SendToLeaderAsync(command));
                AsyncHelpers.RunSync(() => documentDatabase.ServerStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, result.Index));

                if (logger.IsInfoEnabled)
                {
                    logger.Info($"Periodic backup status with task id {status.TaskId} was updated");
                }
            }
            catch (Exception e)
            {
                const string message = "Error saving the periodic backup status";

                if (logger.IsOperationsEnabled)
                {
                    logger.Operations(message, e);
                }

                backupResult?.AddError($"{message}{Environment.NewLine}{e}");
            }
        }
Exemplo n.º 2
0
        private void WriteStatus(PeriodicBackupStatus status)
        {
            AddInfo("Saving backup status");

            try
            {
                var command = new UpdatePeriodicBackupStatusCommand(_database.Name, RaftIdGenerator.NewId())
                {
                    PeriodicBackupStatus = status
                };

                var result = AsyncHelpers.RunSync(() => _serverStore.SendToLeaderAsync(command));

                if (_logger.IsInfoEnabled)
                {
                    _logger.Info($"Periodic backup status with task id {status.TaskId} was updated");
                }

                AsyncHelpers.RunSync(() => _serverStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, result.Index));
            }
            catch (Exception e)
            {
                const string message = "Error saving the periodic backup status";

                if (_logger.IsOperationsEnabled)
                {
                    _logger.Operations(message, e);
                }
            }
        }
Exemplo n.º 3
0
        private async Task WriteStatus(PeriodicBackupStatus status, Action <IOperationProgress> onProgress)
        {
            AddInfo("Saving backup status", onProgress);

            try
            {
                var command = new UpdatePeriodicBackupStatusCommand(_database.Name)
                {
                    PeriodicBackupStatus = status
                };

                var result = await _serverStore.SendToLeaderAsync(command);

                if (_logger.IsInfoEnabled)
                {
                    _logger.Info($"Periodic backup status with task id {status.TaskId} was updated");
                }

                await _serverStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, result.Index);
            }
            catch (Exception e)
            {
                const string message = "Error saving the periodic backup status";

                if (_logger.IsOperationsEnabled)
                {
                    _logger.Operations(message, e);
                }
            }
        }
Exemplo n.º 4
0
        private async Task WriteStatus(PeriodicBackupStatus status)
        {
            if (_cancellationToken.IsCancellationRequested)
            {
                return;
            }

            try
            {
                var command = new UpdatePeriodicBackupStatusCommand(_database.Name)
                {
                    PeriodicBackupStatus = status
                };

                var result = await _serverStore.SendToLeaderAsync(command);

                if (_logger.IsInfoEnabled)
                {
                    _logger.Info($"Periodic backup status with task id {status.TaskId} was updated");
                }

                await _serverStore.WaitForCommitIndexChange(RachisConsensus.CommitIndexModification.GreaterOrEqual, result.Index);
            }
            catch (Exception e)
            {
                const string message = "Error saving the periodic backup status";

                if (_logger.IsOperationsEnabled)
                {
                    _logger.Operations(message, e);
                }

                _database.NotificationCenter.Add(AlertRaised.Create("Periodic Backup",
                                                                    message,
                                                                    AlertType.PeriodicBackup,
                                                                    NotificationSeverity.Error,
                                                                    details: new ExceptionDetails(e)));
            }
        }