hu.mta.sztaki.lpds.cloud.simulator.iaas.vmscheduling
Class Scheduler

java.lang.Object
  extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.vmscheduling.Scheduler
Direct Known Subclasses:
FirstFitScheduler

public abstract class Scheduler
extends Object

The base class for all VM schedulers, provides the foundational logic and simplifies the implementation of VM schedulers by allowing them to mainly focus on their scheduling logic.

Author:
"Gabor Kecskemeti, Laboratory of Parallel and Distributed Systems, MTA SZTAKI (c) 2012"

Nested Class Summary
static interface Scheduler.QueueingEvent
          Implementing this interface allows the implementor to receive events from the scheduler about cases when it believes the infrastructure is not sufficient for its needs.
 
Field Summary
protected  VMManager.CapacityChangeEvent<ResourceConstraints> freeCapacity
          This field represents the action to be done when some resources become free on one of the currently running PMs in the IaaS.
private  AlterableResourceConstraints freeResourcesSinceLastSchedule
          In this field the simulator maintains those recently freed up resources that could be allowing a new scheduling run
private  ConstantConstraints minimumSchedulerRequirement
          Here we keep an account of the amount of resources a particular scheduler would need before it would be able to schedule a new VM request
private  ArrayList<PhysicalMachine> orderedPMcache
          This field contains an automatically updated list of all machines in the parent IaaS.
protected  IaaSService parent
          The IaaS for which this VM scheduler manages the VM requests.
private  int pmCacheLen
          current length of the pm cache so we don't need to query its size all the time
static Comparator<PhysicalMachine> pmComparator
          A PM comparator that offers inverse ordering of PMs if used during sort
protected  PhysicalMachine.StateChangeListener pmstateChanged
          This is the action that takes place when one of the PMs at the IaaS changes its state.
protected  UnalterableConstraintsPropagator publicTQ
          the public version of totalQueued that mirrors its contents but does not allow changes on it
protected  List<QueueingData> queue
          The queue of the scheduler.
private  StateDependentEventHandler<Scheduler.QueueingEvent,Integer> queueListenerManager
          the manager of those objects who shown interest in receiving queuing related event notifications
private  AlterableResourceConstraints totalQueued
          the amount of resources needed for fulfilling all VM requests in the queue
 
Constructor Summary
Scheduler(IaaSService parent)
          The main constructor of all schedulers.
 
Method Summary
 boolean dropVMrequest(VirtualMachine vm)
          Cancels a VM request by dropping the corresponding queuing data from the scheduler's queue.
 List<VirtualMachine> getQueuedVMs()
          Prepares a list of all the VMs that are queued at the particular moment in time
 int getQueueLength()
          The number of VM requests queued at the moment
 ResourceConstraints getTotalQueued()
          The complete resource set required to fulfill the entirety of the VM requests in the queue
private  void invokeRealScheduler()
          This function is actually calling the subclass's scheduler implementation and handles the management of minimum scheduler requirements and resets the free resource aggregate
protected  QueueingData manageQueueRemoval()
          Removes the head of the queue
protected  void manageQueueRemoval(QueueingData qd)
          Removes an arbitrary item from the queue (could be a rather slow operation!)
