Class MultipleQueuesStrategy
- java.lang.Object
-
- edu.kit.ipd.sdq.pcm.simulation.scheduler.exact.queueing.strategies.MultipleQueuesStrategy
-
- All Implemented Interfaces:
IQueueingStrategy
public class MultipleQueuesStrategy extends Object implements IQueueingStrategy
-
-
Constructor Summary
Constructors Constructor Description MultipleQueuesStrategy(Collection<IResourceInstance> allInstances, IRunQueue prototypeRunQueue, IInstanceSelector initialInstanceSelector, ILoadBalancer loadBalancer, boolean in_front_when_balancing)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activelyBalance(IResourceInstance instance)
Depending on the underlying implementation the load is balanced between the resource instances.void
addProcess(IActiveProcess process, IResourceInstance current, boolean inFront)
Adds a process to the runqueue.boolean
containsPending(IActiveProcess process)
void
forkProcess(IActiveProcess process, IResourceInstance current, boolean inFront)
void
fromRunningToWaiting(IActiveProcess process)
void
fromWaitingToReady(IActiveProcess process, IResourceInstance current, boolean in_front_after_waiting)
List<IResourceInstance>
getIdleInstances()
Returns all queues without jobs.IActiveProcess
getNextProcessFor(IResourceInstance instance)
Returns the next runnable process for the resource instance.int
getQueueLengthFor(SimResourceInstance simResourceInstance)
Collection<IResourceInstance>
getResourceInstances()
IRunQueue
getRunQueueFor(IResourceInstance instance)
Returns the RunQueue for a resource instance.List<IActiveProcess>
getStarvingProcesses(IResourceInstance instance, double starvationLimit)
boolean
isIdle(IResourceInstance instance)
True, if the given resource has no running or pending jobs, otherwise false.void
move(IActiveProcess process, IResourceInstance src, IResourceInstance dest)
Moves the given process from the runqueue of the src instance to the runqueue of the dest instance.void
onSleep(IResourceInstance lastInstance)
void
registerProcess(IActiveProcess process, IResourceInstance current)
boolean
removePendingProcess(IActiveProcess process)
Removes at the pending queues of the queuing strategy and tries to remove the process there.void
removeRunning(IActiveProcess process)
Removes a process from the running list of the instance.void
resetStarvationInfo()
IResourceInstance
runningOn(IActiveProcess process)
void
setRunningOn(IActiveProcess process, IResourceInstance instance)
Sets the process as executing on the given instance.void
terminateProcess(IActiveProcess process)
-
-
-
Constructor Detail
-
MultipleQueuesStrategy
public MultipleQueuesStrategy(Collection<IResourceInstance> allInstances, IRunQueue prototypeRunQueue, IInstanceSelector initialInstanceSelector, ILoadBalancer loadBalancer, boolean in_front_when_balancing)
-
-
Method Detail
-
getRunQueueFor
public IRunQueue getRunQueueFor(IResourceInstance instance)
Returns the RunQueue for a resource instance.
-
getNextProcessFor
public IActiveProcess getNextProcessFor(IResourceInstance instance)
Returns the next runnable process for the resource instance.- Specified by:
getNextProcessFor
in interfaceIQueueingStrategy
-
addProcess
public void addProcess(IActiveProcess process, IResourceInstance current, boolean inFront)
Adds a process to the runqueue. The process is added using the strategy of the runqueue. A process is added after its creation or after waiting.- Specified by:
addProcess
in interfaceIQueueingStrategy
inFront
- If true, the process is added at the beginning of its queue, otherwise at its end.
-
move
public void move(IActiveProcess process, IResourceInstance src, IResourceInstance dest)
Moves the given process from the runqueue of the src instance to the runqueue of the dest instance.- Parameters:
process
- Process to be moved.src
- Source resource instance.dest
- Destination resource instance.
-
activelyBalance
public void activelyBalance(IResourceInstance instance)
Description copied from interface:IQueueingStrategy
Depending on the underlying implementation the load is balanced between the resource instances.- Specified by:
activelyBalance
in interfaceIQueueingStrategy
- Parameters:
instance
- Instance initiating the load balance.
-
getResourceInstances
public Collection<IResourceInstance> getResourceInstances()
-
isIdle
public boolean isIdle(IResourceInstance instance)
Description copied from interface:IQueueingStrategy
True, if the given resource has no running or pending jobs, otherwise false.- Specified by:
isIdle
in interfaceIQueueingStrategy
-
getIdleInstances
public List<IResourceInstance> getIdleInstances()
Returns all queues without jobs.- Parameters:
runQueueCollection
-- Returns:
-
removePendingProcess
public boolean removePendingProcess(IActiveProcess process)
Description copied from interface:IQueueingStrategy
Removes at the pending queues of the queuing strategy and tries to remove the process there.- Specified by:
removePendingProcess
in interfaceIQueueingStrategy
- Parameters:
process
- Process that should be removed.- Returns:
- True, if the process was successfully removed. False, if the process was not found in the pending queues.
-
containsPending
public boolean containsPending(IActiveProcess process)
- Specified by:
containsPending
in interfaceIQueueingStrategy
- Parameters:
process
- Process looked for.- Returns:
- True, if the process is in a pending queue of the strategy.
-
removeRunning
public void removeRunning(IActiveProcess process)
Description copied from interface:IQueueingStrategy
Removes a process from the running list of the instance.- Specified by:
removeRunning
in interfaceIQueueingStrategy
- Parameters:
process
- Process of interest.
-
runningOn
public IResourceInstance runningOn(IActiveProcess process)
- Specified by:
runningOn
in interfaceIQueueingStrategy
- Parameters:
process
- Process of interest.- Returns:
- Returns the resource instance the process is currently running on. NULL if the process is not assigned to a resource.
-
setRunningOn
public void setRunningOn(IActiveProcess process, IResourceInstance instance)
Description copied from interface:IQueueingStrategy
Sets the process as executing on the given instance. In order for this operation to be successful, the process must be in ready state and in the a pending queue of the strategy.- Specified by:
setRunningOn
in interfaceIQueueingStrategy
- Parameters:
process
- Process that shall be executed.instance
- Target instance for the process.
-
forkProcess
public void forkProcess(IActiveProcess process, IResourceInstance current, boolean inFront)
- Specified by:
forkProcess
in interfaceIQueueingStrategy
-
registerProcess
public void registerProcess(IActiveProcess process, IResourceInstance current)
- Specified by:
registerProcess
in interfaceIQueueingStrategy
-
fromRunningToWaiting
public void fromRunningToWaiting(IActiveProcess process)
- Specified by:
fromRunningToWaiting
in interfaceIQueueingStrategy
-
onSleep
public void onSleep(IResourceInstance lastInstance)
- Specified by:
onSleep
in interfaceIQueueingStrategy
-
terminateProcess
public void terminateProcess(IActiveProcess process)
- Specified by:
terminateProcess
in interfaceIQueueingStrategy
-
fromWaitingToReady
public void fromWaitingToReady(IActiveProcess process, IResourceInstance current, boolean in_front_after_waiting)
- Specified by:
fromWaitingToReady
in interfaceIQueueingStrategy
-
getStarvingProcesses
public List<IActiveProcess> getStarvingProcesses(IResourceInstance instance, double starvationLimit)
- Specified by:
getStarvingProcesses
in interfaceIQueueingStrategy
-
resetStarvationInfo
public void resetStarvationInfo()
- Specified by:
resetStarvationInfo
in interfaceIQueueingStrategy
-
getQueueLengthFor
public int getQueueLengthFor(SimResourceInstance simResourceInstance)
- Specified by:
getQueueLengthFor
in interfaceIQueueingStrategy
-
-