internal async Task BackupCurrentPartition(Guid task_id, Guid version, EventArgs e) { List <PersistedSaveTask> passive_tasks = new List <PersistedSaveTask>(); var cts = m_dmc.m_cloudidx.GetMyPartitionReplicaChunks(); // Backup strategy: back up each chunk only ONCE, by the first replica that holds it. // XXX this would burden the first replica if it has the most chunks. // TODO load balance HashSet <Guid> planned = new HashSet <Guid>(); foreach (var(rep, cks) in cts) { passive_tasks.Add(new PersistedSaveTask(cks .Where(_ => !planned.Contains(_.Id)) .Select(ck => (rep, new PersistedSlice(version, ck.LowKey, ck.HighKey))))); cks.ForEach(ck => planned.Add(ck.Id)); } GroupedTask gt = new GroupedTask(passive_tasks, task_id); await m_taskqueue.PostTask(gt); await m_taskqueue.Wait(task_id); // After we successfully dump all partials of the partition to the persisted storage, // we then proceed to backup the cluster state, including chunk table, name service, // pending tasks, etc. var uploader = await m_pstore.Upload(version, m_namesvc.PartitionId, 0, 0); await m_backupmgr.Backup(uploader, e); await uploader.FinishUploading(); }
public IActionResult Get() { string currentUserId = User.Identity.Name; List <GroupedTask> grouppedTasks = new List <GroupedTask>(); List <TaskStatus> taskStatuses = db.TaskStatuses.ToList(); List <Task> tasks = db.Tasks .Include(temp => temp.CreatedByUser) .Include(temp => temp.AssignedToUser) .Include(temp => temp.Project).ThenInclude(temp => temp.ClientLocation) .Include(temp => temp.TaskStatusDetails) .Include(temp => temp.TaskPriority) .Where(temp => temp.CreatedBy == currentUserId || temp.AssignedTo == currentUserId) .OrderBy(temp => temp.TaskPriorityID) .ThenByDescending(temp => temp.LastUpdatedOn).ToList(); foreach (var item in tasks) { item.CreatedOnString = item.CreatedOn.ToString("dd/MM/yyyy"); item.LastUpdatedOnString = item.LastUpdatedOn.ToString("dd/MM/yyyy"); item.TaskStatusDetails = item.TaskStatusDetails.OrderByDescending(temp => temp.TaskStatusDetailID).ToList(); foreach (var item2 in item.TaskStatusDetails) { item2.StatusUpdationDateTimeString = item2.StatusUpdationDateTime.ToString("dd/MM/yyyy"); } } foreach (var item in taskStatuses) { GroupedTask groupedTask = new GroupedTask(); groupedTask.TaskStatusName = item.TaskStatusName; groupedTask.Tasks = tasks.Where(temp => temp.CurrentStatus == item.TaskStatusName).ToList(); if (groupedTask.Tasks.Count > 0) { grouppedTasks.Add(groupedTask); } } return(Ok(grouppedTasks)); }
internal async Task RestoreCurrentPartition(Guid task_id, Guid version, EventArgs e) { var downloader = await m_pstore.Download(version, m_namesvc.PartitionId, 0, 0); await m_backupmgr.Restore(downloader, e); // After the backup manager finishes state restoration, chunk tables, // name service, pending tasks should be all restored. Thus we load // chunks into replicas as per described by the chunk table. List <PersistedLoadTask> passive_tasks = new List <PersistedLoadTask>(); var cts = m_dmc.m_cloudidx.GetMyPartitionReplicaChunks(); foreach (var(rep, cks) in cts) { passive_tasks.Add(new PersistedLoadTask(cks .Select(ck => (rep, new PersistedSlice(version, ck.LowKey, ck.HighKey))))); } GroupedTask gt = new GroupedTask(passive_tasks, task_id); await m_taskqueue.PostTask(gt); await m_taskqueue.Wait(task_id); }