Class OriginalAbstractLoadBalancer
java.lang.Object
edu.kit.ipd.sdq.pcm.simulation.scheduler.exact.loaddistribution.balancers.OriginalAbstractLoadBalancer
- All Implemented Interfaces:
ILoadBalancer
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected doubleMinimum 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 booleanDetermines the order how movable processes are returned.protected booleanDetermines the order how movable processes are returned.protected MultipleQueuesStrategyHolder of the runqueues that need to be balanced. -
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedOriginalAbstractLoadBalancer(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 TypeMethodDescriptionvoidactivelyBalance(IResourceInstance instance) Balances the load.protected voidbalanceTwoInstances(IResourceInstance src, IResourceInstance dest, int max_processes_needed) Moves processes from the src instance to the dest instance until both are balanced.protected voiddoBalance(IResourceInstance instance) Balances the queue of the given instance and the queue of the busiest instance.protected IResourceInstancegetBusiest(Collection<IResourceInstance> instance_list) Returns the busiest queue in the given list.protected List<IResourceInstance>Returns all queues with more than one job.protected IResourceInstancegetLaziest(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 booleanisBalanced(IResourceInstance firstInstance, IResourceInstance secondInstance) Template Method.protected intload(IResourceInstance instance) Returns the load of the given instance.protected intnumProcessedNeeded(IResourceInstance first_instance, IResourceInstance second_instance) Returns the maximum number of processes needed to balance both queues.voidsetQueueHolder(MultipleQueuesStrategy queue_holder) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:ILoadBalancerBalances 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:
activelyBalancein 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-
-