Skip to content
This repository has been archived by the owner on Oct 11, 2023. It is now read-only.

Commit

Permalink
Save stats for all simulations when multiple sims are running (#307)
Browse files Browse the repository at this point in the history
  • Loading branch information
ap-git-hub authored and hathind-ms committed Oct 31, 2018
1 parent d4443bb commit a4b237d
Showing 1 changed file with 17 additions and 15 deletions.
32 changes: 17 additions & 15 deletions SimulationAgent/Agent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -240,28 +240,30 @@ private async Task StopInactiveSimulationsAsync(IList<Simulation> activeSimulati

private async Task SaveSimulationStatisticsAsync(IList<Simulation> simulations)
{
foreach (var simulation in simulations)
DateTimeOffset now = DateTimeOffset.UtcNow;
TimeSpan duration = now - this.lastSaveStatisticsTime;

// Save statistics for simulations at specified interval
if (duration.Seconds >= SAVE_STATS_INTERVAL_SECS)
{
try
foreach (var simulation in simulations)
{
if (this.simulationManagers.ContainsKey(simulation.Id))
try
{
DateTimeOffset now = DateTimeOffset.UtcNow;
TimeSpan duration = now - this.lastSaveStatisticsTime;

// Save simulation statistics at specified interval
if (duration.Seconds >= SAVE_STATS_INTERVAL_SECS)
if (this.simulationManagers.ContainsKey(simulation.Id))
{
await this.simulationManagers[simulation.Id].SaveStatisticsAsync();

this.lastSaveStatisticsTime = now;
{
await this.simulationManagers[simulation.Id].SaveStatisticsAsync();
}
}
}
catch (Exception e)
{
this.log.Error("Failed to save simulation statistics.", () => new { simulation.Id, e });
}
}
catch (Exception e)
{
this.log.Error("Failed to save simulation statistics.", () => new { simulation.Id, e });
}

this.lastSaveStatisticsTime = now;
}
}

Expand Down

0 comments on commit a4b237d

Please sign in to comment.