public class CUPS<J extends SimJob,Q extends CUPS> extends AbstractProcessorSharingSimQueue<J,Q>
CUPS queue serves all jobs with the least obtained service time simultaneously,
equally distributing its service capacity among them.Copyright (C) 2005-2017 Jan de Jongh, TNO
This file is covered by the LICENSE file in the root of this project.
| Modifier and Type | Class and Description |
|---|---|
protected static class |
CUPS.CatchUpEvent
A schedule-able
SimEvent for catch-ups of which a single instance is used throughout in this class. |
AbstractSimEntity.Notifier, AbstractSimEntity.PreNotificationHookSimQueue.AutoRevocationPolicySimEntity.Action, SimEntity.UnknownNotificationTypePolicy, SimEntity.UnknownOperationPolicy| Modifier and Type | Field and Description |
|---|---|
protected CUPS.CatchUpEvent |
catchUpEvent
The single catch-up event.
|
static double |
TOLERANCE_OST
The tolerance for rounding errors in the obtained service time.
|
eventsScheduled, SANITYUSE_ARRAY_OPTIMIZATION| Constructor and Description |
|---|
CUPS(org.javades.jsimulation.r5.SimEventList eventList)
Creates a single-server CUPS queue with infinite buffer size given an event list.
|
| Modifier and Type | Method and Description |
|---|---|
protected void |
cancelCatchUpEvent()
Cancels a pending catch-up event (if scheduled).
|
protected void |
catchUp(double time)
Calls
AbstractSimEntity.update(double)
followed by rescheduleDepartureEvent() and rescheduleCatchUpEvent(). |
CUPS<J,Q> |
getCopySimQueue()
Returns a new
CUPS object on the same SimEventList. |
protected Set<J> |
getJobsExecuting()
Gets the jobs currently in execution.
|
protected double |
getMinimumObtainedServiceTime()
Returns the minimum obtained service time (i.e., of all the jobs currently in execution).
|
protected int |
getNumberOfJobsExecuting()
Gets the number of jobs in execution.
|
Object |
getQoS()
Calls super method (in order to make implementation final).
|
Class |
getQoSClass()
Calls super method (in order to make implementation final).
|
protected double |
getServiceTimeForJob(J job)
Calls super method (in order to make implementation final).
|
protected double |
getTimeToCatchUp()
Calculates the time until the next catch-up.
|
protected void |
insertJobInQueueUponArrival(J job,
double time)
Does nothing, and makes that final.
|
protected void |
insertJobInQueueUponStart(J job,
double time)
Performs sanity checks and administers the job's initial obtained service time.
|
boolean |
isStartArmed()
Returns
true. |
protected void |
removeJobFromInternalAdministration(J job)
Removes the given job, if present, from the internal administration.
|
protected void |
removeJobFromQueueUponDeparture(J departingJob,
double time)
Calls
removeJobFromQueueUponRevokation(J, double, boolean) for the departed job. |
protected void |
removeJobFromQueueUponDrop(J job,
double time)
Throws
IllegalStateException. |
protected void |
removeJobFromQueueUponRevokation(J job,
double time,
boolean auto)
Removes the jobs from the internal data structures.
|
protected void |
rescheduleAfterArrival(J job,
double time)
Starts the arrived job if server-access credits are available.
|
protected void |
rescheduleAfterDeparture(J departedJob,
double time)
|
protected void |
rescheduleAfterDrop(J job,
double time)
Throws
IllegalStateException. |
protected void |
rescheduleAfterRevokation(J job,
double time,
boolean auto)
|
protected void |
rescheduleAfterStart(J job,
double time)
Reschedules due to the start of a job,
making it depart immediately if its requested service time is zero
(or finite and time itself is infinite),
or rescheduling through
rescheduleDepartureEvent() and rescheduleCatchUpEvent() otherwise. |
protected void |
rescheduleCatchUpEvent()
Reschedules a catch-up event.
|
protected void |
rescheduleDepartureEvent()
Reschedules the single departure event for this queue.
|
protected void |
rescheduleForNewServerAccessCredits(double time)
Starts jobs as long as there are server-access credits and jobs waiting.
|
protected void |
resetEntitySubClass()
Calls super method and clears the internal administration.
|
protected void |
sanityInternalAdministration()
Performs sanity checks on the internal administration.
|
protected void |
setServerAccessCreditsSubClass()
Calls super method (in order to make implementation final).
|
String |
toStringDefault()
Returns "CUPS".
|
protected void |
updateObtainedServiceTime(double newTime)
Updates the internal administration (i.c., obtained service times) for executing jobs in the service area.
|
queueAccessVacationDropSubClassgetBufferSize, getNumberOfServersarrive, autoRevoke, cancelDepartureEvent, cancelDepartureEvent, depart, departureFromEventList, drop, getAutoRevocationPolicy, getDepartureEvents, getDepartureEvents, getFirstJob, getFirstJobInServiceArea, getFirstJobInWaitingArea, getJobs, getJobsInServiceArea, getJobsInWaitingArea, getNumberOfJobs, getNumberOfJobsInServiceArea, getNumberOfJobsInWaitingArea, getServerAccessCredits, hasJobs, hasJobsInServiceArea, hasJobsInWaitingArea, hasServerAcccessCredits, isJob, isJobInServiceArea, isJobInWaitingArea, isQueueAccessVacation, registerStdOutSimQueueListener, revoke, revoke, scheduleDepartureEvent, scheduleJobArrival, setAutoRevocationPolicy, setQueueAccessVacation, setServerAccessCredits, start, takeServerAccessCredit, triggerPotentialNewStartArmed, unregisterStdOutSimQueueListeneraddPendingNotification, addPendingNotification, clearAndUnlockPendingNotificationsIfLocked, delegateOperation, doAfterNotifications, doOperation, fireAndLockPendingNotifications, getEventList, getLastUpdateTime, getRegisteredDelegatedOperations, getRegisteredNotificationTypes, getRegisteredOperations, getSimEntityListeners, getUnknownNotificationTypePolicy, getUnknownOperationPolicy, isIgnoreEventListReset, notifyEventListReset, registerDelegatedOperation, registerNotificationType, registerOperation, registerPreEventHook, registerPreNotificationHook, registerPreUpdateHook, registerSimEntityListener, registerStdOutSimEntityListener, removeDelegationForOperation, resetEntity, setIgnoreEventListReset, setName, setUnknownNotificationTypePolicy, setUnknownOperationPolicy, toString, unregisterSimEntityListener, unregisterStdOutSimEntityListener, updateclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitarrive, getAutoRevocationPolicy, getJobs, getJobsInServiceArea, getJobsInWaitingArea, getNumberOfJobs, getNumberOfJobsInServiceArea, getNumberOfJobsInWaitingArea, getServerAccessCredits, isJob, isJobInServiceArea, isJobInWaitingArea, isQueueAccessVacation, revoke, revoke, setAutoRevocationPolicy, setQueueAccessVacation, setServerAccessCreditsdoAfterNotifications, doOperation, getEventList, getLastUpdateTime, getRegisteredNotificationTypes, getRegisteredOperations, getSimEntityListeners, getUnknownNotificationTypePolicy, getUnknownOperationPolicy, isIgnoreEventListReset, registerSimEntityListener, resetEntity, setIgnoreEventListReset, setName, setUnknownNotificationTypePolicy, setUnknownOperationPolicy, unregisterSimEntityListener, updatepublic static final double TOLERANCE_OST
protected final CUPS.CatchUpEvent catchUpEvent
catchUp(double) on the enclosing instance.CUPS.CatchUpEvent,
catchUp(double)public CUPS(org.javades.jsimulation.r5.SimEventList eventList)
The constructor registers a pre-update hook that sets the virtual time upon updates.
eventList - The event list to use.AbstractSimEntity.registerPreUpdateHook(java.util.function.DoubleConsumer),
updateObtainedServiceTime(double)public CUPS<J,Q> getCopySimQueue()
CUPS object on the same SimEventList.CUPS object on the same SimEventList.AbstractSimEntity.getEventList()public String toStringDefault()
toStringDefault in interface SimEntitytoStringDefault in class AbstractSimQueue<J extends SimJob,Q extends CUPS>SimEntity.setName(java.lang.String),
Object.toString()public final Class getQoSClass()
null.public final Object getQoS()
null.protected final Set<J> getJobsExecuting()
null).protected final int getNumberOfJobsExecuting()
protected final double getMinimumObtainedServiceTime()
IllegalStateException - If there are currently no jobs in execution (i.e., no jobs in the service area).AbstractSimQueue.hasJobsInServiceArea()protected final void removeJobFromInternalAdministration(J job)
Does not remove the job from super-class structures.
job - The job to remove, non-null.IllegalArgumentException - If the job is null.protected final double getTimeToCatchUp()
IllegalStateException - If the current state of the queue does not allow a catch-up.protected final void sanityInternalAdministration()
Used for debugging. The checks, however, are quite expensive.
This method has no effect if all sanity checks pass.
Unless commented out due to code maturity and/or performance considerations,
invocations are logged at level Level.FINER.
IllegalStateException - If the internal administration is inconsistent.protected final void resetEntitySubClass()
resetEntitySubClass in class AbstractSimQueue<J extends SimJob,Q extends CUPS>SimEntity.resetEntity()protected final void updateObtainedServiceTime(double newTime)
This method is called as an pre-update hook, and not meant to be called from user code (in sub-classes).
It is left protected for javadoc.
This method automatically performs "catch-ups".
newTime - The new time.AbstractSimQueue.hasJobsInServiceArea(),
getJobsExecuting(),
AbstractSimEntity.getLastUpdateTime(),
AbstractSimEntity.registerPreUpdateHook(java.util.function.DoubleConsumer)protected final void insertJobInQueueUponArrival(J job, double time)
insertJobInQueueUponArrival in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The job that arrived.time - The current time (i.e., arrival time of the job).AbstractSimQueue.arrive(double, J)protected final void rescheduleAfterArrival(J job, double time)
rescheduleAfterArrival in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The job that arrived (and is already present in AbstractSimQueue.getJobs()).time - The current time (i.e., the arrival time of the job).AbstractSimQueue.hasServerAcccessCredits(),
AbstractSimQueue.start(double, J)protected final void removeJobFromQueueUponDrop(J job, double time)
IllegalStateException.removeJobFromQueueUponDrop in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The job that is to be dropped.time - The current time (i.e., drop time of the job).IllegalStateException - Always, as this SimQueue does not drop jobs.AbstractSimQueue.drop(J, double)protected final void rescheduleAfterDrop(J job, double time)
IllegalStateException.rescheduleAfterDrop in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The jobs that was dropped.time - The current time (i.e., drop time of the job).IllegalStateException - Always, as this SimQueue does not drop jobs.AbstractSimQueue.drop(J, double)protected final void removeJobFromQueueUponRevokation(J job, double time, boolean auto)
removeJobFromQueueUponRevokation in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The job that is to be revoked.time - The current time (i.e., revocation time of the job).auto - Whether or not this applies to an auto-revocation.AbstractSimQueue.revoke(double, J, boolean),
removeJobFromInternalAdministration(J)protected final void rescheduleAfterRevokation(J job, double time, boolean auto)
rescheduleAfterRevokation in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The jobs that was successfully revoked.time - The current time (i.e., revocation time of the job).auto - Whether or not this applies to an auto-revocation.AbstractSimQueue.revoke(double, J, boolean),
rescheduleDepartureEvent(),
rescheduleCatchUpEvent()protected final void setServerAccessCreditsSubClass()
setServerAccessCreditsSubClass in class AbstractSimQueue<J extends SimJob,Q extends CUPS>AbstractSimQueue.getServerAccessCredits(),
AbstractSimQueue.setServerAccessCredits(double, int),
AbstractSimQueue.rescheduleForNewServerAccessCredits(double)protected final void rescheduleForNewServerAccessCredits(double time)
rescheduleForNewServerAccessCredits in class AbstractSimQueue<J extends SimJob,Q extends CUPS>time - The current time (i.e., the time at which new server-access credits became available).AbstractSimQueue.hasServerAcccessCredits(),
AbstractSimQueue.hasJobsInWaitingArea(),
AbstractSimQueue.start(double, J),
AbstractSimQueue.getFirstJobInWaitingArea()public final boolean isStartArmed()
true.SimQueueListener.notifyNewStartArmed(double, Q, boolean)protected final void insertJobInQueueUponStart(J job, double time)
insertJobInQueueUponStart in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The job that starts.time - The current time (i.e., start time of the job).getServiceTimeForJob(J),
obtainedServiceTimeMapprotected final void rescheduleAfterStart(J job, double time)
rescheduleDepartureEvent() and rescheduleCatchUpEvent() otherwise.rescheduleAfterStart in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The job that started (and is already present in AbstractSimQueue.getJobsInServiceArea().time - The current time (i.e., the start time of the job).getServiceTimeForJob(J),
rescheduleDepartureEvent(),
rescheduleCatchUpEvent(),
AbstractSimQueue.depart(double, J)protected final double getServiceTimeForJob(J job)
getServiceTimeForJob in class AbstractSimQueue<J extends SimJob,Q extends CUPS>job - The job, non-null.protected final void catchUp(double time)
AbstractSimEntity.update(double)
followed by rescheduleDepartureEvent() and rescheduleCatchUpEvent().
Always invoked from (only) CUPS.CatchUpEvent.
Note that the actual catch-up is performed in updateObtainedServiceTime(double) through the pre-update hook.
This method does however check that there are actually two groups of jobs in the service area with different obtained service
times.
Otherwise, we are illegally scheduled unless a recent update took place without rescheduling (e.g., a Queue Access Vacation).
It also checks that after the AbstractSimEntity.update(double), the number of such groups has decreased by exactly one,
again considering that we may have missed the catch-up due to a recent AbstractSimEntity.update(double).
For internal use but made protected for documentation purposes.
time - The time of the catch-up event (current time).IllegalStateException - If this method is invoked at an inappropriate moment,
or the pre-update hook fails to perform the expected catch-up
(in both cases, taking into consideration the possibility of missed updates).CUPS.CatchUpEvent,
rescheduleDepartureEvent(),
rescheduleCatchUpEvent()protected final void removeJobFromQueueUponDeparture(J departingJob, double time)
removeJobFromQueueUponRevokation(J, double, boolean) for the departed job.removeJobFromQueueUponDeparture in class AbstractSimQueue<J extends SimJob,Q extends CUPS>departingJob - The job that departs.time - The departure (current) time.removeJobFromQueueUponRevokation(J, double, boolean)protected final void rescheduleAfterDeparture(J departedJob, double time)
rescheduleAfterDeparture in class AbstractSimQueue<J extends SimJob,Q extends CUPS>departedJob - The departed job.time - The departure (current) time.AbstractSimQueue.depart(double, J),
rescheduleDepartureEvent(),
rescheduleCatchUpEvent()protected final void rescheduleDepartureEvent()
Refuses to schedule departure events at positive or negative infinity.
protected final void cancelCatchUpEvent()
The implementation simply removes the single catch-up event from the event list and from AbstractSimQueue.eventsScheduled.
protected final void rescheduleCatchUpEvent()
Refuses to schedule catch-up events at positive or negative infinity.
Copyright © 2018. All rights reserved.