jsim.process
Class Server

java.lang.Object
  extended by jsim.process.DynamicNode
      extended by jsim.process.Server
Direct Known Subclasses:
Facility

public class Server
extends DynamicNode

The Server class allows groups of servers to be created. A Server object consists of one or more tokens (service units). To obtain service, an entity (client) must acquire a token.


Nested Class Summary
protected  class Server.TokenVec
          Inner class for token vector.
 
Field Summary
protected  Server.TokenVec tokenV
          Token vector.
 
Fields inherited from class jsim.process.DynamicNode
costs, duration, occupancy, outgoing, props, trc
 
Constructor Summary
Server(int id, Prop props, Transport[] outgoing, AnimationQueue sharedQueue)
          Version of the Constructor for use with animator Construct a Server.
Server(Prop props, Transport[] outgoing)
          Construct a Server.
 
Method Summary
 void contract()
          Remove a service unit (token) from the server.
 void expand()
          Add a service unit (token) to the server.
 int getId()
          Returns the id of the Server
 SimObject preempt(Token pToken, SimObject pEntity)
          Preempt the service of the entity being served by token.
 void request(SimObject entity)
          Request a token (service unit).
 void setId(int id)
          Sets the id of the Server
 void use(SimObject entity)
          An entity calls the use method to obtain service.
 void use(SimObject entity, double service, double cost)
          An entity calls the use method to obtain service.
 
Methods inherited from class jsim.process.DynamicNode
getNodeStats, getOutgoing, getProps, setBatchProperties, setPrimary, setProps
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

tokenV

protected final Server.TokenVec tokenV
Token vector.

Constructor Detail

Server

public Server(Prop props,
              Transport[] outgoing)
Construct a Server. This constructor has sufficient information to draw the node and its outgoing edges.

Parameters:
property - properties of node
location - position of node
nodeGroup - containing model
outgoing - outgoing transports

Server

public Server(int id,
              Prop props,
              Transport[] outgoing,
              AnimationQueue sharedQueue)
Version of the Constructor for use with animator Construct a Server. This constructor has sufficient information to draw the node and its outgoing edges.

Parameters:
id - id of the server
property - properties of node
location - position of node
nodeGroup - containing model
outgoing - outgoing transports
sharedQueue - animation queue
Method Detail

getId

public int getId()
Returns the id of the Server

Returns:
id id of this server

setId

public void setId(int id)
Sets the id of the Server

Parameters:
id - id for this server

request

public void request(SimObject entity)
Request a token (service unit). If no token is available the entity is lost (and its thread is terminated).

Parameters:
entity - the SimObject (entity) requesting service

use

public void use(SimObject entity,
                double service,
                double cost)
An entity calls the use method to obtain service. Must call request first.

Parameters:
entity - entity obtaining service
service - service time

use

public void use(SimObject entity)
An entity calls the use method to obtain service. The service time is randomly generated. Must call request first.

Parameters:
entity - entity obtaining service

preempt

public SimObject preempt(Token pToken,
                         SimObject pEntity)
Preempt the service of the entity being served by token.

Parameters:
tokenNum - preempt the service of this token
Returns:
SimObject the preempted entity

expand

public void expand()
Add a service unit (token) to the server.


contract

public void contract()
Remove a service unit (token) from the server. Handle a possible preempted entity (a SimObject).