Class ServerType

java.lang.Object
jline.lang.Element
jline.lang.constant.ServerType
All Implemented Interfaces:
Serializable, Copyable

public class ServerType extends Element implements Serializable
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:
  • Constructor Details

    • ServerType

      public ServerType(String name, int numOfServers)
      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

      public ServerType(String name, int numOfServers, List<JobClass> compatibleClasses)
      Creates a new server type with the specified name, number of servers, and compatible classes.
      Parameters:
      name - the name identifying this server type
      numOfServers - 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

      public List<JobClass> getCompatibleClasses()
      Gets the list of job classes compatible with this server type.
      Returns:
      a new list containing the compatible job classes
    • addCompatibleClass

      public void addCompatibleClass(JobClass jobClass)
      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

      public boolean removeCompatibleClass(JobClass jobClass)
      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

      public void setCompatibleClasses(List<JobClass> classes)
      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

      public boolean isCompatible(JobClass jobClass)
      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

      public Queue getParentQueue()
      Gets the parent queue this server type belongs to.
      Returns:
      the parent queue, or null if not yet added to a queue
    • setParentQueue

      public void setParentQueue(Queue queue)
      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

      public String toString()
      Overrides:
      toString in class Object