|
Aggie Student Toolkit — Load Balancer CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
|
Owns one complete run: the generator, the load balancer(s) and the clock. More...
#include <Simulation.h>
Public Member Functions | |
| Simulation (const Config &config, Logger &logger) | |
| Builds the components described by a validated configuration. | |
| void | run () |
| Runs every clock cycle of the simulation. | |
| void | writeReport (std::ostream &out) const |
| Writes the full log summary: settings, randomness, results, snapshots and scaling timeline. | |
| std::vector< const LoadBalancer * > | loadBalancers () const |
| const RequestGenerator & | generator () const |
Owns one complete run: the generator, the load balancer(s) and the clock.
In normal mode the simulation drives a single LoadBalancer. In switch mode (bonus) it drives a Switch whose two load balancers split the initial servers in proportion to the expected job mix.
run() fills the initial queue with servers x queuePerServer requests, dispatches at time 0, then advances the clock one cycle at a time, printing a status line every Config::statusEvery cycles. writeReport() produces the log summary required for the assignment.
Definition at line 32 of file Simulation.h.
Builds the components described by a validated configuration.
| config | Settings for the run. |
| logger | Destination for events and status lines. |
Definition at line 79 of file Simulation.cpp.
| void Simulation::run | ( | ) |
Runs every clock cycle of the simulation.
Definition at line 103 of file Simulation.cpp.
| void Simulation::writeReport | ( | std::ostream & | out | ) | const |
Writes the full log summary: settings, randomness, results, snapshots and scaling timeline.
| out | Stream to write to. |
Definition at line 288 of file Simulation.cpp.
| std::vector< const LoadBalancer * > Simulation::loadBalancers | ( | ) | const |
Definition at line 147 of file Simulation.cpp.
| const RequestGenerator & Simulation::generator | ( | ) | const |
Definition at line 161 of file Simulation.cpp.