public class DLIMIT<J extends SimJob,Q extends DLIMIT> extends AbstractServerlessSimQueue<J,Q>
DLIMIT queue jobs depart without service in arrival order,
but not at a higher rate than a given limit, at the expense of waiting.
This SimQueue is server-less.
The operation of this SimQueue is controlled by the rateLimit property, see getRateLimit().
It must be non-negative and is set upon construction; and cannot be changed afterwards.
If set to zero, this queue behaves as SINK.
If so to positive infinite, this queue behaves as ZERO.
The DLIMIT queueing discipline is equivalent to LeakyBucket with infinite buffer size.
Copyright (C) 2005-2017 Jan de Jongh, TNO
This file is covered by the LICENSE file in the root of this project.
ZERO,
SINK,
DELAY,
LeakyBucket| Modifier and Type | Class and Description |
|---|---|
protected static class |
DLIMIT.RateLimitExpirationEvent<Q extends DLIMIT>
The default
SimEvent used internally for scheduling rate-limit expirations. |
AbstractSimEntity.Notifier, AbstractSimEntity.PreNotificationHookSimQueue.AutoRevocationPolicySimEntity.Action, SimEntity.UnknownNotificationTypePolicy, SimEntity.UnknownOperationPolicyeventsScheduled, SANITYUSE_ARRAY_OPTIMIZATION| Constructor and Description |
|---|
DLIMIT(org.javades.jsimulation.r5.SimEventList eventList,
double rateLimit)
Creates a
DLIMIT queue with infinite buffer size given an event list and (departure) rate limit. |
| Modifier and Type | Method and Description |
|---|---|
DLIMIT<J,Q> |
getCopySimQueue()
Returns a new
DLIMIT object on the same SimEventList with the same (departure) rate limit. |
Object |
getQoS()
Calls super method (in order to make implementation final).
|
Class |
getQoSClass()
Calls super method (in order to make implementation final).
|
double |
getRateLimit()
Returns the (immutable) rate limit for departures (non-negative).
|
protected void |
insertJobInQueueUponArrival(J job,
double time)
Does nothing.
|
protected boolean |
isRateLimited()
Returns whether this queue is currently (departure) rate limited.
|
protected void |
rateLimitExpiration(DLIMIT.RateLimitExpirationEvent<Q> event)
Notification of rate-limit expiration from an internally-scheduled
DLIMIT.RateLimitExpirationEvent. |
protected void |
removeJobFromQueueUponDeparture(J departingJob,
double time)
Does nothing.
|
protected void |
removeJobFromQueueUponDrop(J job,
double time)
Does nothing.
|
protected void |
removeJobFromQueueUponRevokation(J job,
double time,
boolean auto)
Does nothing.
|
protected void |
rescheduleAfterArrival(J job,
double time)
Makes the job depart if the queue is not rate-limited; otherwise drop it if the waiting queue is "overflown".
|
protected void |
rescheduleAfterDeparture(J departedJob,
double time)
Schedules a new
DLIMIT.RateLimitExpirationEvent if the departure-rate limit is finite and non-zero. |
protected void |
rescheduleAfterDrop(J job,
double time)
Does nothing.
|
protected void |
rescheduleAfterRevokation(J job,
double time,
boolean auto)
Does nothing.
|
protected void |
resetEntitySubClass()
Calls super method and properly sets the rate limitation.
|
protected DLIMIT.RateLimitExpirationEvent<Q> |
scheduleRateLimitExpirationEvent(double expirationTime)
Schedules a suitable
SimEvent for a rate-limit expiration on the event list. |
String |
toStringDefault()
Returns "DLIMIT[rateLimit]".
|
getServiceTimeForJob, insertJobInQueueUponStart, isStartArmed, queueAccessVacationDropSubClass, rescheduleAfterStart, rescheduleForNewServerAccessCredits, setServerAccessCreditsSubClassgetBufferSize, 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 DLIMIT(org.javades.jsimulation.r5.SimEventList eventList,
double rateLimit)
DLIMIT queue with infinite buffer size given an event list and (departure) rate limit.eventList - The event list to use.rateLimit - The (departure) rate limit, non-negative.IllegalArgumentException - If the rate limit is strictly negative.public DLIMIT<J,Q> getCopySimQueue()
DLIMIT object on the same SimEventList with the same (departure) rate limit.DLIMIT object on the same SimEventList with the same (departure) rate limit.AbstractSimEntity.getEventList(),
getRateLimit()public String toStringDefault()
toStringDefault in interface SimEntitytoStringDefault in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>SimEntity.setName(java.lang.String),
Object.toString()public final double getRateLimit()
The (departure) rate limit is set upon construction, and cannot be changed afterwards.
protected final boolean isRateLimited()
public final Class getQoSClass()
null.public final Object getQoS()
null.protected final void resetEntitySubClass()
Since we always schedule DLIMIT.RateLimitExpirationEvent through AbstractSimQueue.eventsScheduled,
our super-class will cancel them automatically (if needed).
resetEntitySubClass in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>isRateLimitedprotected final void insertJobInQueueUponArrival(J job, double time)
insertJobInQueueUponArrival in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>job - The job that arrived.time - The current time (i.e., arrival time of the job).AbstractSimQueue.arrive(double, J),
AbstractSimQueue.rescheduleAfterArrival(J, double)protected final void rescheduleAfterArrival(J job, double time)
rescheduleAfterArrival in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>job - The job that arrived (and is already present in AbstractSimQueue.getJobs()).time - The current time (i.e., the arrival time of the job).isRateLimited,
AbstractSimQueue.depart(double, J),
insertJobInQueueUponArrival(J, double)protected final void removeJobFromQueueUponDrop(J job, double time)
removeJobFromQueueUponDrop in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>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)
rescheduleAfterDrop in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>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)
removeJobFromQueueUponRevokation in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>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)
rescheduleAfterRevokation in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>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 rateLimitExpiration(DLIMIT.RateLimitExpirationEvent<Q> event)
DLIMIT.RateLimitExpirationEvent.
Invokes AbstractSimEntity.update(double)
and AbstractSimEntity.clearAndUnlockPendingNotificationsIfLocked(),
insisting to be a top-level event (at the expense of an IllegalStateException).
If there are job in the waiting area, it makes depart the first one.
Otherwise, it invokes AbstractSimQueue.triggerPotentialNewStartArmed(double).
Finally, it notifies listeners through AbstractSimEntity.fireAndLockPendingNotifications().
event - The event that invoked us through its SimEventAction, non-null.DLIMIT.RateLimitExpirationEvent,
AbstractSimQueue.eventsScheduled,
isRateLimited,
AbstractSimQueue.hasJobsInWaitingArea(),
AbstractSimQueue.depart(double, J),
AbstractSimQueue.triggerPotentialNewStartArmed(double),
AbstractSimEntity.clearAndUnlockPendingNotificationsIfLocked(),
AbstractSimEntity.fireAndLockPendingNotifications()protected final DLIMIT.RateLimitExpirationEvent<Q> scheduleRateLimitExpirationEvent(double expirationTime)
SimEvent for a rate-limit expiration on the event list.
The implementation creates a new DLIMIT.RateLimitExpirationEvent,
adds it to AbstractSimQueue.eventsScheduled and schedules the new event on the event list.
Effectively, this ensures that unless the event is canceled,
the method rateLimitExpiration(org.javades.jqueues.r5.entity.jq.queue.serverless.DLIMIT.RateLimitExpirationEvent<Q>) is invoked upon reaching the event.
expirationTime - The scheduled expiration time.AbstractSimEntity.getEventList(),
AbstractSimEntity.getLastUpdateTime(),
AbstractSimQueue.eventsScheduledprotected final void removeJobFromQueueUponDeparture(J departingJob, double time)
removeJobFromQueueUponDeparture in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>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)
DLIMIT.RateLimitExpirationEvent if the departure-rate limit is finite and non-zero.
If the rate limit is zero or negative, this method throws an exception, as departures are not supposed to happen.
rescheduleAfterDeparture in class AbstractSimQueue<J extends SimJob,Q extends DLIMIT>departedJob - The departed job.time - The departure (current) time.IllegalStateException - If the rate limit is not strictly positive, or if this queue is currently under
rate-limitation, as determined through isRateLimited,
in both cases of which departures should not occur.isRateLimited,
getRateLimit(),
scheduleRateLimitExpirationEvent(double)Copyright © 2018. All rights reserved.