Esempio n. 1
0
        private IList <ContentHashWithLastAccessTimeAndReplicaCount> GetUnpinnedHashesAndCompilePinnedSize(
            Context context,
            IEnumerable <ContentHashWithLastAccessTimeAndReplicaCount> hashesToPurge,
            PinnedSizeChecker pinnedSizeChecker,
            PurgeResult purgeResult)
        {
            long totalPinnedSize = 0; // Compile aggregate pinnedSize for the fail faster case
            var  unpinnedHashes  = new List <ContentHashWithLastAccessTimeAndReplicaCount>();

            foreach (var hashInfo in hashesToPurge)
            {
                var pinnedSize = pinnedSizeChecker(context, hashInfo.ContentHash);
                if (pinnedSize >= 0)
                {
                    totalPinnedSize += pinnedSize;
                }
                else
                {
                    unpinnedHashes.Add(hashInfo);
                }
            }

            purgeResult.MergePinnedSize(totalPinnedSize);
            return(unpinnedHashes);
        }
Esempio n. 2
0
        private IList <ContentHashWithLastAccessTimeAndReplicaCount> GetUnpinnedHashesAndCompilePinnedSize(IEnumerable <ContentHashWithLastAccessTimeAndReplicaCount> purgeableHashesBatch)
        {
            long totalPinnedSize = 0; // Compile aggregate pinnedSize for the fail faster case
            var  unpinnedHashes  = new List <ContentHashWithLastAccessTimeAndReplicaCount>();

            foreach (var hashInfo in purgeableHashesBatch)
            {
                var pinnedSize = _distributedEvictionSettings.PinnedSizeChecker(_context, hashInfo.ContentHash);
                if (pinnedSize >= 0)
                {
                    totalPinnedSize += pinnedSize;
                }
                else
                {
                    unpinnedHashes.Add(hashInfo);
                }
            }

            _purgeResult.MergePinnedSize(totalPinnedSize);
            return(unpinnedHashes);
        }