Пример #1
0
        public void FinalizeBlobAddition(string bsname, byte[] blobhash, BlobLocation.BlobType blobType)
        {
            // Handle root blob
            BlobLocation rootblocation = GetBlobLocation(blobhash);

            if (rootblocation.TotalReferenceCount == 0)
            {
                IBlobReferenceIterator blobReferences = GetAllBlobReferences(blobhash, blobType, true, false);
                // Loop through children
                foreach (byte[] reference in blobReferences)
                {
                    BlobLocation blocation = GetBlobLocation(blobhash);
                    if (blocation.TotalReferenceCount > 0) // This was already stored
                    {
                        blobReferences.SkipChildren();
                    }
                    IncrementReferenceCountNoRecurse(bsname, blocation, blobhash, 1);
                }
            }
            // Increment root blob
            IncrementReferenceCountNoRecurse(bsname, rootblocation, blobhash, 1);
        }
Пример #2
0
        public void DecrementReferenceCount(string backupsetname, byte[] blobhash, BlobLocation.BlobType blobtype,
                                            bool includefiles)
        {
            BlobLocation rootBlobLocation = GetBlobLocation(blobhash);

            if (rootBlobLocation.BSetReferenceCounts[backupsetname] == 1) // To be deleted?
            {
                IBlobReferenceIterator blobReferences = GetAllBlobReferences(blobhash, blobtype, includefiles, false);
                foreach (var reference in blobReferences)
                {
                    BlobLocation blocation = GetBlobLocation(reference);

                    // When we finish iterating over the children, decrement this blob
                    blobReferences.PostOrderAction(() => IncrementReferenceCountNoRecurse(backupsetname, blocation, reference, -1));
                    if (rootBlobLocation.BSetReferenceCounts[backupsetname] != 1) // Not to be deleted?
                    {
                        // Dont need to decrement child references if this wont be deleted
                        blobReferences.SkipChildren();
                    }
                }
            }
            IncrementReferenceCountNoRecurse(backupsetname, rootBlobLocation, blobhash, -1); // must delete parent last so parent can be loaded/used in GetAllBlobReferences()
        }
Пример #3
0
        public void TransferBlobAndReferences(BlobStore dst, string dstbackupset, byte[] blobhash,
                                              BlobLocation.BlobType blobtype, bool includefiles)
        {
            BlobLocation rootDstBlobLocation;

            try
            {
                rootDstBlobLocation = dst.GetBlobLocation(blobhash);
            }
            catch (KeyNotFoundException)
            {
                byte[] blob;
                (rootDstBlobLocation, blob) = TransferBlobNoReferences(dst, dstbackupset, blobhash, GetBlobLocation(blobhash));

                IBlobReferenceIterator blobReferences = GetAllBlobReferences(blobhash, blobtype, includefiles, false);
                blobReferences.SupplyData(blob);
                foreach (var reference in blobReferences)
                {
                    BlobLocation dstBlobLocation;
                    try
                    {
                        dstBlobLocation = dst.GetBlobLocation(reference);
                        // Dont need to increment child references if this already exists
                        blobReferences.SkipChildren();
                    }
                    catch (KeyNotFoundException)
                    {
                        (dstBlobLocation, blob) = TransferBlobNoReferences(dst, dstbackupset, reference, GetBlobLocation(reference));
                        blobReferences.SupplyData(blob);
                    }
                    // When we finish iterating over the children, increment this blob
                    blobReferences.PostOrderAction(() => dst.IncrementReferenceCountNoRecurse(dstbackupset, dstBlobLocation, reference, 1));
                }
            }
            dst.IncrementReferenceCountNoRecurse(dstbackupset, rootDstBlobLocation, blobhash, 1);
        }