protected abstract  ConstantConstraints scheduleQueued()
          When a new VM scheduler is created this is the function to be implemented.
 void scheduleVMrequest(VirtualMachine[] vms, ResourceConstraints rc, Repository vaSource, HashMap<String,Object> schedulingConstraints)
          The main entry point to the schedulers.
 void subscribeQueueingEvents(Scheduler.QueueingEvent e)
          Allows third parties to get notified if the scheduler is not satisfied with the current infrastructure (e.g.
 void unsubscribeQueueingEvents(Scheduler.QueueingEvent e)
          Cancels the notifications about queuing events
private  void updateTotalQueuedAfterRemoval(QueueingData qd)
          The common functionality required to manage the update of the total queued field.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

parent

protected final IaaSService parent
The IaaS for which this VM scheduler manages the VM requests.


queue

protected List<QueueingData> queue
The queue of the scheduler. This is intentionally made protected so subclasses could replace the list implementation to one that suits them better.


totalQueued

private AlterableResourceConstraints totalQueued
the amount of resources needed for fulfilling all VM requests in the queue


publicTQ

protected UnalterableConstraintsPropagator publicTQ
the public version of totalQueued that mirrors its contents but does not allow changes on it


orderedPMcache

private ArrayList<PhysicalMachine> orderedPMcache
This field contains an automatically updated list of all machines in the parent IaaS. The list is kept in the order of the PM's size to allow rapid decisions on the possible fitting of VM requests.


pmCacheLen

private int pmCacheLen
current length of the pm cache so we don't need to query its size all the time


queueListenerManager

private final StateDependentEventHandler<Scheduler.QueueingEvent,Integer> queueListenerManager
the manager of those objects who shown interest in receiving queuing related event notifications


minimumSchedulerRequirement

private ConstantConstraints minimumSchedulerRequirement
Here we keep an account of the amount of resources a particular scheduler would need before it would be able to schedule a new VM request


freeResourcesSinceLastSchedule

private AlterableResourceConstraints freeResourcesSinceLastSchedule
In this field the simulator maintains those recently freed up resources that could be allowing a new scheduling run


pmComparator

public static final Comparator<PhysicalMachine> pmComparator
A PM comparator that offers inverse ordering of PMs if used during sort


pmstateChanged

protected PhysicalMachine.StateChangeListener pmstateChanged
This is the action that takes place when one of the PMs at the IaaS changes its state. If this listener is called because a new PM has turned on then the scheduler is again given a chance to allocate some VMs. If there are some queued requests even after doing the scheduling then the queuelisteners are notified so they can improve the IaaS's infrastructure setup.


freeCapacity

protected VMManager.CapacityChangeEvent<ResourceConstraints> freeCapacity
This field represents the action to be done when some resources become free on one of the currently running PMs in the IaaS. If necessary this action invokes the scheduling and also notifies the queuing listeners about having a VM queue despite newly free resources.

Constructor Detail

Scheduler

public Scheduler(IaaSService parent)
The main constructor of all schedulers. This constructor ensures that the orderedPMcache is maintained and it also connects the scheduler's free capacity and pm state listeners.

Parameters:
parent - the IaaS service for which this scheduler is expected to act as the VM request scheduler
Method Detail

scheduleVMrequest

public final void scheduleVMrequest(VirtualMachine[] vms,
                                    ResourceConstraints rc,
                                    Repository vaSource,
                                    HashMap<String,Object> schedulingConstraints)
                             throws VMManager.VMManagementException
The main entry point to the schedulers. This function checks if a request could be possibly hosted on the IaaS's infrastructure, if so then it queues it. And if necessary it also invokes the actual scheduling operation implemented in the subclasses.

Parameters:
vms - the virtual machines that should be placed on the IaaS's machine set
rc - the resource requirements for the VMs
vaSource - the repository that stores the virtual appliance for the above VM set.
schedulingConstraints - custom data to be passed on to subclassed schedulers
Throws:
VMManager.VMManagementException - if the request is impossible to schedule on the current infrastructure

dropVMrequest

public final boolean dropVMrequest(VirtualMachine vm)
Cancels a VM request by dropping the corresponding queuing data from the scheduler's queue.

Parameters:
vm - the VM which is representing the queued request to be dropped from the queue
Returns:
true if the request was actually dropped, false otherwise.

getTotalQueued

public ResourceConstraints getTotalQueued()
The complete resource set required to fulfill the entirety of the VM requests in the queue

Returns:
the complete resource set

getQueueLength

public int getQueueLength()
The number of VM requests queued at the moment

Returns:
the length of the request queue

manageQueueRemoval

protected void manageQueueRemoval(QueueingData qd)
Removes an arbitrary item from the queue (could be a rather slow operation!)

Parameters:
qd - the item to be removed

manageQueueRemoval

protected QueueingData manageQueueRemoval()
Removes the head of the queue

Returns:
the queuing data object removed from the queue's head

updateTotalQueuedAfterRemoval

private void updateTotalQueuedAfterRemoval(QueueingData qd)
The common functionality required to manage the update of the total queued field.

Parameters:
qd - the removed queue member that needs to be deducted from the total queue field

subscribeQueueingEvents

public final void subscribeQueueingEvents(Scheduler.QueueingEvent e)
Allows third parties to get notified if the scheduler is not satisfied with the current infrastructure (e.g. because it cannot fit the current VM request set to the running PM set)

Parameters:
e - the object that will handle the notifications

unsubscribeQueueingEvents

public final void unsubscribeQueueingEvents(Scheduler.QueueingEvent e)
Cancels the notifications about queuing events

Parameters:
e - the object that no longer needs notifications

getQueuedVMs

public final List<VirtualMachine> getQueuedVMs()
Prepares a list of all the VMs that are queued at the particular moment in time

Returns:
the list of requested and not yet served VMs

invokeRealScheduler

private void invokeRealScheduler()
This function is actually calling the subclass's scheduler implementation and handles the management of minimum scheduler requirements and resets the free resource aggregate


scheduleQueued

protected abstract ConstantConstraints scheduleQueued()
When a new VM scheduler is created this is the function to be implemented. The function is expected to poll or the queue and only remove queued entities if they are placed on an actual PM. The removal is supported by the manageQueueRemoval function which allows both in order and out of order removals thus even allows prioritizing scheduler logic.

Returns:
the amount of free resources that the IaaS service needs to offer before this scheduler could actually proceed with its next VM placement.


Copyright © 2012–2015 University of Innsbruck & MTA SZTAKI. All rights reserved.