/// <summary> /// Update the Minutes /// </summary> /// <param name="recordData">The Data</param> private void UpdateMinute(IIncomingRecordData recordData) { //Get the minute the data came in var dataMinuteTime = recordData.LoadedDateTime.Minute; var lastMinute = minutes[minutes.Count - 1]; //Ctor adds a MinuteRecord; so this won't be empty var lastMinuteTime = lastMinute.Identifier; if (lastMinuteTime != dataMinuteTime) { /* * For a non-busy machine; or one that got restarted there may have been a period of * time that the data wasn't flowing in - this corrects for it */ for (var missingMinute = lastMinuteTime; missingMinute < dataMinuteTime; missingMinute++) { //This adds the missing time and values will be defaulted to 0 (zero) minutes.Add(new MinuteRecord(missingMinute)); base.UpdateEmpty(); } lastMinute = new MinuteRecord(dataMinuteTime); minutes.Add(lastMinute); //Fall through to apply the record data } //It's still the current minute; so we update lastMinute.Update(recordData); }
/// <summary> /// Updates the information tracking the current record /// </summary> /// <param name="recordData">The data for the record</param> public override void Update(IIncomingRecordData recordData) { //Minutes go first because if there's gaps; it needs to //add empty records to base UpdateMinute(recordData); base.Update(recordData);//Updates the hour average information }
/// <summary> /// Updates the information tracking the current record /// </summary> /// <param name="recordData">The data for the record</param> public virtual void Update(IIncomingRecordData recordData) { if (IsCompletedAdding) { Log.Info(() => "Attempted to add after CompletedAdding"); return; } cpuAverageCalc.Update(recordData.CpuLoad); ramAverageCalc.Update(recordData.RamLoad); }
/// <summary> /// <see cref="IRecordQueue.AddRecordData"/> /// </summary> public void AddRecordData(IIncomingRecordData data) { if (data == null) { const string msg = "RecordData cannot be null."; Log.Error(() => msg); return;//We'll play nice and not crash the service } QueuedRecords.Add(data); }
/// <summary> /// This adds a RecordLoad data set into the correct server /// </summary> /// <param name="incomingRecordData"></param> public virtual void AddRecordLoad(IIncomingRecordData incomingRecordData) { if (string.IsNullOrEmpty(incomingRecordData?.ServerName)) { Log.Error(() => "Invalid incomingRecordData"); return; } var serverData = ServerSet[incomingRecordData.ServerName] as ServerData; if (serverData == null) { serverData = new ServerData(incomingRecordData.ServerName); ServerSet.Add(incomingRecordData.ServerName, serverData); } serverData.Update(incomingRecordData); }
/// <summary> /// Updates the information tracking the current record /// </summary> /// <param name="recordData">The data for the record</param> public void Update(IIncomingRecordData recordData) { /* * If it's been over 24 hours; reset as we shouldn't have * data anymore. */ var lastEntryDif = recordData.LoadedDateTime.Subtract(lastDateTime); if (lastEntryDif.Hours == 0) //Same Hour { /* * No-oping this. * It should be the only check MOST of the time; so having * it first will minimize the cycles; and in a heavy load * this small optimization can have significant improvement */ } else if (lastEntryDif.Hours > 24) //It's been more than 24 hours; reset { Initialize(recordData.LoadedDateTime.Hour); //reset } else if (lastEntryDif.Hours > 1) //It's been more than an hour since last Update { MultipleHourJump(recordData.LoadedDateTime, lastEntryDif); } else if (lastEntryDif.Hours == 1) //This had better be the last case we hit { NewHour(recordData.LoadedDateTime); } else { /* * We should REALLY never get here... but... incase we do; KA-BOOM */ var msg = $"Incoming [time={recordData.LoadedDateTime}] is of an unexpected form resulting in an invalid [timeSpan={lastEntryDif}] from [lastDateTime={lastDateTime}]"; Log.Error(() => msg); throw new InvalidOperationException(msg); } lastHourRecord.Update(recordData);//Update lastDateTime = recordData.LoadedDateTime; }
/// <summary> /// Update the server with new data /// </summary> /// <param name="incomingRecordData"></param> public void Update(IIncomingRecordData incomingRecordData) { dayContainer.Update(incomingRecordData); }