Aggie Student Toolkit — Load Balancer
CSCE 412 Project 4
Arnav Fotedar · Fall 2026 · C++ load balancer simulation
Toggle main menu visibility
Loading...
Searching...
No Matches
Switch.h
Go to the documentation of this file.
1
6
7
#ifndef SWITCH_H
8
#define SWITCH_H
9
10
#include <memory>
11
#include <vector>
12
13
#include "
LoadBalancer.h
"
14
#include "
Request.h
"
15
24
class
Switch
{
25
public
:
31
Switch
(std::unique_ptr<LoadBalancer>
processing
, std::unique_ptr<LoadBalancer>
streaming
);
32
39
bool
route
(
const
Request
& request,
unsigned
long
cycle);
40
42
void
start
();
43
49
void
processCycle
(
unsigned
long
cycle,
const
std::vector<Request>& arrivals);
50
52
LoadBalancer
&
processing
();
54
LoadBalancer
&
streaming
();
56
unsigned
long
routedProcessing
()
const
;
58
unsigned
long
routedStreaming
()
const
;
59
60
private
:
61
std::unique_ptr<LoadBalancer> processing_;
62
std::unique_ptr<LoadBalancer> streaming_;
63
unsigned
long
routedProcessing_ = 0;
64
unsigned
long
routedStreaming_ = 0;
65
};
66
67
#endif
LoadBalancer.h
Declares the LoadBalancer class, which queues requests, dispatches them and scales its server pool.
Request.h
Defines the Request structure and its JobType that flow through the load balancer.
LoadBalancer
Distributes queued requests across a dynamically sized pool of WebServer objects.
Definition
LoadBalancer.h:116
Switch::processing
LoadBalancer & processing()
Definition
Switch.cpp:48
Switch::routedStreaming
unsigned long routedStreaming() const
Definition
Switch.cpp:54
Switch::Switch
Switch(std::unique_ptr< LoadBalancer > processing, std::unique_ptr< LoadBalancer > streaming)
Creates a switch that owns both load balancers.
Definition
Switch.cpp:11
Switch::processCycle
void processCycle(unsigned long cycle, const std::vector< Request > &arrivals)
Splits this cycle's arrivals by job type and runs one cycle on both load balancers.
Definition
Switch.cpp:32
Switch::streaming
LoadBalancer & streaming()
Definition
Switch.cpp:50
Switch::routedProcessing
unsigned long routedProcessing() const
Definition
Switch.cpp:52
Switch::start
void start()
Starts both load balancers (records starting queues, dispatches at time 0).
Definition
Switch.cpp:27
Switch::route
bool route(const Request &request, unsigned long cycle)
Sends one request to the load balancer for its job type.
Definition
Switch.cpp:18
Request
A single web request waiting for, or receiving, service.
Definition
Request.h:41
Switch.h
Generated by
1.18.0