public class SocPS<J extends SimJob,Q extends SocPS> extends AbstractProcessorSharingSimQueue<J,Q>
At each time, the service rate of a job in the service area is linearly proportional to its remaining service time. (Note that this specification is actually essential; one can achieve simultaneous departures in many ways!)
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 Map<J,Double> |
remainingServiceTime
The per-job (in the service area) remaining service time.
|
static double |
TOLERANCE_RST
The tolerance for rounding errors in the remaining service time.
|
eventsScheduled, SANITYUSE_ARRAY_OPTIMIZATION| Constructor and Description |
|---|
SocPS(org.javades.jsimulation.r5.SimEventList eventList)
Creates a single-server SocPS queue with infinite buffer size given an event list.
|
| Modifier and Type | Method and Description |
|---|---|
SocPS<J,Q> |
getCopySimQueue()
Returns a new
SocPS object on the same SimEventList. |
Object |
getQoS()
Calls super method (in order to make implementation final).
|
Class |
getQoSClass()
Calls super method (in order to make implementation final).
|
protected double |
getRemainingWork()
Gets the total remaining work, i.e., the sum of remaining service times of all jobs in the service area.
|
protected double |
getServiceTimeForJob(J job)
Calls super method (in order to make implementation final).
|
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 remaining service time.
|
boolean |
isStartArmed()
Returns
true. |
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)
Makes sure all jobs left in the service area depart as well (through recursion).
|
protected void |
rescheduleAfterDrop(J job,
double time)
Throws
IllegalStateException. |
protected void |
rescheduleAfterRevokation(J job,
double time,
boolean auto)
Calls
rescheduleDepartureEvent(). |
protected void |
rescheduleAfterStart(J job,
double time)
Invokes
rescheduleDepartureEvent(). |
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 |
setServerAccessCreditsSubClass()
Calls super method (in order to make implementation final).
|
String |
toStringDefault()
Returns "SocPS".
|
protected void |
updateRemainingServiceTimes(double newTime)
Updates the internal administration (i.c., remaining 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_RST
public SocPS(org.javades.jsimulation.r5.SimEventList eventList)
The constructor registers a pre-update hook that maintains the remaining service times.
eventList - The event list to use.AbstractSimEntity.registerPreUpdateHook(java.util.function.DoubleConsumer),
updateRemainingServiceTimes(double)public SocPS<J,Q> getCopySimQueue()
SocPS object on the same SimEventList.SocPS object on the same SimEventList.AbstractSimEntity.getEventList()public String toStringDefault()
toStringDefault in interface SimEntitytoStringDefault in class AbstractSimQueue<J extends SimJob,Q extends SocPS>SimEntity.setName(java.lang.String),
Object.toString()public final Class getQoSClass()
null.public final Object getQoS()
null.protected final double getRemainingWork()
remainingServiceTimeprotected final void resetEntitySubClass()
resetEntitySubClass in class AbstractSimQueue<J extends SimJob,Q extends SocPS>remainingServiceTimeprotected final void updateRemainingServiceTimes(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.AbstractSimQueue.hasJobsInServiceArea(),
AbstractSimEntity.getLastUpdateTime(),
remainingServiceTime,
AbstractSimEntity.registerPreUpdateHook(java.util.function.DoubleConsumer)protected final void insertJobInQueueUponArrival(J job, double time)
insertJobInQueueUponArrival in class AbstractSimQueue<J extends SimJob,Q extends SocPS>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 SocPS>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 SocPS>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 SocPS>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)
Removes the job remainingServiceTime.
removeJobFromQueueUponRevokation in class AbstractSimQueue<J extends SimJob,Q extends SocPS>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),
remainingServiceTime,
rescheduleAfterRevokation(J, double, boolean)protected final void rescheduleAfterRevokation(J job, double time, boolean auto)
rescheduleDepartureEvent().rescheduleAfterRevokation in class AbstractSimQueue<J extends SimJob,Q extends SocPS>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),
rescheduleDepartureEvent(),
removeJobFromQueueUponRevokation(J, double, boolean)protected final void setServerAccessCreditsSubClass()
setServerAccessCreditsSubClass in class AbstractSimQueue<J extends SimJob,Q extends SocPS>AbstractSimQueue.getServerAccessCredits(),
AbstractSimQueue.setServerAccessCredits(double, int),
AbstractSimQueue.rescheduleForNewServerAccessCredits(double)protected final void rescheduleForNewServerAccessCredits(double time)
rescheduleForNewServerAccessCredits in class AbstractSimQueue<J extends SimJob,Q extends SocPS>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 SocPS>job - The job that starts.time - The current time (i.e., start time of the job).getServiceTimeForJob(J),
remainingServiceTimeprotected final void rescheduleAfterStart(J job, double time)
rescheduleDepartureEvent().rescheduleAfterStart in class AbstractSimQueue<J extends SimJob,Q extends SocPS>job - The job that started (and is already present in AbstractSimQueue.getJobsInServiceArea().time - The current time (i.e., the start time of the job).rescheduleDepartureEvent(),
insertJobInQueueUponStart(J, double)protected final double getServiceTimeForJob(J job)
getServiceTimeForJob in class AbstractSimQueue<J extends SimJob,Q extends SocPS>job - The job, non-null.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 SocPS>departingJob - The job that departs.time - The departure (current) time.removeJobFromQueueUponRevokation(J, double, boolean),
rescheduleAfterDeparture(J, double)protected final void rescheduleAfterDeparture(J departedJob, double time)
All jobs in the service area depart simultaneously, if at all.
Hence, if a job departs, all other jobs in the service area must depart as well.
The main scheduling method, rescheduleDepartureEvent(),
schedules (or invokes) a departure through AbstractSimQueue.depart(double, J) on a single job,
and it is up to us to make sure all jobs in the service area depart.
rescheduleAfterDeparture in class AbstractSimQueue<J extends SimJob,Q extends SocPS>departedJob - The departed job.time - The departure (current) time.removeJobFromQueueUponDeparture(J, double)protected final void rescheduleDepartureEvent()
First, this method cancels any pending departure event.
If the remaining work of this queue is negligible, in view of TOLERANCE_RST,
or if the remaining work is finite but time is negative of positive infinity,
this method triggers the departure of all jobs in the service area, if any,
by invoking AbstractSimQueue.depart(double, J) on the first job in the service area,
relying on the departure handling for the other jobs to depart.
Otherwise, if the remaining work is finite and time is finite,
this method schedules a suitable departure event through AbstractSimQueue.scheduleDepartureEvent(double, J)
for the first job in the service area, if present,
again relying on the departure handling for the simultaneous departure of the other jobs in the service area.
Otherwise, the remaining work is infinite (or there are no jobs) and nothing needs to be done.
AbstractSimQueue.getDepartureEvents(),
AbstractSimQueue.cancelDepartureEvent(org.javades.jqueues.r5.entity.jq.SimJQEvent.Departure<J, Q>),
AbstractSimEntity.getLastUpdateTime(),
getRemainingWork(),
AbstractSimQueue.hasJobsInServiceArea(),
AbstractSimQueue.getNumberOfJobsInServiceArea(),
AbstractSimQueue.depart(double, J),
AbstractSimQueue.hasJobsInServiceArea(),
TOLERANCE_RST,
AbstractSimQueue.scheduleDepartureEvent(double, J)Copyright © 2018. All rights reserved.