コード例 #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);
        }
コード例 #2
0
        /// <summary>
        /// Finish setting up distributed eviction.
        /// </summary>
        public void InitializeDistributedEviction(
            UpdateContentWithLastAccessTimeAsync updateMetadataFunc,
            Tracer tracer,
            PinnedSizeChecker pinnedSizeChecker,
            NagleQueue <ContentHash> reregisterHashQueue)
        {
            Contract.Assert(updateMetadataFunc != null);
            Contract.Assert(pinnedSizeChecker != null);
            Contract.Assert(tracer != null);
            Contract.Assert(reregisterHashQueue != null);

            UpdateContentWithLastAccessTimeAsync = updateMetadataFunc;
            Tracer              = tracer;
            PinnedSizeChecker   = pinnedSizeChecker;
            ReregisterHashQueue = reregisterHashQueue;
            IsInitialized       = true;
        }