java.lang.Object
edu.kit.ipd.sdq.pcm.simulation.scheduler.exact.loaddistribution.balancers.OriginalAbstractLoadBalancer
All Implemented Interfaces:
ILoadBalancer

public abstract class OriginalAbstractLoadBalancer extends Object implements ILoadBalancer
  • Field Details

    • balance_interval

      protected double balance_interval
      Minimum time that needs to pass between two load balancing attempts
    • last_load

      protected Hashtable<IResourceInstance,Double> 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

      protected MultipleQueuesStrategy queue_holder
      Holder of the runqueues that need to be balanced.
    • prio_increasing

      protected boolean prio_increasing
      Determines the order how movable processes are returned. If true, the priority of the processes is increasing, otherwise decreasing.
    • queue_ascending

      protected boolean 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.
  • 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

      public void setQueueHolder(MultipleQueuesStrategy queue_holder)
    • 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

      public void activelyBalance(IResourceInstance instance)
      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 interface ILoadBalancer
    • 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 moved
      dest - 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

      protected int load(IResourceInstance instance)
      Returns the load of the given instance.
      Parameters:
      instance -
      Returns:
    • getBusiest

      protected IResourceInstance getBusiest(Collection<IResourceInstance> instance_list)
      Returns the busiest queue in the given list.
      Parameters:
      runQueues -
      Returns:
    • getLaziest

      protected IResourceInstance getLaziest(Collection<IResourceInstance> instance_list)
      Returns the idlest queue in the given list.
      Parameters:
      runQueues -
      Returns:
    • getInstancesWithMoreThanOneProcess

      protected List<IResourceInstance> 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

      protected void doBalance(IResourceInstance instance)
      Balances the queue of the given instance and the queue of the busiest instance.
      Parameters:
      instance -