Load Balancer Simulator
CSCE 412 - Load Balancer Simulation Project
WebServer.h
Go to the documentation of this file.
1 
6 #ifndef WEBSERVER_H
7 #define WEBSERVER_H
8 
9 #include "Request.h"
10 
17 class WebServer {
18  private:
19  int id;
22 
23  public:
28  WebServer(int id);
29 
33  ~WebServer();
34 
39  int getId();
40 
45  const bool tick();
46 
51  void assignRequest(Request* req);
52 };
53 
54 #endif
Defines the Request struct representing a network request in the load balancer simulation.
Simulates a web server that receives and processes requests from the load balancer.
Definition: WebServer.h:17
int id
Unique identifier for this server.
Definition: WebServer.h:19
~WebServer()
Destructor. Cleans up any assigned request to prevent memory leaks.
Definition: WebServer.cpp:14
const bool tick()
Advances the server by one clock cycle.
Definition: WebServer.cpp:26
WebServer(int id)
Constructs a WebServer with the given ID.
Definition: WebServer.cpp:8
int cyclesRemaining
Clock cycles remaining to finish the current request.
Definition: WebServer.h:21
void assignRequest(Request *req)
Assigns a new request to this server for processing.
Definition: WebServer.cpp:42
int getId()
Returns the server's unique ID.
Definition: WebServer.cpp:22
Request * currRequest
Pointer to the currently assigned request, or nullptr if idle.
Definition: WebServer.h:20
Represents a single network request with source/destination IPs, processing time, and job type.
Definition: Request.h:14