internal void SetState(RequestState value) { if (this.curState == value) { return; } DateTime utcNow = TimeProvider.UtcNow; TimeSpan duration = utcNow.Subtract(this.stateChangeTimestamp); this.RefreshDurations(); if (RequestJobTimeTracker.SupportDurationTracking(this.curState)) { RequestJobDurationData requestJobDurationData; if (!this.durations.TryGetValue(this.curState, out requestJobDurationData)) { requestJobDurationData = new RequestJobDurationData(this.curState); } requestJobDurationData.AddTime(duration); this.durations[this.curState] = requestJobDurationData; } this.stateChangeTimestamp = utcNow; this.curState = value; if (RequestJobTimeTracker.SupportDurationTracking(this.curState)) { this.UpdateActiveCounts(this.curState, 1L); this.IncRateCounts(this.curState); } }
public static void MergeTimestamps(RequestJobTimeTracker mrsTimeTracker, RequestJobTimeTracker other) { foreach (RequestJobTimestampData requestJobTimestampData in other.Timestamps) { if (!RequestJobTimeTracker.mrsMasteredTimestamps.Contains(requestJobTimestampData.Id)) { if (RequestJobTimeTracker.nonMrsMasteredTimestamps.Contains(requestJobTimestampData.Id)) { mrsTimeTracker.SetTimestamp(requestJobTimestampData.Id, new DateTime?(requestJobTimestampData.Timestamp)); } else { DateTime?timestamp = mrsTimeTracker.GetTimestamp(requestJobTimestampData.Id); if (timestamp == null || timestamp.Value < requestJobTimestampData.Timestamp) { mrsTimeTracker.SetTimestamp(requestJobTimestampData.Id, new DateTime?(requestJobTimestampData.Timestamp)); } } } } foreach (RequestJobTimestamp ts in RequestJobTimeTracker.nonMrsMasteredTimestamps) { if (other.GetTimestamp(ts) == null) { mrsTimeTracker.SetTimestamp(ts, null); } } }
private static IEnumerable <IObjectLogPropertyDefinition <RequestJobLogData> > GetTimeTrackerDurations() { List <IObjectLogPropertyDefinition <RequestJobLogData> > list = new List <IObjectLogPropertyDefinition <RequestJobLogData> >(); foreach (object obj in Enum.GetValues(typeof(RequestState))) { RequestState requestState = (RequestState)obj; if (RequestJobTimeTracker.SupportDurationTracking(requestState)) { list.Add(new RequestJobLog.RequestJobLogSchema.TimeTrackerDurationProperty(requestState)); } } return(list); }
public void Append(RequestJobTimeTracker timeTracker, ReportEntryFlags flags) { ThrottleDurations sourceThrottleDurations; ThrottleDurations targetThrottleDurations; timeTracker.GetThrottledDurations(out sourceThrottleDurations, out targetThrottleDurations); ReportEntry reportEntry = new ReportEntry(); reportEntry.Flags = flags; if ((flags & ReportEntryFlags.SourceThrottleDurations) != ReportEntryFlags.None) { reportEntry.SourceThrottleDurations = sourceThrottleDurations; } if ((flags & ReportEntryFlags.TargetThrottleDurations) != ReportEntryFlags.None) { reportEntry.TargetThrottleDurations = targetThrottleDurations; } this.Append(reportEntry); }