public GetDateBoundCommand(DateTime date, bool getDate, ListUtils.ValueBound bound, IDateBoundsCache dateBoundsCache) { this.date = date; this.bound = bound; this.userNeedsDate = getDate; this.dateBoundsCache = dateBoundsCache; }
static void TestBound(int value, ListUtils.ValueBound bound, int expectedIdx) { List <int> lst = new List <int>(new int[] { 0, 2, 2, 2, 3, 5, 7, 8, 8, 10 }); int actual = ListUtils.GetBound(lst, value, bound, Comparer <int> .Default); Assert.AreEqual(expectedIdx, actual); }
static void FindDateBoundTest(ListUtils.ValueBound bound, long dateTicks, string expectedMessage, EntryPartition?searchRangeBegin = null, EntryPartition?searchRangeEnd = null) { var entry = AzureDiagnosticsUtils.FindDateBound( new AzureDiagnosticLogsTableMock() .Add(TestEventTimestampFromMinutes(1), "1") .Add(TestEventTimestampFromMinutes(1) + 2, "1+2") .Add(TestEventTimestampFromMinutes(1) + 2, "1+2.2") .Add(TestEventTimestampFromMinutes(1) + 3, "1+3") .Add(TestEventTimestampFromMinutes(1) + 10, "1+10") .Add(TestEventTimestampFromMinutes(2), "2") .Add(TestEventTimestampFromMinutes(3) + 100, "3+100") .Add(TestEventTimestampFromMinutes(3) + 200, "3+200") .Add(TestEventTimestampFromMinutes(3) + 300, "3+300") .Add(TestEventTimestampFromMinutes(3) + 300, "3+300.2") .Add(TestEventTimestampFromMinutes(1000) + 10, "1000+10") .Add(TestEventTimestampFromMinutes(1000) + 20, "1000+20") .Add(TestEventTimestampFromMinutes(100000), "100000") .Add(TestEventTimestampFromMinutes(100000) + 100, "100000+100"), new DateTime(dateTicks, DateTimeKind.Utc), bound, searchRangeBegin.GetValueOrDefault(EntryPartition.MinValue), searchRangeEnd.GetValueOrDefault(EntryPartition.MaxValue), CancellationToken.None); if (expectedMessage == null) { Assert.IsTrue(!entry.HasValue); } else { Assert.IsTrue(entry.HasValue); Assert.AreEqual(expectedMessage, (entry.Value.Entry as WADLogsTableEntry).Message); } }
public DateBoundPositionResponseData GetDateBoundPosition(DateTime d, ListUtils.ValueBound bound) { var idx = ListUtils.GetBound(messages, (IMessage)null, bound, new DatesComparer(d)); if (idx < 0) { return new DateBoundPositionResponseData() { Position = -1, Index = -1, IsBeforeBeginPosition = true, } } ; if (idx >= messages.Count) { return new DateBoundPositionResponseData() { Position = messages.Count == 0 ? 0 : (messages[messages.Count - 1].Position + 1), Index = messages.Count, IsEndPosition = true, } } ; return(new DateBoundPositionResponseData() { Position = messages[idx].Position, Index = idx, Date = messages[idx].Time }); } }; }
Task <DateBoundPositionResponseData> ITimeGapsSource.GetDateBoundPosition( DateTime d, ListUtils.ValueBound bound, CancellationToken cancellation ) { return(source.Provider.GetDateBoundPosition(d, bound, true, LogProviderCommandPriority.BackgroundActivity, cancellation)); }
Task <DateBoundPositionResponseData> ILogProvider.GetDateBoundPosition( DateTime d, ListUtils.ValueBound bound, bool getDate, LogProviderCommandPriority priority, CancellationToken cancellation) { CheckDisposed(); var ret = new GetDateBoundCommand(d, getDate, bound, dateBoundsCache); var cmd = new Command(Command.CommandType.GetDateBound, priority, tracer, cancellation, ret); PostCommand(cmd); return(ret.Task); }
static string ToString(ListUtils.ValueBound bound) { switch (bound) { case LogJoint.ListUtils.ValueBound.Lower: return("L"); case LogJoint.ListUtils.ValueBound.LowerReversed: return("LR"); case LogJoint.ListUtils.ValueBound.Upper: return("U"); case LogJoint.ListUtils.ValueBound.UpperReversed: return("UR"); default: Assert.Fail(); return(""); } }
public static IndexedAzureDiagnosticLogEntry?FindDateBound( IAzureDiagnosticLogsTable wadTable, DateTime date, ListUtils.ValueBound bound, EntryPartition searchRangeBegin, EntryPartition searchRangeEnd, CancellationToken cancellationToken) { switch (bound) { case ListUtils.ValueBound.Lower: return(FindLowerDateBound(wadTable, date, searchRangeEnd, cancellationToken)); case ListUtils.ValueBound.LowerReversed: return(FindLowerReversedDateBound(wadTable, date, searchRangeBegin, cancellationToken)); default: throw new NotImplementedException("Searching for " + bound.ToString() + " bound in Azure Diagnostics Logs is not implemented"); } }
Task <DateBoundPositionResponseData> IMessagesSource.GetDateBoundPosition(DateTime d, ListUtils.ValueBound bound, LogProviderCommandPriority priority, System.Threading.CancellationToken cancellation) { return(Task.FromResult(messages.GetDateBoundPosition(d, bound))); }
DateBoundPositionResponseData ICombinedSourceSearchResult.GetDateBoundPosition(DateTime d, ListUtils.ValueBound bound) { return(messages.GetDateBoundPosition(d, bound)); }
Task <DateBoundPositionResponseData> ITimeGapsSource.GetDateBoundPosition(DateTime d, ListUtils.ValueBound bound, CancellationToken cancellation) { var ret = new DateBoundPositionResponseData() { IsEndPosition = true, IsBeforeBeginPosition = true }; bool findSmallestDate = bound == ListUtils.ValueBound.Lower || bound == ListUtils.ValueBound.Upper; foreach (var r in EnumVisibleResults().Select(r => r.GetLastSnapshot()).Where(s => s != null)) { var bnd = r.GetDateBoundPosition(d, bound); if (bnd.Date != null) { if (ret.Date == null) { ret.Date = bnd.Date; } else if (findSmallestDate) { if (bnd.Date.Value < ret.Date.Value) { ret.Date = bnd.Date; } } else { if (bnd.Date.Value > ret.Date.Value) { ret.Date = bnd.Date; } } } if (!bnd.IsBeforeBeginPosition) { ret.IsBeforeBeginPosition = false; } if (!bnd.IsEndPosition) { ret.IsEndPosition = false; } ret.Position += bnd.Index; // use sum of indexes as virtual position } return(Task.FromResult(ret)); }
Task <DateBoundPositionResponseData> LogViewer.IMessagesSource.GetDateBoundPosition( DateTime d, ListUtils.ValueBound bound, LogProviderCommandPriority priority, CancellationToken cancellation) { return(Task.FromResult(ssr.GetDateBoundPosition(d, bound))); }
public static long LocateDateBound(IPositionedMessagesReader reader, DateTime date, ListUtils.ValueBound bound, CancellationToken cancellation) { var d = new MessageTimestamp(date); long begin = reader.BeginPosition; long end = reader.EndPosition; long pos = begin; long count = end - begin; for (; 0 < count;) { long count2 = count / 2; MessageTimestamp d2 = ReadNearestMessageTimestamp(reader, pos + count2).GetValueOrDefault(MessageTimestamp.MaxValue); bool moveRight = false; switch (bound) { case ListUtils.ValueBound.Lower: case ListUtils.ValueBound.UpperReversed: moveRight = d2 < d; break; case ListUtils.ValueBound.Upper: case ListUtils.ValueBound.LowerReversed: moveRight = d2 <= d; break; } if (moveRight) { pos += count2 + 1; count -= count2 + 1; } else { count = count2; } cancellation.ThrowIfCancellationRequested(); } if (bound == ListUtils.ValueBound.LowerReversed || bound == ListUtils.ValueBound.UpperReversed) { long?tmp = FindPrevMessagePosition(reader, pos); if (tmp == null) { return(begin - 1); } pos = tmp.Value; } return(pos); }
public static long LocateDateBound(IPositionedMessagesReader reader, DateTime date, ListUtils.ValueBound bound) { return(LocateDateBound(reader, date, bound, CancellationToken.None)); }
Task <DateBoundPositionResponseData> IMessagesSource.GetDateBoundPosition(DateTime d, ListUtils.ValueBound bound, LogProviderCommandPriority priority, CancellationToken cancellation) { return(ls.Provider.GetDateBoundPosition(d, bound, false, priority, cancellation)); }