示例#1
0
 private ICommit GetStreamHead(HeadKey headKey)
 {
     lock (_maxItemsToTrack)
     {
         _heads.TryGetValue(headKey, out ICommit head);
         return(head);
     }
 }
示例#2
0
        private void RemoveHead(HeadKey head)
        {
            _heads.Remove(head);
            LinkedListNode <HeadKey> node = _maxItemsToTrack.Find(head); // There should only be ever one or none

            if (node != null)
            {
                _maxItemsToTrack.Remove(node);
            }
        }
示例#3
0
        private void UpdateStreamHead(ICommit committed)
        {
            HeadKey headKey = GetHeadKey(committed);
            ICommit head    = GetStreamHead(headKey);

            if (AlreadyTracked(head))
            {
                _maxItemsToTrack.Remove(headKey);
            }

            head = head ?? committed;
            head = head.StreamRevision > committed.StreamRevision ? head : committed;

            _heads[headKey] = head;
        }
示例#4
0
        private void TrackUpToCapacity(ICommit committed)
        {
            Logger.LogTrace(Resources.TrackingCommit, committed.CommitSequence, committed.StreamId, committed.BucketId);
            _maxItemsToTrack.AddFirst(GetHeadKey(committed));
            if (_maxItemsToTrack.Count <= _maxStreamsToTrack)
            {
                return;
            }

            HeadKey expired = _maxItemsToTrack.Last.Value;

            Logger.LogTrace(Resources.NoLongerTrackingStream, expired.StreamId, expired.BucketId);

            _heads.Remove(expired);
            _maxItemsToTrack.RemoveLast();
        }
示例#5
0
        public bool HeadNeedUpdate(out string key, KeyDate right)
        {
            key = string.Empty;
            if (Initialized)
            {
                if (lines.Head > right && lines.Tail <= right)
                {
                    if (lines.IsHead(HeadKey) || HeadKey > right)
                    {
                        key = HeadKey.ToString();
                    }
                    else
                    {
                        key = lines.GetNext(HeadKey).ToString();
                    }

                    return(true);
                }
            }
            return(false);
        }