CSCE 412 - Project 3 Load Balancer
Loading...
Searching...
No Matches
WebServer Class Reference

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.
 

Detailed Description

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.

Constructor & Destructor Documentation

◆ WebServer()

WebServer::WebServer ( char name)

Constructs a WebServer with a specified name.

Constructs a WebServer object with the specified name.

Parameters
nameA character representing the server's name.

Initializes the server name, request start time, active request flag, and processed request count.

Parameters
nameA character representing the server's name.

Member Function Documentation

◆ addRequest()

void WebServer::addRequest ( Request req,
int currTime )

Adds a request to the server's queue.

Adds a request to the server.

Parameters
reqThe request to be added.
currTimeThe 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).

Parameters
reqThe request to be added.
currTimeThe current time in clock cycles.

◆ getName()

char WebServer::getName ( ) const

Gets the name of the server.

Returns
The server's name.
The name of the server.

◆ getProcessedRequestCount()

int WebServer::getProcessedRequestCount ( ) const

Gets the count of processed requests.

Retrieves the count of processed requests.

Returns
The total number of processed requests.

◆ incrementProcessedRequestCount()

void WebServer::incrementProcessedRequestCount ( )

Increments the count of processed requests.

This method increases the processed request count by one.

◆ isIdle()

bool WebServer::isIdle ( ) const

Checks if the server is currently idle.

Returns
True if the server has no active requests, false otherwise.

◆ isRequestDone()

bool WebServer::isRequestDone ( int currTime)

Checks if the current request is done processing.

Parameters
currTimeThe current time in clock cycles.
Returns
True if the request is completed, false otherwise.

This method evaluates whether the current request has completed processing based on the job type and the current time.

Parameters
currTimeThe current time in clock cycles.
Returns
True if the request is completed, false otherwise.

The documentation for this class was generated from the following files: