Class Server

java.lang.Object
  extended by Server

public class Server
extends java.lang.Object

Class for simulation server resources.
COMP 2100
Project 3
October 2014


Constructor Summary
Server(java.lang.String name)
          Creates new Server that is idle.
 
Method Summary
 Customer getCustomer()
          Obtain reference to Customer currently using this server.
 java.lang.String getName()
          Obtain name given to this server when it was constructed.
 Statistic getServiceTimeStat()
          Obtain reference to server's service time statistic.
 Statistic getUtilizationStat()
          Obtain reference to server utilization statistic.
 boolean isBusy()
          Determine whether or not server is busy with customer.
 Customer release()
          Server is ordered to release its current customer.
 boolean request(Customer c)
          Customer requests to use the server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Server

public Server(java.lang.String name)
Creates new Server that is idle.

Parameters:
name - Descriptive name for this server
Method Detail

isBusy

public boolean isBusy()
Determine whether or not server is busy with customer.

Returns:
True if server busy, false otherwise

getCustomer

public Customer getCustomer()
Obtain reference to Customer currently using this server.

Returns:
Customer object current assigned to this server. Null if server is not busy.

getName

public java.lang.String getName()
Obtain name given to this server when it was constructed.

Returns:
String containing server's name.

getUtilizationStat

public Statistic getUtilizationStat()
Obtain reference to server utilization statistic. Server utilization is in range 0-1 (0-100% busy).

Returns:
Statistic object for utilization.

getServiceTimeStat

public Statistic getServiceTimeStat()
Obtain reference to server's service time statistic. This tracks time that customers spend in service.

Returns:
Statistic object for service time.

request

public boolean request(Customer c)
Customer requests to use the server. If the server is already busy, the customer will be rejected. Otherwise the server will become busy with the customer.

Parameters:
c - Customer requesting the server.
Returns:
True if request is granted (server was idle), false otherwise (server was already busy).

release

public Customer release()
Server is ordered to release its current customer. If it was not busy, returns null. Otherwise, it releases the customer and goes idle.

Returns:
Customer the Server is currently busy with, or null if not busy.