Package jline.lang.constant
Class ServerType
java.lang.Object
jline.lang.Element
jline.lang.constant.ServerType
- All Implemented Interfaces:
Serializable,Copyable
Represents a type of server within a heterogeneous multiserver queue.
A server type defines a group of identical servers with:
- A unique name identifying this server type
- A count of servers of this type
- A list of job classes that are compatible with (can be served by) this type
Server types enable modeling of heterogeneous multiserver queues where different servers may have different service rates and serve different subsets of job classes.
Example usage:
ServerType fastServer = new ServerType("Fast", 2);
fastServer.addCompatibleClass(classA);
fastServer.addCompatibleClass(classB);
queue.addServerType(fastServer);
queue.setService(classA, fastServer, new Exp(2.0));
- See Also:
-
Field Summary
-
Constructor Summary
ConstructorsConstructorDescriptionServerType(String name, int numOfServers) Creates a new server type with the specified name and number of servers.ServerType(String name, int numOfServers, List<JobClass> compatibleClasses) Creates a new server type with the specified name, number of servers, and compatible classes. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddCompatibleClass(JobClass jobClass) Adds a job class to the list of classes that can be served by this server type.Gets the list of job classes compatible with this server type.intgetId()Gets the unique identifier of this server type within its queue.intGets the number of compatible job classes.intGets the number of servers of this type.Gets the parent queue this server type belongs to.booleanChecks if this server type has any compatible classes defined.booleanisCompatible(JobClass jobClass) Checks if a job class is compatible with this server type.booleanremoveCompatibleClass(JobClass jobClass) Removes a job class from the list of compatible classes.voidsetCompatibleClasses(List<JobClass> classes) Sets the list of compatible job classes, replacing any existing list.voidsetId(int id) Sets the unique identifier of this server type.voidsetNumOfServers(int numOfServers) Sets the number of servers of this type.voidsetParentQueue(Queue queue) Sets the parent queue for this server type.toString()
-
Constructor Details
-
ServerType
Creates a new server type with the specified name and number of servers. By default, no job classes are compatible until explicitly added.- Parameters:
name- the name identifying this server type (e.g., "Fast", "Slow")numOfServers- the number of servers of this type (must be >= 1)- Throws:
IllegalArgumentException- if numOfServers is less than 1
-
ServerType
Creates a new server type with the specified name, number of servers, and compatible classes.- Parameters:
name- the name identifying this server typenumOfServers- the number of servers of this type (must be >= 1)compatibleClasses- initial list of compatible job classes- Throws:
IllegalArgumentException- if numOfServers is less than 1
-
-
Method Details
-
getId
public int getId()Gets the unique identifier of this server type within its queue.- Returns:
- the server type ID, or -1 if not yet added to a queue
-
setId
public void setId(int id) Sets the unique identifier of this server type. This is typically called by the Queue when the server type is added.- Parameters:
id- the ID to assign
-
getNumOfServers
public int getNumOfServers()Gets the number of servers of this type.- Returns:
- the number of servers
-
setNumOfServers
public void setNumOfServers(int numOfServers) Sets the number of servers of this type.- Parameters:
numOfServers- the number of servers (must be >= 1)- Throws:
IllegalArgumentException- if numOfServers is less than 1
-
getCompatibleClasses
Gets the list of job classes compatible with this server type.- Returns:
- a new list containing the compatible job classes
-
addCompatibleClass
Adds a job class to the list of classes that can be served by this server type.- Parameters:
jobClass- the job class to add as compatible- Throws:
IllegalArgumentException- if jobClass is null
-
removeCompatibleClass
Removes a job class from the list of compatible classes.- Parameters:
jobClass- the job class to remove- Returns:
- true if the class was removed, false if it was not in the list
-
setCompatibleClasses
Sets the list of compatible job classes, replacing any existing list.- Parameters:
classes- the list of job classes to set as compatible- Throws:
IllegalArgumentException- if classes is null
-
isCompatible
Checks if a job class is compatible with this server type.- Parameters:
jobClass- the job class to check- Returns:
- true if the class can be served by this server type
-
getNumCompatibleClasses
public int getNumCompatibleClasses()Gets the number of compatible job classes.- Returns:
- the count of compatible classes
-
hasCompatibleClasses
public boolean hasCompatibleClasses()Checks if this server type has any compatible classes defined.- Returns:
- true if at least one compatible class is defined
-
getParentQueue
Gets the parent queue this server type belongs to.- Returns:
- the parent queue, or null if not yet added to a queue
-
setParentQueue
Sets the parent queue for this server type. This is typically called by the Queue when the server type is added.- Parameters:
queue- the parent queue
-
toString
-