Exemplo n.º 1
0
        private BChunk BuildIndexChunk()
        {
            backup.AddHubNotificationEvent(704, "", "");
            BChunk iChunk = new BChunk(/*backup.TaskId, */ backup.Index.FullName, backup.Index.FullName, backup.TaskId);            //string name, int bsid, string bPath, string snapPath)

            try{
                //iChunk.Add(FileProvider.GetFile(index.FullName));

                iChunk.Add(new MinimalFsItem(backup.Index.FullName));
                if (backup.DataFlags.HasFlag(DataProcessingFlags.CDedup))                // backup the deduplication database
                {
                    iChunk.Add(ItemProvider.GetProvider().GetItemByPath(DedupIndex.Instance().IndexDBName));
                }

                /*string sumHash;
                 * using(FileStream cksumFS = new FileStream(backup.Index.FullName, FileMode.Open, FileAccess.Read)){
                 *      sumHash = BitConverter.ToString(SHA1.Create().ComputeHash(cksumFS));
                 *      iChunk.Sum = sumHash;
                 * }*/
                iChunk.Sum = IndexManager.CheckSumIndex(backup.TaskId, (backup.Level != BackupLevel.Full));

                // register for session received, to process index transfer
                User.StorageSessionReceivedEvent += new User.StorageSessionReceivedHandler(this.SendIndex);
                User.AskIndexDest(backup.TaskId, backup.Index.Name, iChunk.Sum);
                Logger.Append(Severity.DEBUG, "Asked index destination to hub");
                return(iChunk);
            }
            catch (Exception e) {
                Logger.Append(Severity.ERROR, "Couldn't checksum index and/or ask destination to hub: " + e.Message + "---" + e.StackTrace);
                backup.AddHubNotificationEvent(808, e.Message, "");
            }
            return(null);
        }
Exemplo n.º 2
0
        internal void Run()
        {
            // at this stage we're ready to backup : we gathered/exploded/grouped backup paths, gathered necesary FSes
            // and application objects.
            if (backup.Level == BackupLevel.SnapshotOnly)            //if backup type is snapshotonly, we're done, since snapshots have been taken at this stage
            {
                ProcessIndex();
                return;
            }
            //Ask the first storage sessions
            this.StorageNeeded(new PeerSession {
                TaskId = backup.Id, Id = -1
            }, realParallelism, false, false);

            //Start the deduplication index instance, if needed
            dedupIndex = DedupIndex.Instance(this.backup.BackupSet.UseDedicatedDdb?this.backup.BackupSet.Id:0, true);

            //check if we should already have a dedup db, and if it's present and valid
            if (backup.ParentTask != null && !dedupIndex.ExistsAndValid(backup.ParentTask.DdbSum))
            {
                IndexNeeded(this.backup.Id, true);
            }

            brdEnumerator = backup.RootDrives.GetEnumerator();
            //User.SessionReady += this.SessionReceived;

            for (uint i = 0; i < realParallelism; i++)
            {
                var producer = System.Threading.Tasks.Task.Factory.StartNew(() => {
                    Produce(megaQueue.Dequeue());
                }, TaskCreationOptions.LongRunning);                 // WRONG : split paths first
                producer.ContinueWith(o => UnexpectedError(producer), TaskContinuationOptions.OnlyOnFaulted);
            }

            // Start indexer task
            var indexer = System.Threading.Tasks.Task.Factory.StartNew(() => {
                DoIndex();
            }, cancellationTokenSource.Token, TaskCreationOptions.None, TaskScheduler.Default);

            indexer.ContinueWith(o => UnexpectedError(indexer), TaskContinuationOptions.OnlyOnFaulted);
            indexer.ContinueWith(o => ProcessIndex(), TaskContinuationOptions.OnlyOnRanToCompletion /*| TaskContinuationOptions.NotOnFaulted| TaskContinuationOptions.NotOnCanceled*/);

            /*System.Threading.Tasks.Task.Factory.ContinueWhenAll(producers,  z=>{
             *
             * });*/
        }
Exemplo n.º 3
0
        private void ProcessIndex()
        {
            //if(cancellationTokenSource.IsCancellationRequested) return;

            //indexProcessing = true;
            if (backup.DataFlags.HasFlag(DataProcessingFlags.CDedup)
                /*	&& !cancellationTokenSource.IsCancellationRequested*/)
            {
                // save dedup and process index even if task is cancelled (for cleaning purposes)
                try{
                    DedupIndex.Instance().Persist();
                }
                catch (Exception _e) {
                    Logger.Append(Severity.ERROR, "Could not save deduplication indexes DB, backup data is therefore invalid. TODO: Report!!! : " + _e.Message + " ---- " + _e.StackTrace);
                    backup.AddHubNotificationEvent(809, DedupIndex.Instance().IndexDBName, _e.Message);
                }
            }
            // now we have to send backup index and dedup index
            backup.Index.Terminate();
            //backup.Index = null;
            indexChunk = BuildIndexChunk();
        }