|
CSCE 412 - Project 3 Load Balancer
|
A class to represent a server that processes a request. More...
#include <webserver.h>
Public Member Functions | |
| WebServer (char name) | |
| Constructs a WebServer with a specified name. | |
| void | addRequest (Request req, int currTime) |
| Adds a request to the server's queue. | |
| bool | isRequestDone (int currTime) |
| Checks if the current request is done processing. | |
| bool | isIdle () const |
| Checks if the server is currently idle. | |
| char | getName () const |
| Gets the name of the server. | |
| void | incrementProcessedRequestCount () |
| Increments the count of processed requests. | |
| int | getProcessedRequestCount () const |
| Gets the count of processed requests. | |
A class to represent a server that processes a request.
The WebServer class handles incoming requests, processes them, and keeps track of the number of requests processed.
| WebServer::WebServer | ( | char | name | ) |
Constructs a WebServer with a specified name.
Constructs a WebServer object with the specified name.
| name | A character representing the server's name. |
Initializes the server name, request start time, active request flag, and processed request count.
| name | A character representing the server's name. |
| void WebServer::addRequest | ( | Request | req, |
| int | currTime ) |
Adds a request to the server's queue.
Adds a request to the server.
| req | The request to be added. |
| currTime | The current time in clock cycles. |
This method assigns the given request to the server, sets the current time for when the request starts processing, and updates the server's active request status. It also adjusts the processing time based on the job type (Processing or Streaming).
| req | The request to be added. |
| currTime | The current time in clock cycles. |
| char WebServer::getName | ( | ) | const |
Gets the name of the server.
| int WebServer::getProcessedRequestCount | ( | ) | const |
Gets the count of processed requests.
Retrieves the count of processed requests.
| void WebServer::incrementProcessedRequestCount | ( | ) |
Increments the count of processed requests.
This method increases the processed request count by one.
| bool WebServer::isIdle | ( | ) | const |
Checks if the server is currently idle.
| bool WebServer::isRequestDone | ( | int | currTime | ) |
Checks if the current request is done processing.
| currTime | The current time in clock cycles. |
This method evaluates whether the current request has completed processing based on the job type and the current time.
| currTime | The current time in clock cycles. |