Пример #1
0
        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();
        }
Пример #2
0
        private void BackupWorker(IndexingActivityStatus state, string backupDirectoryPath)
        {
            try
            {
                _backupCancellationSource = new CancellationTokenSource();
                _backupManager.Backup(state, backupDirectoryPath, SearchManager.Instance,
                                      _backupCancellationSource.Token);
            }
            catch (Exception e)
            {
                CollectErrorMessages(e, _backupManager.BackupInfo);
                SnTrace.Index.WriteError("SearchService: " + _backupManager.BackupInfo.Message);
            }

            _backupHistory.Add(_backupManager.BackupInfo.Clone());
            SnTrace.Index.Write("SearchService: BackupInfo is added to history.");
            _backupManager = null;
            _backupCancellationSource.Dispose();
            _backupCancellationSource = null;
        }