public class ShortestQueueDispatcher extends SimEntityBase
This class is a simple illustration of a dispatcher class. It keeps an array of Servers and listens for an Arrival event. Upon the Arrival event, the index of the server with the fewest customers is determined and the Arrival event is scheduled for that server. The technique is to directly invoke waitDelay() on the server instance, thereby making it appear as if the server itself had scheduled the event.
The class also illustrates the PropertyChangeNamespace class. This class listens for PropertyChangeEvents, prepends a namespace to the property name, and re-fires the event.
Modifier and Type | Field and Description |
---|---|
private PropertyChangeNamespace[] |
nameSpace |
private SimpleServer[] |
server
The Servers that this dispatcher can direct arrivals to.
|
eventList, property
DEFAULT_ENTITY_NAME, DEFAULT_EVENT_NAME, DEFAULT_PRIORITY, EVENT_METHOD_PREFIX, NL
Constructor and Description |
---|
ShortestQueueDispatcher() |
ShortestQueueDispatcher(SimpleServer[] servers)
Creates a new dispatcher that will direct arrivals to the given Servers.
|
Modifier and Type | Method and Description |
---|---|
void |
doArrival()
Schedules Arrival on server with the shortest queue.
|
protected int |
getShortestQueue()
Return the index of the SimpleServer with the shortest queue.
|
void |
setServers(SimpleServer[] serv)
Sets the Servers available to this dispatcher.
|
coldReset, dumpDoMethods, dumpDoMethodsStr, dumpNamesAndSignatures, dumpNamesAndSignaturesStr, getFullMethodName, getSignatureString, handleSimEvent, isAssignableFrom, isDebug, processSimEvent, setDebug, stopAtTime, stopOnTime
addPropertyChangeListener, addPropertyChangeListener, attemptSchedule, clearAddedProperty, compareTo, fireIndexedPropertyChange, fireIndexedPropertyChange, firePropertyChange, firePropertyChange, firePropertyChange, getAddedProperties, getEventList, getEventListID, getName, getPriority, getPropertiesString, getProperty, getProperty, getPropertyChangeListeners, getSerial, interrupt, interrupt, interruptAll, interruptAll, interruptAll, interruptAllWithArgs, interruptAllWithArgs, isClearAddedPropertiesOnReset, isJustDefinedProperties, isPersistant, isReRunnable, isVerbose, parametersMatch, removePropertyChangeListener, removePropertyChangeListener, reset, resetNextSerial, setClearAddedPropertiesOnReset, setEventList, setEventListID, setJustDefinedProperties, setName, setPersistant, setPriority, setProperty, setVerbose, toString, waitDelay, waitDelay, waitDelay, waitDelay
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
addSimEventListener, getSimEventListeners, notifyListeners, removeSimEventListener
private SimpleServer[] server
private PropertyChangeNamespace[] nameSpace
public ShortestQueueDispatcher()
public ShortestQueueDispatcher(SimpleServer[] servers)
PropertyChangeNamespace
that listens for its
PropertyChangeEvents, prepends the property name with the servers number
and then re-fires the event. The dispatcher has a PropertyChangeNamespace
that listens to all of the SimpleServer's PropertyChangeNamespaces and
re-fires the events. Therefore, any PropertyChangeListener need only
listen to this dispatcher's events to be informed of all property changes
on Servers in the system.servers
- Given array of SimpleServerspublic void doArrival()
public void setServers(SimpleServer[] serv)
PropertyChangeNamespace
that listens for its
PropertyChangeEvents, prepends the property name with the server number
and then re-fires the event. The dispatcher has a PropertyChangeNamespace
that listens to all of the SimpleServer's PropertyChangeNamespaces and
re-fires the events. Therefore, any PropertyChangeListener need only
listen to this dispatcher's events to be informed of all property changes
on Servers in the system.serv
- Array of servers to be used.protected int getShortestQueue()