public BackupProgress GetBackupProgress(int tenantId) { lock (ProgressQueue.SynchRoot) { return(ToBackupProgress(ProgressQueue.GetItems().OfType <BackupProgressItem>().FirstOrDefault(t => t.TenantId == tenantId))); } }
public BackupProgress GetRestoreProgress(int tenantId) { lock (SynchRoot) { return(ToBackupProgress(ProgressQueue.GetTasks <RestoreProgressItem>().FirstOrDefault(t => t.TenantId == tenantId))); } }
public static void Initialize() { var backupConfiguration = BackupConfigurationSection.GetSection(); currentWebConfigPath = ToAbsolute(backupConfiguration.RegionConfigs.GetCurrentConfig()); if (!currentWebConfigPath.EndsWith(".config", StringComparison.OrdinalIgnoreCase)) { currentWebConfigPath = Path.Combine(currentWebConfigPath, "web.config"); } tmpfolder = ToAbsolute(backupConfiguration.TmpFolder); expire = backupConfiguration.ExpirePeriod; tasks = new ProgressQueue(backupConfiguration.ThreadCount, TimeSpan.FromMinutes(15), false); cleaner = new Timer(Clean, expire, expire, expire); ThreadPool.QueueUserWorkItem(state => { foreach (var tenant in CoreContext.TenantManager .GetTenants() .Where(t => t.Status == TenantStatus.Transfering)) { tenant.SetStatus(TenantStatus.Active); CoreContext.TenantManager.SaveTenant(tenant); var url = tenant.TenantDomain; if (!url.StartsWith("http://") && !url.StartsWith("https://")) { url = "http://" + url; } NotifyHelper.SendAboutTransferError(tenant.TenantId, string.Empty, url, string.Empty, true); } }); }
public virtual Boolean MoveNext() { Boolean result; if (!Completed) { if (ProgressQueue.Count > 0) { TreeNodeType node = ProgressQueue.Dequeue(); foreach (TreeNodeType child in node.Children) { ProgressQueue.Enqueue(child); } CurrentItem = node; } else // Enumeration is complete. { CurrentItem = InvalidItem; Completed = true; } result = !CurrentItem.Equals(InvalidItem); } else { result = false; } return(result); }
public static void Initialize() { var backupConfiguration = BackupConfigurationSection.GetSection(); currentWebConfigPath = ToAbsolute(backupConfiguration.RegionConfigs.GetCurrentConfig()); if (!currentWebConfigPath.EndsWith(".config", StringComparison.OrdinalIgnoreCase)) { currentWebConfigPath = Path.Combine(currentWebConfigPath, "web.config"); } tmpfolder = ToAbsolute(backupConfiguration.TmpFolder); expire = backupConfiguration.ExpirePeriod; tasks = new ProgressQueue(backupConfiguration.ThreadCount, TimeSpan.FromMinutes(15), false); cleaner = new Timer(Clean, expire, expire, expire); ThreadPool.QueueUserWorkItem(state => { foreach (var tenant in CoreContext.TenantManager .GetTenants() .Where(t => t.Status == TenantStatus.Transfering)) { tenant.SetStatus(TenantStatus.Active); CoreContext.TenantManager.SaveTenant(tenant); var url = tenant.TenantDomain; if (!url.StartsWith("http://") && !url.StartsWith("https://")) { url = "http://" + url; } NotifyHelper.SendAboutTransferError(tenant.TenantId, string.Empty, url, string.Empty, true); } }); }
public virtual void Reset() { CurrentItem = InvalidItem; Completed = false; ProgressQueue.Clear(); ProgressQueue.Enqueue(Root); }
public void Stop() { if (ProgressQueue != null) { ProgressQueue.Terminate(); ProgressQueue = null; } }
public static void Initialize() { var config = BackupConfigurationSection.GetSection(); tasks = new ProgressQueue(config.ThreadCount, TimeSpan.FromMinutes(15), false); cleaner = new Timer(Clean, config.ExpirePeriod, config.ExpirePeriod, config.ExpirePeriod); ThreadPool.QueueUserWorkItem(_ => RestoreTransferingTenants()); }
public void ResetRestoreError(int tenantId) { lock (ProgressQueue.SynchRoot) { var progress = ProgressQueue.GetItems().OfType <RestoreProgressItem>().FirstOrDefault(t => t.TenantId == tenantId); if (progress != null) { progress.Error = null; } } }
public void ResetRestoreError(int tenantId) { lock (SynchRoot) { var progress = ProgressQueue.GetTasks <RestoreProgressItem>().FirstOrDefault(t => t.TenantId == tenantId); if (progress != null) { progress.Exception = null; } } }
public void Stop() { if (ProgressQueue != null) { var tasks = ProgressQueue.GetTasks(); foreach (var t in tasks) { ProgressQueue.CancelTask(t.Id); } ProgressQueue = null; } }
public static void Stop() { if (tasks != null) { tasks.Terminate(); tasks = null; } if (schedulerTasks != null) { schedulerTasks.Terminate(); schedulerTasks = null; } }
public static void Terminate() { if (tasks != null) { tasks.Terminate(); tasks = null; } if (cleaner != null) { cleaner.Change(Timeout.Infinite, Timeout.Infinite); cleaner.Dispose(); cleaner = null; } }
public static void Terminate() { if (tasks != null) { tasks.Terminate(); tasks = null; } if (cleaner != null) { cleaner.Change(Timeout.Infinite, Timeout.Infinite); cleaner.Dispose(); cleaner = null; } }
public void StartScheduledBackup(BackupSchedule schedule) { lock (ProgressQueue.SynchRoot) { var item = ProgressQueue.GetItems().OfType <BackupProgressItem>().FirstOrDefault(t => t.TenantId == schedule.TenantId); if (item != null && item.IsCompleted) { ProgressQueue.Remove(item); item = null; } if (item == null) { item = FactoryProgressItem.CreateBackupProgressItem(schedule, false, TempFolder, Limit, CurrentRegion, ConfigPaths); ProgressQueue.Add(item); } } }
public BackupProgress StartRestore(StartRestoreRequest request) { lock (ProgressQueue.SynchRoot) { var item = ProgressQueue.GetItems().OfType <RestoreProgressItem>().FirstOrDefault(t => t.TenantId == request.TenantId); if (item != null && item.IsCompleted) { ProgressQueue.Remove(item); item = null; } if (item == null) { item = FactoryProgressItem.CreateRestoreProgressItem(request, TempFolder, UpgradesPath, CurrentRegion, ConfigPaths); ProgressQueue.Add(item); } return(ToBackupProgress(item)); } }
public static void Start(BackupConfigurationSection config) { limit = config.Limit; upgradesPath = config.UpgradesPath; currentRegion = config.WebConfigs.CurrentRegion; configPaths = config.WebConfigs.Cast <WebConfigElement>().ToDictionary(el => el.Region, el => PathHelper.ToRootedConfigPath(el.Path)); configPaths[currentRegion] = PathHelper.ToRootedConfigPath(config.WebConfigs.CurrentPath); var invalidConfigPath = configPaths.Values.FirstOrDefault(path => !File.Exists(path)); if (invalidConfigPath != null) { Log.WarnFormat("Configuration file {0} not found", invalidConfigPath); } tasks = new ProgressQueue(config.Service.WorkerCount, TimeSpan.FromMinutes(15), false); schedulerTasks = new ProgressQueue(config.Scheduler.WorkerCount, TimeSpan.FromMinutes(15), false); }
public BackupProgress StartTransfer(int tenantId, string targetRegion, bool transferMail, bool notify) { lock (ProgressQueue.SynchRoot) { var item = ProgressQueue.GetItems().OfType <TransferProgressItem>().FirstOrDefault(t => t.TenantId == tenantId); if (item != null && item.IsCompleted) { ProgressQueue.Remove(item); item = null; } if (item == null) { item = FactoryProgressItem.CreateTransferProgressItem(targetRegion, transferMail, tenantId, TempFolder, Limit, notify, CurrentRegion, ConfigPaths); ProgressQueue.Add(item); } return(ToBackupProgress(item)); } }
public BackupProgress StartBackup(StartBackupRequest request) { lock (SynchRoot) { var item = ProgressQueue.GetTasks <BackupProgressItem>().FirstOrDefault(t => t.TenantId == request.TenantId); if (item != null && item.IsCompleted) { ProgressQueue.RemoveTask(item.Id); item = null; } if (item == null) { item = FactoryProgressItem.CreateBackupProgressItem(request, false, TempFolder, Limit, CurrentRegion, ConfigPaths); ProgressQueue.QueueTask(item); } item.PublishChanges(); return(ToBackupProgress(item)); } }
public BackupProgress StartBackup(StartBackupRequest request) { lock (ProgressQueue.SynchRoot) { var item = ProgressQueue.GetItems().OfType <BackupProgressItem>().FirstOrDefault(t => t.TenantId == request.TenantId); if (item != null && item.IsCompleted) { ProgressQueue.Remove(item); item = null; } if (item == null) { item = FactoryProgressItem.CreateBackupProgressItem(request, false, TempFolder, Limit, CurrentRegion, ConfigPaths); ProgressQueue.Add(item); } var progress = ToBackupProgress(item); PublishProgress(progress); return(progress); } }
public virtual void Dispose() { Root = CurrentItem = InvalidItem; ProgressQueue.Clear(); }
public void WriteProgress(long sourceId, ProgressRecordEx progressRecord) { ProgressQueue.Enqueue(progressRecord); WriteProtectedProgress(() => realWriter.WriteProgress(sourceId, progressRecord)); }
public void WriteProgress(ProgressRecordEx progressRecord) { ProgressQueue.Enqueue(progressRecord); WriteProtectedProgress(() => realWriter.WriteProgress(progressRecord)); }