Load Balancer Simulation
A simulation of a load balancer with dynamic server scaling in C++
Loading...
Searching...
No Matches
WebServer.h
Go to the documentation of this file.
1
5
6#ifndef WEBSERVER_H
7#define WEBSERVER_H
8
9#include "Request.h"
10
15class WebServer {
16public:
21 explicit WebServer(int id);
22
27 void assignRequest(const Request& req);
28
32 void process();
33
37 void clear();
38
43 bool isBusy() const;
44
49 bool isFinished() const;
50
55 int getId() const { return id_; }
56
57private:
58 int id_;
59 bool busy_;
62};
63
64#endif
Defines the Request structure for load balancer simulation.
int remainingTime_
Definition WebServer.h:60
void clear()
Clear the current request and mark server as idle.
Definition WebServer.cpp:31
Request currentRequest_
Definition WebServer.h:61
bool isFinished() const
Check if the current request has finished processing.
Definition WebServer.cpp:37
void assignRequest(const Request &req)
Assign a request to this server for processing.
Definition WebServer.cpp:12
WebServer(int id)
Construct a web server with the given ID.
Definition WebServer.cpp:9
void process()
Advance processing by one clock cycle (decrements remaining time).
Definition WebServer.cpp:19
bool isBusy() const
Check if the server is currently processing a request.
Definition WebServer.cpp:26
bool busy_
Definition WebServer.h:59
int getId() const
Get the server's unique ID.
Definition WebServer.h:55
Represents a single request/job in the load balancer simulation.
Definition Request.h:15