/// <summary> /// Tries to retrieve an entry from this cache. /// </summary> /// <param name="logTable"></param> /// <param name="index"></param> /// <param name="logEntry"></param> /// <returns></returns> public bool TryGetValue(ILogTable logTable, LogEntryIndex index, out LogEntry logEntry) { lock (_syncRoot) { return(_logEntries.TryGetValue(logTable, index, out logEntry)); } }
public void TestIncrement() { var idx = new LogEntryIndex(0); ++idx; idx.Should().Be(new LogEntryIndex(1)); }
/// <summary> /// Removes the given entry from this cache. /// </summary> /// <param name="logTable"></param> /// <param name="index"></param> /// <returns>true if the entry was removed, false otherwise</returns> public bool Remove(ILogTable logTable, LogEntryIndex index) { lock (_syncRoot) { return(_logEntries.Remove(logTable, index)); } }
/// <inheritdoc /> public ITask <LogEntry> this[LogEntryIndex index] { get { lock (_syncRoot) { return(Task2.FromResult(_entries[(int)index])); } } }
public void OnRead(LogEntryIndex index, int count, bool invalidate = false) { lock (_syncRoot) { foreach (var notifier in _notifiers.Values) { notifier.EmitChanged(new LogTableModification(index, count, invalidate)); } } }
/// <summary> /// Adds the given entry to this cache. /// If an entry already exists, then it will be replaced. /// </summary> /// <param name="logTable"></param> /// <param name="index"></param> /// <param name="logEntry"></param> public void Add(ILogTable logTable, LogEntryIndex index, LogEntry logEntry) { if (logTable == null) { throw new ArgumentNullException(nameof(logTable)); } lock (_syncRoot) { _logEntries.Add(logTable, index, logEntry); CollectIfNecessary(); } }
public bool Contains(ILogTable logTable, LogEntryIndex index) { if (logTable == null) { return(false); } if (index == LogEntryIndex.Invalid) { return(false); } lock (_syncRoot) { return(_logEntries.Contains(logTable, index)); } }
public void TestConstruction9() { var lineIndex = new LogLineIndex(1); var entryIndex = new LogEntryIndex(42); var sourceId = new LogLineSourceId(254); var t = new DateTime(2017, 11, 26, 12, 20, 1); var line = new LogLine(lineIndex, entryIndex, sourceId, "Hello, World!", LevelFlags.Trace, t); line.LineIndex.Should().Be(1); line.OriginalLineIndex.Should().Be(1); line.LogEntryIndex.Should().Be(42); line.SourceId.Should().Be(sourceId); line.Message.Should().Be("Hello, World!"); line.Level.Should().Be(LevelFlags.Trace); line.Timestamp.Should().Be(t); line.MatchedFilters.Should().Be(0); }
private void GetIndex(IReadOnlyList <LogLineIndex> indices, LogEntryIndex[] buffer, int destinationIndex) { lock (_syncRoot) { for (int i = 0; i < indices.Count; ++i) { var index = indices[i]; if (index >= 0 && index < _entries.Count) { buffer[destinationIndex + i] = new LogEntryIndex((int)index); } else { buffer[destinationIndex + i] = Core.Columns.LogEntryIndex.DefaultValue; } } } }
/// <summary> /// /// </summary> /// <param name="index"></param> public void RemoveFrom(LogEntryIndex index) { lock (_syncRoot) { if (index < 0) { Log.WarnFormat("Invalid index '{0}'", index); return; } if (index > _entries.Count) { Log.WarnFormat("Invalid index '{0}', Count is '{1}'", index, _entries.Count); return; } var available = _entries.Count - index; _entries.RemoveRange((int)index, available); _listeners.Invalidate((int)index, available); Touch(); } }
/// <summary> /// Adds the given range of entries to this cache. /// </summary> /// <param name="logTable"></param> /// <param name="startIndex"></param> /// <param name="logEntries"></param> public void AddRange(ILogTable logTable, LogEntryIndex startIndex, IEnumerable <LogEntry> logEntries) { if (logTable == null) { throw new ArgumentNullException(nameof(logTable)); } lock (_syncRoot) { LogEntryIndex index = startIndex; foreach (var logEntry in logEntries) { _logEntries.Add(logTable, index, logEntry); ++index; } // We DO NOT want to collect inside the loop. // Not doing so breaks the promise of not consuming more memory // than configured, however that is a very weak promise from the start // and thus we do not bother at trying to *strictly* keep it. Instead we // see it as a guideline not not exceed it too often or by too much (tm). CollectIfNecessary(); } }
public LogEntryInfo(LogEntryIndex entryIndex, LogLineIndex firstLineIndex) { EntryIndex = entryIndex; FirstLineIndex = firstLineIndex; }
/// <summary> /// /// </summary> /// <param name="index"></param> /// <param name="count"></param> /// <param name="isInvalidate"></param> public LogTableModification(LogEntryIndex index, int count, bool isInvalidate = false) { Section = new LogTableSection(index, count); IsInvalidate = isInvalidate; Schema = null; }
public void TestIncrement() { var idx = new LogEntryIndex(0); ++idx; idx.Should().Be(new LogEntryIndex(1)); }
public ITask<LogEntry> this[LogEntryIndex index] { get { throw new NotImplementedException(); } }
/// <summary> /// Initializes this section. /// </summary> /// <param name="index"></param> /// <param name="count"></param> public LogTableSection(LogEntryIndex index, int count) { Index = index; Count = count; }
public LogLine(LogLineIndex lineIndex, LogEntryIndex logEntryIndex, string message, LevelFlags level, DateTime?timestamp) : this((int)lineIndex, (int)logEntryIndex, message, level, timestamp) { }
public ITask<LogEntry> this[LogEntryIndex index] { get { return _accessQueue[index]; } }
/// <inheritdoc /> public ITask <LogEntry> this[LogEntryIndex index] { get { throw new NotImplementedException(); } }
public LogLine(LogLineIndex lineIndex, LogEntryIndex logEntryIndex, LogLineSourceId sourceId, string message, LevelFlags level, DateTime?timestamp) : this((int)lineIndex, (int)lineIndex, (int)logEntryIndex, sourceId, message, level, timestamp, matchedFilters : 0) { }
public LogLine(LogLineIndex lineIndex, LogEntryIndex logEntryIndex, LogLine line) : this((int)lineIndex, (int)logEntryIndex, line.Message, line.Level, line.Timestamp) { }