private ICommit GetStreamHead(HeadKey headKey) { lock (_maxItemsToTrack) { _heads.TryGetValue(headKey, out ICommit head); return(head); } }
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); } }
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; }
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(); }
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); }