Class OriginalAbstractLoadBalancer
java.lang.Object
edu.kit.ipd.sdq.pcm.simulation.scheduler.exact.loaddistribution.balancers.OriginalAbstractLoadBalancer
- All Implemented Interfaces:
ILoadBalancer
-
Field Summary
Modifier and TypeFieldDescriptionprotected double
Minimum time that needs to pass between two load balancing attemptsprotected Hashtable<IResourceInstance,
Double> If !do_global_balance, this table is used to track the time that passed since the last execution of a load balancer for an instance.protected boolean
Determines the order how movable processes are returned.protected boolean
Determines the order how movable processes are returned.protected MultipleQueuesStrategy
Holder of the runqueues that need to be balanced. -
Constructor Summary
ModifierConstructorDescriptionprotected
OriginalAbstractLoadBalancer
(double balance_interval, boolean do_global_balance, boolean prio_increasing, boolean queue_ascending, int max_iterations) Creates a new instance of a load balancer. -
Method Summary
Modifier and TypeMethodDescriptionvoid
activelyBalance
(IResourceInstance instance) Balances the load.protected void
balanceTwoInstances
(IResourceInstance src, IResourceInstance dest, int max_processes_needed) Moves processes from the src instance to the dest instance until both are balanced.protected void
doBalance
(IResourceInstance instance) Balances the queue of the given instance and the queue of the busiest instance.protected IResourceInstance
getBusiest
(Collection<IResourceInstance> instance_list) Returns the busiest queue in the given list.protected List<IResourceInstance>
Returns all queues with more than one job.protected IResourceInstance
getLaziest
(Collection<IResourceInstance> instance_list) Returns the idlest queue in the given list.protected List<IActiveProcess>
identifyMovableProcesses
(IResourceInstance source_instance, IResourceInstance target_instance, int processes_needed) Returns an ordered list of movable processes.protected abstract boolean
isBalanced
(IResourceInstance firstInstance, IResourceInstance secondInstance) Template Method.protected int
load
(IResourceInstance instance) Returns the load of the given instance.protected int
numProcessedNeeded
(IResourceInstance first_instance, IResourceInstance second_instance) Returns the maximum number of processes needed to balance both queues.void
setQueueHolder
(MultipleQueuesStrategy queue_holder) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface edu.kit.ipd.sdq.pcm.simulation.scheduler.exact.loaddistribution.ILoadBalancer
onFork, onSleep, onTerminate, onWake
-
Field Details
-
balance_interval
protected double balance_intervalMinimum time that needs to pass between two load balancing attempts -
last_load
If !do_global_balance, this table is used to track the time that passed since the last execution of a load balancer for an instance. -
queue_holder
Holder of the runqueues that need to be balanced. -
prio_increasing
protected boolean prio_increasingDetermines the order how movable processes are returned. If true, the priority of the processes is increasing, otherwise decreasing. -
queue_ascending
protected boolean queue_ascendingDetermines the order how movable processes are returned. If true, the first processes are returned in the same order of the queue, otherwise they are returned in reverse order.
-
-
Constructor Details
-
OriginalAbstractLoadBalancer
protected OriginalAbstractLoadBalancer(double balance_interval, boolean do_global_balance, boolean prio_increasing, boolean queue_ascending, int max_iterations) Creates a new instance of a load balancer.- Parameters:
balance_interval
- Minimum time that needs to pass between two executions of the load balancer.do_global_balance
- Indicates whether all instances should be balanced or only the specified and busiest one.prio_increasing
- Determines the order how movable processes are returned. If true, the priority of the processes is increasing, otherwise decreasing.queue_ascending
- Determines the order how movable processes are returned. If true, the first processes are returned in the same order of the queue, otherwise they are returned in reverse order.max_iterations
- Gives the maximum number of iterations for a global balancing.
-
-
Method Details
-
setQueueHolder
-
isBalanced
protected abstract boolean isBalanced(IResourceInstance firstInstance, IResourceInstance secondInstance) Template Method. Checks if both queues are balanced with respect to a given criteria.- Parameters:
busyQueue
-idleQueue
-- Returns:
-
activelyBalance
Description copied from interface:ILoadBalancer
Balances the load. Two scenarios are possible. Either the load is balanced between all instances, or the specified instances pulls processes from the busiest one.- Specified by:
activelyBalance
in interfaceILoadBalancer
-
balanceTwoInstances
protected void balanceTwoInstances(IResourceInstance src, IResourceInstance dest, int max_processes_needed) Moves processes from the src instance to the dest instance until both are balanced.- Parameters:
src
- source instance of the processes moveddest
- destination instance of the processes moved
-
identifyMovableProcesses
protected List<IActiveProcess> identifyMovableProcesses(IResourceInstance source_instance, IResourceInstance target_instance, int processes_needed) Returns an ordered list of movable processes. The processes are ordered with respect to their "movability".- Returns:
- Ordered list of movable processes.
-
load
Returns the load of the given instance.- Parameters:
instance
-- Returns:
-
getBusiest
Returns the busiest queue in the given list.- Parameters:
runQueues
-- Returns:
-
getLaziest
Returns the idlest queue in the given list.- Parameters:
runQueues
-- Returns:
-
getInstancesWithMoreThanOneProcess
Returns all queues with more than one job.- Parameters:
runQueueCollection
-- Returns:
-
numProcessedNeeded
protected int numProcessedNeeded(IResourceInstance first_instance, IResourceInstance second_instance) Returns the maximum number of processes needed to balance both queues.- Parameters:
first_instance
-second_instance
-- Returns:
-
doBalance
Balances the queue of the given instance and the queue of the busiest instance.- Parameters:
instance
-
-