public void Deserialize(Common.Serialization.IO.CompactReader reader) { _id = reader.ReadInt64(); NumberOfSlices = reader.ReadInt64(); Database = reader.ReadString(); DatabaseCluster = reader.ReadString(); _crc = reader.ReadInt64(); Version = reader.ReadString(); _creationDate = reader.ReadDateTime(); SegmentMap = Common.Util.SerializationUtility.DeserializeDictionary <long, long>(reader); _recoveryType = (RecoveryJobType)reader.ReadInt32(); _fullBackupDate = reader.ReadDateTime(); _state = (RecoveryFileState)reader.ReadInt32(); }
public void CloseBackupFile(string name, RecoveryFileState state) { //M_TODO: // Add timeout interval for file writing, incase the data is not being consumed and timeout span has been reached, break the loop and DIE!!! try { // TimeSpan timeSpan BackupFile file = _activeContext.GetBackupFile(name); file.FileHeader.State = state; int elapsed = 0; // if file not already flushed if (!file.HeaderFlushed) { while (!_activeContext.SharedQueue.Consumed) { // wait till all data has been consumed and written } if (_activeContext.SharedQueue.Consumed) { if (file.SaveHeader()) { if (LoggerManager.Instance.RecoveryLogger != null && LoggerManager.Instance.RecoveryLogger.IsInfoEnabled) { LoggerManager.Instance.RecoveryLogger.Info("RecoveryPersistenceManager.CloseBackupFile()", file.Name + " closing"); } file.Close(); } else { throw new Exception("Unable to write data"); } } } } catch (Exception exp) { if (LoggerManager.Instance.RecoveryLogger != null && LoggerManager.Instance.RecoveryLogger.IsErrorEnabled) { LoggerManager.Instance.RecoveryLogger.Error("RecoveryPersistenceManager.CloseBackupFile()", exp.ToString()); } } }
public void RenameRootFolder(RecoveryFileState state) { try { Impersonation impersonation = null; if (RecoveryFolderStructure.PathIsNetworkPath(ActiveConfig.RecoveryPath)) { impersonation = new Impersonation(_activeConfig.UserName, _activeConfig.Password); } string sourcePath = Path.Combine(ActiveConfig.RecoveryPath, RootFolderName); if (Directory.Exists(sourcePath)) { string destination = string.Empty; string[] name = sourcePath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); switch (state) { case RecoveryFileState.Cancelled: if (sourcePath.EndsWith(RecoveryFolderStructure.INPROGRESS)) { destination = name[0] + RecoveryFolderStructure.CANCELLED; } break; case RecoveryFileState.Completed: string[] folderName = sourcePath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); destination = folderName[0] + RecoveryFolderStructure.COMPLETED; break; case RecoveryFileState.Failed: string[] rootName = sourcePath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); destination = rootName[0] + RecoveryFolderStructure.FAILED; break; } if (!RecoveryFolderStructure.PathIsNetworkPath(sourcePath)) { if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } Directory.Move(Path.Combine(sourcePath, RecoveryFolderStructure.CONFIG_FOLDER), Path.Combine(destination, RecoveryFolderStructure.CONFIG_FOLDER)); } else { Directory.Move(sourcePath, destination); } if (Directory.Exists(sourcePath)) { if (new DirectoryInfo(sourcePath).GetDirectories().Count() == 0) { Directory.Delete(sourcePath); } } if (impersonation != null) { impersonation.Dispose(); } } } catch (Exception exp) { LoggerManager.Instance.RecoveryLogger.Error("Config.Rename", exp); } }
internal void RenameRootFolder(RecoveryFileState state) { if (!RecoveryFolderStructure.PathIsNetworkPath(_rootPath)) { string[] shardPath = null; shardPath = RootPath.Split(new string[] { RecoveryFolderStructure.SHARD_BACKUP_FOLDER }, StringSplitOptions.RemoveEmptyEntries); switch (state) { case RecoveryFileState.Cancelled: string destination = string.Empty; if (RootPath.EndsWith(RecoveryFolderStructure.INPROGRESS)) { string[] name = RootPath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); destination = name[0] + RecoveryFolderStructure.CANCELLED; if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } destination = RootPath.Replace(RecoveryFolderStructure.INPROGRESS, RecoveryFolderStructure.CANCELLED); Directory.Move(RootPath, destination); RootPath = destination; } break; case RecoveryFileState.Completed: string[] folderName = RootPath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); destination = folderName[0] + RecoveryFolderStructure.COMPLETED; if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } destination = RootPath.Replace(RecoveryFolderStructure.INPROGRESS, RecoveryFolderStructure.COMPLETED); Directory.Move(RootPath, destination); RootPath = destination; break; case RecoveryFileState.Failed: string[] rootName = RootPath.Split(RecoveryFolderStructure.INDELIMETER, StringSplitOptions.RemoveEmptyEntries); destination = rootName[0] + RecoveryFolderStructure.FAILED; if (!Directory.Exists(destination)) { Directory.CreateDirectory(destination); } destination = RootPath.Replace(RecoveryFolderStructure.INPROGRESS, RecoveryFolderStructure.FAILED); Directory.Move(RootPath, destination); RootPath = destination; break; } if (new DirectoryInfo(shardPath[0]).GetDirectories().Count() == 0) { Directory.Delete(shardPath[0]); } } }