public abstract class AbstractPreemptiveSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue> extends AbstractClassicSimQueue<J,Q>
Implementations allow (through inheritance) the job requested service time to be (positive) infinite. Jobs with that feature will never depart through internal scheduling (can only depart due to preemption and the proper preemption strategy), even if time itself is positive or negative infinity. If time is infinite, jobs with finite service time requirement will always start and depart immediately upon arrival.
Copyright (C) 2005-2017 Jan de Jongh, TNO
This file is covered by the LICENSE file in the root of this project.
AbstractSimEntity.Notifier, AbstractSimEntity.PreNotificationHookSimQueue.AutoRevocationPolicySimEntity.Action, SimEntity.UnknownNotificationTypePolicy, SimEntity.UnknownOperationPolicy| Modifier and Type | Field and Description |
|---|---|
static PreemptionStrategy |
DEFAULT_PREEMPTION_STRATEGY
The default preemption strategy, if none was specified upon construction.
|
protected Map<J,Double> |
jobsBeingServed
The jobs currently being served by a server, mapped onto the start time of this service chunk.
|
protected HashMapWithPreImageAndOrderedValueSet<J,Double> |
remainingServiceTime
The mapping from jobs in
AbstractSimQueue.getJobsInServiceArea() to their respective remaining service times. |
static double |
TOLERANCE_RST
The tolerance for rounding errors in the remaining service time.
|
eventsScheduled, SANITYUSE_ARRAY_OPTIMIZATION| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPreemptiveSimQueue(org.javades.jsimulation.r5.SimEventList eventList,
int bufferSize,
int numberOfServers,
PreemptionStrategy preemptionStrategy)
Creates a preemptive queue given an event list, buffer size, number of servers and preemption strategy.
|
| Modifier and Type | Method and Description |
|---|---|
Set<J> |
getJobsBeingServed()
Gets the set of jobs currently being served by a server.
|
PreemptionStrategy |
getPreemptionStrategy()
Gets the preemption strategy.
|
protected void |
preemptJob(double time,
J job)
Preempts a job in
jobsBeingServed, taking actions depending on the preemption
strategy of this queue. |
protected void |
queueAccessVacationDropSubClass(double time,
J job)
Calls super method (in order to make implementation final).
|
protected void |
removeJobFromQueueUponDeparture(J departingJob,
double time)
Invokes
removeJobFromQueueUponExit(J, double) (final implementation). |
protected void |
removeJobFromQueueUponDrop(J job,
double time)
Invokes
removeJobFromQueueUponExit(J, double) (final implementation). |
protected abstract void |
removeJobFromQueueUponExit(J exitingJob,
double time)
Removes a job from the internal administration upon its exit from this queue (to be implemented by concrete subclasses).
|
protected void |
removeJobFromQueueUponRevokation(J job,
double time,
boolean auto)
Invokes
removeJobFromQueueUponExit(J, double) (final implementation). |
protected void |
rescheduleAfterDeparture(J departedJob,
double time)
Invokes
rescheduleAfterExit(double) (final implementation). |
protected void |
rescheduleAfterDrop(J job,
double time)
Invokes
rescheduleAfterExit(double) (final implementation). |
protected abstract void |
rescheduleAfterExit(double time)
Reschedules after a job has left this queue (to be implemented by concrete subclasses).
|
protected void |
rescheduleAfterRevokation(J job,
double time,
boolean auto)
Invokes
rescheduleAfterExit(double) (final implementation). |
protected void |
resetEntitySubClass()
Calls super method and removes all jobs from internal data structures.
|
protected void |
startServiceChunk(double time,
J job)
Starts execution of a job in
AbstractSimQueue.getJobsInServiceArea(), until it departs (if at all) or until it is preempted. |
protected void |
updateRemainingServiceTime(double newTime)
Updates the remaining service time of executing jobs in the service area.
|
getBufferSize, getNumberOfServersarrive, autoRevoke, cancelDepartureEvent, cancelDepartureEvent, depart, departureFromEventList, drop, getAutoRevocationPolicy, getDepartureEvents, getDepartureEvents, getFirstJob, getFirstJobInServiceArea, getFirstJobInWaitingArea, getJobs, getJobsInServiceArea, getJobsInWaitingArea, getNumberOfJobs, getNumberOfJobsInServiceArea, getNumberOfJobsInWaitingArea, getServerAccessCredits, getServiceTimeForJob, hasJobs, hasJobsInServiceArea, hasJobsInWaitingArea, hasServerAcccessCredits, insertJobInQueueUponArrival, insertJobInQueueUponStart, isJob, isJobInServiceArea, isJobInWaitingArea, isQueueAccessVacation, registerStdOutSimQueueListener, rescheduleAfterArrival, rescheduleAfterStart, rescheduleForNewServerAccessCredits, revoke, revoke, scheduleDepartureEvent, scheduleJobArrival, setAutoRevocationPolicy, setQueueAccessVacation, setServerAccessCredits, setServerAccessCreditsSubClass, start, takeServerAccessCredit, toStringDefault, 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, getCopySimQueue, getJobs, getJobsInServiceArea, getJobsInWaitingArea, getNumberOfJobs, getNumberOfJobsInServiceArea, getNumberOfJobsInWaitingArea, getServerAccessCredits, isJob, isJobInServiceArea, isJobInWaitingArea, isQueueAccessVacation, isStartArmed, revoke, revoke, setAutoRevocationPolicy, setQueueAccessVacation, setServerAccessCreditsdoAfterNotifications, doOperation, getEventList, getLastUpdateTime, getRegisteredNotificationTypes, getRegisteredOperations, getSimEntityListeners, getUnknownNotificationTypePolicy, getUnknownOperationPolicy, isIgnoreEventListReset, registerSimEntityListener, resetEntity, setIgnoreEventListReset, setName, setUnknownNotificationTypePolicy, setUnknownOperationPolicy, toStringDefault, unregisterSimEntityListener, updatenotifyEventListResetgetQoS, getQoSClasspublic static final PreemptionStrategy DEFAULT_PREEMPTION_STRATEGY
PreemptionStrategy.RESUME).public static final double TOLERANCE_RST
protected final HashMapWithPreImageAndOrderedValueSet<J extends SimJob,Double> remainingServiceTime
AbstractSimQueue.getJobsInServiceArea() to their respective remaining service times.
The key-set of this map must always be identical to AbstractSimQueue.getJobsInServiceArea().
The special extensions to TreeMap allow for efficient determination of the pre-images of
remaining service times.
protected AbstractPreemptiveSimQueue(org.javades.jsimulation.r5.SimEventList eventList,
int bufferSize,
int numberOfServers,
PreemptionStrategy preemptionStrategy)
The constructor registers a pre-update hook that updates the remaining service time.
eventList - The event list to use.bufferSize - The buffer size (non-negative), Integer.MAX_VALUE is interpreted as infinity.numberOfServers - The number of servers (non-negative), Integer.MAX_VALUE is interpreted as infinity.preemptionStrategy - The preemption strategy, if null, the default is used (preemptive-resume).IllegalArgumentException - If the event list is null.updateRemainingServiceTime(double)public final PreemptionStrategy getPreemptionStrategy()
The preemption strategy is non-null and fixed upon construction; if cannot be modified.
protected final void updateRemainingServiceTime(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.
newTime - The new time.jobsBeingServed,
remainingServiceTime,
TOLERANCE_RST,
AbstractSimEntity.registerPreUpdateHook(java.util.function.DoubleConsumer)public final Set<J> getJobsBeingServed()
The assumption in this class is that a server can serve at most one job, and that the full unit-capacity of a server is used to serve the job in service (if any).
protected void resetEntitySubClass()
resetEntitySubClass in class AbstractSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue>remainingServiceTime,
jobsBeingServedprotected final void queueAccessVacationDropSubClass(double time,
J job)
queueAccessVacationDropSubClass in class AbstractSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue>time - The time the job was dropped, i.e., the current time.job - The dropped job.AbstractSimQueue.arrive(double, J),
AbstractSimQueue.setQueueAccessVacation(double, boolean)protected final void preemptJob(double time,
J job)
jobsBeingServed, taking actions depending on the preemption
strategy of this queue.time - The (current) time.job - The job to preempt.IllegalArgumentException - If the job is null or not in jobsBeingServed.UnsupportedOperationException - If the preemption strategy is PreemptionStrategy.REDRAW
of PreemptionStrategy.CUSTOM.jobsBeingServed,
remainingServiceTime,
getPreemptionStrategy(),
AbstractSimQueue.drop(J, double),
AbstractSimQueue.cancelDepartureEvent(org.javades.jqueues.r5.entity.jq.SimJQEvent.Departure<J, Q>),
AbstractSimQueue.getServiceTimeForJob(J),
AbstractSimQueue.depart(double, J)protected final void startServiceChunk(double time,
J job)
AbstractSimQueue.getJobsInServiceArea(), until it departs (if at all) or until it is preempted.
The job to execute departs immediately if its remaining service time is zero; or is finite and time itself is at positive or negative infinity. No departure event is scheduled if the job has infinite required service time.
time - The (current) time.job - The job to start executing.IllegalArgumentException - If the job is null, not in the service area, or already being executed.jobsBeingServed,
remainingServiceTime,
TOLERANCE_RST,
AbstractSimQueue.scheduleDepartureEvent(double, J),
AbstractSimQueue.depart(double, J)protected final void removeJobFromQueueUponDrop(J job, double time)
removeJobFromQueueUponExit(J, double) (final implementation).removeJobFromQueueUponDrop in class AbstractSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue>job - The job that is to be dropped.time - The current time (i.e., drop time of the job).AbstractSimQueue.drop(J, double),
AbstractSimQueue.rescheduleAfterDrop(J, double)protected final void rescheduleAfterDrop(J job, double time)
rescheduleAfterExit(double) (final implementation).rescheduleAfterDrop in class AbstractSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue>job - The jobs that was dropped.time - The current time (i.e., drop time of the job).AbstractSimQueue.drop(J, double),
AbstractSimQueue.removeJobFromQueueUponDrop(J, double)protected final void removeJobFromQueueUponRevokation(J job, double time, boolean auto)
removeJobFromQueueUponExit(J, double) (final implementation).removeJobFromQueueUponRevokation in class AbstractSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue>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),
AbstractSimQueue.autoRevoke(double, J),
AbstractSimQueue.rescheduleAfterRevokation(J, double, boolean),
SimQueue.AutoRevocationPolicyprotected final void rescheduleAfterRevokation(J job, double time, boolean auto)
rescheduleAfterExit(double) (final implementation).rescheduleAfterRevokation in class AbstractSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue>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),
AbstractSimQueue.autoRevoke(double, J),
AbstractSimQueue.removeJobFromQueueUponRevokation(J, double, boolean),
SimQueue.AutoRevocationPolicyprotected final void removeJobFromQueueUponDeparture(J departingJob, double time)
removeJobFromQueueUponExit(J, double) (final implementation).removeJobFromQueueUponDeparture in class AbstractSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue>departingJob - The job that departs.time - The departure (current) time.AbstractSimQueue.depart(double, J),
AbstractSimQueue.rescheduleAfterDeparture(J, double)protected final void rescheduleAfterDeparture(J departedJob, double time)
rescheduleAfterExit(double) (final implementation).rescheduleAfterDeparture in class AbstractSimQueue<J extends SimJob,Q extends AbstractPreemptiveSimQueue>departedJob - The departed job.time - The departure (current) time.AbstractSimQueue.depart(double, J),
AbstractSimQueue.removeJobFromQueueUponDeparture(J, double)protected abstract void removeJobFromQueueUponExit(J exitingJob, double time)
The job may have been dropped, successfully revoked, or it may just depart.
This is the central entry point for
removeJobFromQueueUponDrop(J, double),
removeJobFromQueueUponRevokation(J, double, boolean),
removeJobFromQueueUponDeparture(J, double).
Implementations must take into account the cancellation of departure (and other) events.
exitingJob - The job leaving.time - The (current) time.removeJobFromQueueUponDrop(J, double),
removeJobFromQueueUponRevokation(J, double, boolean),
removeJobFromQueueUponDeparture(J, double),
rescheduleAfterExit(double),
AbstractSimQueue.getDepartureEvents()protected abstract void rescheduleAfterExit(double time)
The job may have been dropped, successfully been revoked, or departed.
This is the central entry point for
rescheduleAfterDrop(J, double),
rescheduleAfterRevokation(J, double, boolean),
rescheduleAfterDeparture(J, double).
Implementations must typically check whether to start a new service chunk startServiceChunk(double, J).
time - The (current) time.rescheduleAfterDrop(J, double),
rescheduleAfterRevokation(J, double, boolean),
rescheduleAfterDeparture(J, double),
removeJobFromQueueUponExit(J, double),
startServiceChunk(double, J)Copyright © 2018. All rights reserved.