J - The type of SimJobs supported.Q - The type of SimQueues supported.P - The type used for QoS.public class PQ<J extends SimJob,Q extends PQ,P extends Comparable> extends AbstractPreemptiveSimQueueQoS<J,Q,P>
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 |
|---|---|
protected NavigableMap<P,Set<J>> |
jobsQoSMap |
DEFAULT_PREEMPTION_STRATEGY, jobsBeingServed, remainingServiceTime, TOLERANCE_RSTeventsScheduled, SANITYUSE_ARRAY_OPTIMIZATION| Constructor and Description |
|---|
PQ(org.javades.jsimulation.r5.SimEventList eventList,
PreemptionStrategy preemptionStrategy,
Class<P> qosClass,
P defaultJobQoS)
Creates a Priority Queue with infinite buffer size and a single server,
given an event list, preemption strategy, and QoS structure.
|
| Modifier and Type | Method and Description |
|---|---|
PQ<J,Q,P> |
getCopySimQueue()
Returns a new
PQ object on the same SimEventList with the same preemption strategy and QoS structure. |
protected J |
getExecutableJobWithHighestPriority()
Gets the job (if any) eligible for execution that has highest priority, respecting server-access credits.
|
NavigableMap<P,Set<J>> |
getJobsQoSMap()
Gets the mapping QoS values onto jobs currently visiting this queue with that particular QoS value.
|
protected double |
getServiceTimeForJob(J job)
Calls super method (in order to make implementation final).
|
protected void |
insertJobInQueueUponArrival(J job,
double time)
Inserts the job into
jobsQoSMap. |
protected void |
insertJobInQueueUponStart(J job,
double time)
|
boolean |
isStartArmed()
Returns true if there are no jobs present in the service area.
|
protected void |
removeJobFromQueueUponExit(J exitingJob,
double time)
Removes the job from internal administration and cancels a pending departure event for it.
|
protected void |
reschedule()
Reschedules through assessment of which job to serve.
|
protected void |
rescheduleAfterArrival(J job,
double time)
Starts the arrived job immediately if it is the executable job (respecting server-access credits) with highest priority.
|
protected void |
rescheduleAfterExit(double time)
Invokes
reschedule(). |
protected void |
rescheduleAfterStart(J job,
double time)
Invokes
reschedule(). |
protected void |
rescheduleForNewServerAccessCredits(double time)
Invokes
reschedule(). |
protected void |
resetEntitySubClass()
Calls super method and clear
jobsQoSMap. |
protected void |
setServerAccessCreditsSubClass()
Calls super method (in order to make implementation final).
|
String |
toStringDefault()
Returns "PQ[preemption strategy]".
|
getDefaultJobQoS, getQoS, getQoSClass, setQoS, setQoSClassgetJobsBeingServed, getPreemptionStrategy, preemptJob, queueAccessVacationDropSubClass, removeJobFromQueueUponDeparture, removeJobFromQueueUponDrop, removeJobFromQueueUponRevokation, rescheduleAfterDeparture, rescheduleAfterDrop, rescheduleAfterRevokation, startServiceChunk, updateRemainingServiceTimegetBufferSize, 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, updateprotected final NavigableMap<P extends Comparable,Set<J extends SimJob>> jobsQoSMap
public PQ(org.javades.jsimulation.r5.SimEventList eventList,
PreemptionStrategy preemptionStrategy,
Class<P> qosClass,
P defaultJobQoS)
eventList - The event list to use.preemptionStrategy - The preemption strategy, if null, the default is used (preemptive-resume).qosClass - The Java class to use for QoS behavior, non-null.defaultJobQoS - The default QoS value to use for non-QoS jobs, non-null.IllegalArgumentException - If the event list or one or both QoS arguments is null.public PQ<J,Q,P> getCopySimQueue()
PQ object on the same SimEventList with the same preemption strategy and QoS structure.PQ object on the same SimEventList with the same preemption strategy and QoS structure.AbstractSimEntity.getEventList(),
AbstractPreemptiveSimQueue.getPreemptionStrategy(),
AbstractPreemptiveSimQueueQoS.getQoSClass(),
AbstractPreemptiveSimQueueQoS.getDefaultJobQoS()public String toStringDefault()
toStringDefault in interface SimEntitytoStringDefault in class AbstractSimQueue<J extends SimJob,Q extends PQ>SimEntity.setName(java.lang.String),
Object.toString()public final NavigableMap<P,Set<J>> getJobsQoSMap()
SimQueueQoS
Each SimJob present returning (valid) non-null QoS value from SimQoS.getQoS()
must be in present in only that value set,
and the union of these value sets must exactly match SimQueue.getJobs().
Jobs returning null from SimQoS.getQoS() must be put in a value set corresponding to
SimQueueQoS.getDefaultJobQoS().
Note that many concrete subclasses will impose an ordering on the keys and/or on the value sets.
SimQueue.getJobs(),
SimQoS.getQoS(),
SimQueueQoS.getDefaultJobQoS()protected final void resetEntitySubClass()
jobsQoSMap.resetEntitySubClass in class AbstractPreemptiveSimQueueQoS<J extends SimJob,Q extends PQ,P extends Comparable>jobsQoSMapprotected final void insertJobInQueueUponArrival(J job, double time)
jobsQoSMap.insertJobInQueueUponArrival in class AbstractSimQueue<J extends SimJob,Q extends PQ>job - The job that arrived.time - The current time (i.e., arrival time of the job).SimQueueQoSUtils.getAndCheckJobQoS(J, Q)protected final void rescheduleAfterArrival(J job, double time)
rescheduleAfterArrival in class AbstractSimQueue<J extends SimJob,Q extends PQ>job - The job that arrived (and is already present in AbstractSimQueue.getJobs()).time - The current time (i.e., the arrival time of the job).getExecutableJobWithHighestPriority(),
AbstractSimQueue.start(double, J)protected final void setServerAccessCreditsSubClass()
setServerAccessCreditsSubClass in class AbstractSimQueue<J extends SimJob,Q extends PQ>AbstractSimQueue.getServerAccessCredits(),
AbstractSimQueue.setServerAccessCredits(double, int),
AbstractSimQueue.rescheduleForNewServerAccessCredits(double)protected final void rescheduleForNewServerAccessCredits(double time)
reschedule().rescheduleForNewServerAccessCredits in class AbstractSimQueue<J extends SimJob,Q extends PQ>time - The current time (i.e., the time at which new server-access credits became available).AbstractSimQueue.setServerAccessCredits(double, int),
AbstractSimQueue.hasServerAcccessCredits()public final boolean isStartArmed()
AbstractSimQueue.getNumberOfJobsInServiceArea()protected final void insertJobInQueueUponStart(J job, double time)
insertJobInQueueUponStart in class AbstractSimQueue<J extends SimJob,Q extends PQ>job - The job that starts.time - The current time (i.e., start time of the job).getServiceTimeForJob(J),
AbstractPreemptiveSimQueue.remainingServiceTimeprotected final void rescheduleAfterStart(J job, double time)
reschedule().rescheduleAfterStart in class AbstractSimQueue<J extends SimJob,Q extends PQ>job - The job that started (and is already present in AbstractSimQueue.getJobsInServiceArea().time - The current time (i.e., the start time of the job).AbstractPreemptiveSimQueue.remainingServiceTime,
reschedule()protected final double getServiceTimeForJob(J job)
getServiceTimeForJob in class AbstractSimQueue<J extends SimJob,Q extends PQ>job - The job, non-null.protected final void removeJobFromQueueUponExit(J exitingJob, double time)
removeJobFromQueueUponExit in class AbstractPreemptiveSimQueue<J extends SimJob,Q extends PQ>exitingJob - The job leaving.time - The (current) time.AbstractPreemptiveSimQueue.remainingServiceTime,
AbstractPreemptiveSimQueue.jobsBeingServed,
AbstractSimQueue.getDepartureEvents(),
AbstractSimQueue.cancelDepartureEvent(org.javades.jqueues.r5.entity.jq.SimJQEvent.Departure<J, Q>),
SimQueueQoSUtils.getAndCheckJobQoS(J, Q),
getJobsQoSMap()protected final void rescheduleAfterExit(double time)
reschedule().rescheduleAfterExit in class AbstractPreemptiveSimQueue<J extends SimJob,Q extends PQ>time - The (current) time.AbstractPreemptiveSimQueue.rescheduleAfterDrop(J, double),
AbstractPreemptiveSimQueue.rescheduleAfterRevokation(J, double, boolean),
AbstractPreemptiveSimQueue.rescheduleAfterDeparture(J, double),
AbstractPreemptiveSimQueue.removeJobFromQueueUponExit(J, double),
AbstractPreemptiveSimQueue.startServiceChunk(double, J)protected final J getExecutableJobWithHighestPriority()
This method effectively determines the job that should be in service in PQ
by examining (solely)
AbstractSimQueue.getJobs(),
jobsQoSMap,
AbstractSimQueue.getJobsInServiceArea(),
and AbstractSimQueue.hasServerAcccessCredits().
Note that ties between executable jobs with equal QoS values are broken by the order in which the jobs appear
in an iterator over the applicable value set in jobsQoSMap
(in the obvious sense that the job that first appears in the iterator is given highest priority).
This method does (some) sanity checks on jobsQoSMap on the fly.
null if there is no such job.protected final void reschedule()
Repeatedly (until they match) confronts
the job to serve as obtained through getExecutableJobWithHighestPriority()
with the job currently in service (the only job in AbstractPreemptiveSimQueue.jobsBeingServed).
If there is a mismatch, and if there is a job currently being served,
it preempts the latter job through AbstractPreemptiveSimQueue.preemptJob(double, J), and recurs.
Otherwise, if there is a mismatch but no job is currently being served,
it starts getExecutableJobWithHighestPriority()
either by AbstractSimQueue.start(double, J) if the job is not already in the service area,
or by AbstractPreemptiveSimQueue.startServiceChunk(double, J) otherwise.
AbstractPreemptiveSimQueue.jobsBeingServed,
getExecutableJobWithHighestPriority(),
AbstractPreemptiveSimQueue.preemptJob(double, J),
AbstractSimQueue.isJobInServiceArea(org.javades.jqueues.r5.entity.jq.job.SimJob),
AbstractSimQueue.start(double, J),
AbstractPreemptiveSimQueue.startServiceChunk(double, J)Copyright © 2018. All rights reserved.