@@ -44,63 +44,6 @@ public AdminController(
4444 _logger = logger ?? throw new ArgumentNullException ( nameof ( logger ) ) ;
4545 }
4646
47- /// <summary>
48- /// Resets all active simulations and releases allocated memory.
49- /// </summary>
50- /// <remarks>
51- /// <para>
52- /// This endpoint performs a full reset of the simulator:
53- /// </para>
54- /// <list type="bullet">
55- /// <item>Releases all allocated memory blocks</item>
56- /// <item>Forces garbage collection</item>
57- /// <item>Clears active simulation tracking (CPU/ThreadBlock simulations will complete naturally)</item>
58- /// </list>
59- /// <para>
60- /// <strong>Note:</strong> CPU stress and thread blocking simulations cannot be instantly
61- /// cancelled - they will complete their configured duration. Only memory allocations
62- /// are immediately released.
63- /// </para>
64- /// </remarks>
65- /// <returns>Summary of the reset operation.</returns>
66- /// <response code="200">Reset completed successfully.</response>
67- [ HttpPost ( "reset-all" ) ]
68- [ ProducesResponseType ( typeof ( ResetAllResponse ) , StatusCodes . Status200OK ) ]
69- public IActionResult ResetAll ( )
70- {
71- var clientIp = HttpContext . Connection . RemoteIpAddress ? . ToString ( ) ;
72- _logger . LogWarning (
73- "⚠️ Reset-all requested from {ClientIP}. Releasing all resources..." ,
74- clientIp ) ;
75-
76- // Get state before reset
77- var activeSimulations = _simulationTracker . GetActiveSimulations ( ) ;
78- var memoryStatus = _memoryPressureService . GetMemoryStatus ( ) ;
79-
80- // Release memory (this also unregisters from tracker)
81- var releaseResult = _memoryPressureService . ReleaseAllMemory ( forceGc : true ) ;
82-
83- _logger . LogInformation (
84- "Reset complete: Released {BlocksReleased} memory blocks ({BytesReleased} bytes), " +
85- "had {ActiveSimulations} active simulations" ,
86- releaseResult . ReleasedBlockCount ,
87- releaseResult . ReleasedBytes ,
88- activeSimulations . Count ) ;
89-
90- return Ok ( new ResetAllResponse
91- {
92- Success = true ,
93- Message = "Reset completed. Memory released. Note: CPU and ThreadBlock simulations will complete naturally." ,
94- MemoryBlocksReleased = releaseResult . ReleasedBlockCount ,
95- BytesReleased = releaseResult . ReleasedBytes ,
96- ActiveSimulationsAtReset = activeSimulations . Count ,
97- SimulationTypesActive = activeSimulations
98- . GroupBy ( s => s . Type )
99- . ToDictionary ( g => g . Key . ToString ( ) , g => g . Count ( ) ) ,
100- GarbageCollectionForced = true
101- } ) ;
102- }
103-
10447 /// <summary>
10548 /// Gets current simulation statistics.
10649 /// </summary>
@@ -149,47 +92,6 @@ public IActionResult GetStats()
14992 }
15093}
15194
152- /// <summary>
153- /// Response from the reset-all operation.
154- /// </summary>
155- public class ResetAllResponse
156- {
157- /// <summary>
158- /// Whether the reset was successful.
159- /// </summary>
160- public bool Success { get ; init ; }
161-
162- /// <summary>
163- /// Human-readable message about the reset.
164- /// </summary>
165- public required string Message { get ; init ; }
166-
167- /// <summary>
168- /// Number of memory blocks that were released.
169- /// </summary>
170- public int MemoryBlocksReleased { get ; init ; }
171-
172- /// <summary>
173- /// Total bytes of memory that were released.
174- /// </summary>
175- public long BytesReleased { get ; init ; }
176-
177- /// <summary>
178- /// Number of active simulations at the time of reset.
179- /// </summary>
180- public int ActiveSimulationsAtReset { get ; init ; }
181-
182- /// <summary>
183- /// Breakdown of active simulations by type.
184- /// </summary>
185- public Dictionary < string , int > SimulationTypesActive { get ; init ; } = new ( ) ;
186-
187- /// <summary>
188- /// Whether garbage collection was forced.
189- /// </summary>
190- public bool GarbageCollectionForced { get ; init ; }
191- }
192-
19395/// <summary>
19496/// Current simulation statistics.
19597/// </summary>
0 commit comments