hu.mta.sztaki.lpds.cloud.simulator.iaas
Class IaaSService

java.lang.Object
  extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.IaaSService
All Implemented Interfaces:
PhysicalMachine.StateChangeListener, VMManager<IaaSService,PhysicalMachine>

public class IaaSService
extends Object
implements VMManager<IaaSService,PhysicalMachine>, PhysicalMachine.StateChangeListener

This class represents a single IaaS service. It's tasks are the maintenance and management of the physical machines and the scheduling of the VM requests among the PMs.

Author:
"Gabor Kecskemeti, Distributed and Parallel Systems Group, University of Innsbruck (c) 2013"

Nested Class Summary
static class IaaSService.IaaSHandlingException
          This class represents a generic error that occurred during the operation of the IaaS service.
 
Nested classes/interfaces inherited from interface hu.mta.sztaki.lpds.cloud.simulator.iaas.VMManager
VMManager.CapacityChangeEvent<F>, VMManager.NoSuchVMException, VMManager.VMManagementException
 
Field Summary
private  StateDependentEventHandler<VMManager.CapacityChangeEvent<PhysicalMachine>,List<PhysicalMachine>> capacityListenerManager
          event handler for capacity changes in terms of added/removed physical machines
private  ArrayList<PhysicalMachine> internalMachines
          The actual writable list of the machine set maintained behind this IaaSService WARNING: The order of internal machines is not guaranteed
private  ArrayList<Repository> internalRepositories
          The list of repositories under direct control of this IaaS service - this is for internal purposes the list is writeable The order of internal repositories is not guaranteed
private  ArrayList<PhysicalMachine> internalRunningMachines
          The actual writable list of the running machine set maintained behind this IaaSService WARNING: The order of internal running machines is not guaranteed
 List<PhysicalMachine> machines
          publicly available read only version of the internal machines field
 PhysicalMachineController pmcontroller
          the PM scheduler applied by this IaaSService object
private  ResourceConstraints publicRCap
          The capacity of the running machines to be reported externally.
private  ResourceConstraints publicTCap
          the total capacity to be reported for external users.
 List<Repository> repositories
          the read only list of all repositories in the system
private  AlterableResourceConstraints runningCapacity
          the capacity of the machines that are actually running in the system - this is for internal use only again
 List<PhysicalMachine> runningMachines
          publicly available read only version of the internal running machines field
 Scheduler sched
          the VM scheduler applied by this IaaSservice object
private  AlterableResourceConstraints totalCapacity
          the total capacity of all machines in this iaas service, for use only internally in the IaaS service class
 
Constructor Summary
IaaSService(Class<? extends Scheduler> s, Class<? extends PhysicalMachineController> c)
          Constructs an IaaS service object directly.
 
Method Summary
 void bulkHostRegistration(List<PhysicalMachine> newPMs)
          This function allows rapid registration of several PMs
private  PhysicalMachine checkVMHost(VirtualMachine vm)
          Determines if the VM is hosted locally in one of the physical machines of this IaaSServie
 void deregisterHost(PhysicalMachine pm)
          This function allows the IaaS to reduce in size.
 void deregisterRepository(Repository r)
          This function allows the IaaS to reduce its storage capacities.
 ResourceConstraints getCapacities()
          returns with the total capacities of this service (cumulative value for all its PMs)
 ResourceConstraints getRunningCapacities()
          returns with the total running capacities of this service (cumulative value for all its PMs that are in a running state)
 boolean isRegisteredHost(PhysicalMachine pm)
          A function to determine if a host is within the premises of this IaaSService.
 Collection<VirtualMachine> listVMs()
          lists all VMs running or requested (and queued at a VM scheduler) from the IaaSservice
 void migrateVM(VirtualMachine vm, IaaSService target)
          Not implemented! Will allow migrating VMs across IaaSServices.
private  void realDeregistration(PhysicalMachine pm)
          Really deregisters a PM from the list of PMs.
 void reallocateResources(VirtualMachine vm, ResourceConstraints newresources)
          NOT IMPLEMENTED! Reallocates the VM's resources according to the newresources on the host of the VM.
 void registerHost(PhysicalMachine pm)
          This function allows the IaaS to grow in size with a single PM
 void registerRepository(Repository r)
          This function allows the IaaS to grow its storage capacities
 VirtualMachine[] requestVM(VirtualAppliance va, ResourceConstraints rc, Repository vaSource, int count)
          Allows the request of multiple VMs without propagating any scheduling constraints.
 VirtualMachine[] requestVM(VirtualAppliance va, ResourceConstraints rc, Repository vaSource, int count, HashMap<String,Object> schedulingConstraints)
          Allows the request of multiple VMs.
 void stateChanged(PhysicalMachine pm, PhysicalMachine.State oldState, PhysicalMachine.State newState)
          Implements the PhysicalMachine's state change listener to manage the internalRunningMachines list.
 void subscribeToCapacityChanges(VMManager.CapacityChangeEvent<PhysicalMachine> e)
          get notified about capacity changes (PM additions/removals) This call is propagated to StateDependentEventHandler.
 void terminateVM(VirtualMachine vm, boolean killTasks)
          Requesting the destruction of a VM in a DESTROYED state will dequeue the VM from the scheduler's request queue.
 String toString()
          Provides a convenient way to debug the IaaS.
 void unsubscribeFromCapacityChanges(VMManager.CapacityChangeEvent<PhysicalMachine> e)
          cancel the notifications about capacity changes (PM additions/removals) This call is propagated to StateDependentEventHandler.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

internalMachines

private final ArrayList<PhysicalMachine> internalMachines
The actual writable list of the machine set maintained behind this IaaSService WARNING: The order of internal machines is not guaranteed


internalRunningMachines

private final ArrayList<PhysicalMachine> internalRunningMachines
The actual writable list of the running machine set maintained behind this IaaSService WARNING: The order of internal running machines is not guaranteed


machines

public final List<PhysicalMachine> machines
publicly available read only version of the internal machines field


runningMachines

public final List<PhysicalMachine> runningMachines
publicly available read only version of the internal running machines field


totalCapacity

private AlterableResourceConstraints totalCapacity
the total capacity of all machines in this iaas service, for use only internally in the IaaS service class


publicTCap

private ResourceConstraints publicTCap
the total capacity to be reported for external users. This field propagates the totalCapacity field. Keep in mind that the capacity reported by this field could change without notification.


runningCapacity

private AlterableResourceConstraints runningCapacity
the capacity of the machines that are actually running in the system - this is for internal use only again


publicRCap

private ResourceConstraints publicRCap
The capacity of the running machines to be reported externally. This is implemented with a propagator thus changes in runningcapacity will be immediately reflected here as well without notification.


capacityListenerManager

private final StateDependentEventHandler<VMManager.CapacityChangeEvent<PhysicalMachine>,List<PhysicalMachine>> capacityListenerManager
event handler for capacity changes in terms of added/removed physical machines


internalRepositories

private final ArrayList<Repository> internalRepositories
The list of repositories under direct control of this IaaS service - this is for internal purposes the list is writeable The order of internal repositories is not guaranteed


repositories

public final List<Repository> repositories
the read only list of all repositories in the system


sched

public final Scheduler sched
the VM scheduler applied by this IaaSservice object


pmcontroller

public final PhysicalMachineController pmcontroller
the PM scheduler applied by this IaaSService object

Constructor Detail

IaaSService

public IaaSService(Class<? extends Scheduler> s,
                   Class<? extends PhysicalMachineController> c)
            throws InstantiationException,
                   IllegalAccessException,
                   IllegalArgumentException,
                   InvocationTargetException,
                   NoSuchMethodException,
                   SecurityException
Constructs an IaaS service object directly. The VM and PM schedulers for this IaaS service will be created during the creation of the IaaSService itself. This ensures that users cannot alter the link between the IaaSService and the various schedulers. The exceptions are thrown because reflection is used to create the scheduler objects.

Parameters:
s - class of the VM scheduler to be used
c - class of the PM scheduler to be used
Throws:
InstantiationException
IllegalAccessException
IllegalArgumentException
InvocationTargetException
NoSuchMethodException
SecurityException
Method Detail

migrateVM

public void migrateVM(VirtualMachine vm,
                      IaaSService target)
Not implemented! Will allow migrating VMs across IaaSServices.

Specified by:
migrateVM in interface VMManager<IaaSService,PhysicalMachine>
Parameters:
vm - the VM to be relocated
target - the target system that should host the VM in the future

checkVMHost

private PhysicalMachine checkVMHost(VirtualMachine vm)
                             throws VMManager.NoSuchVMException
Determines if the VM is hosted locally in one of the physical machines of this IaaSServie

Parameters:
vm - the VM to be checked
Returns:
the PM that hosts the VM
Throws:
NoSuchVMException - if the VM is not hosted by any of the PMs in the system
VMManager.NoSuchVMException

reallocateResources

public void reallocateResources(VirtualMachine vm,
                                ResourceConstraints newresources)
                         throws VMManager.NoSuchVMException,
                                VMManager.VMManagementException
NOT IMPLEMENTED! Reallocates the VM's resources according to the newresources on the host of the VM.

Specified by:
reallocateResources in interface VMManager<IaaSService,PhysicalMachine>
Parameters:
vm - The VM to be adjusted
newresources - The new amount of resources needed (this could not only raise the available resources of the VM but also decrease them
Throws:
VMManager.NoSuchVMException - if the request was issued for a VM unknown in the system
VMManager.VMManagementException - if the request cannot be fulfilled for some reason

requestVM

public VirtualMachine[] requestVM(VirtualAppliance va,
                                  ResourceConstraints rc,
                                  Repository vaSource,
                                  int count)
                           throws VMManager.VMManagementException,
                                  NetworkNode.NetworkException
Allows the request of multiple VMs without propagating any scheduling constraints.

Parameters:
va - the VA to be used as the disk of the VM
rc - the resource requirements of the future VM
vaSource - the repository that currently stores the VA
count - the number of VMs that this request should be returning with
Returns:
the list of VMs created by the call (please note the VMs returned might never actually get running, if the PMs are always blocked by some other activities, or if they go to NONSERVABLE state)
Throws:
VMManagementException - if there are no pms that could run the VMs. or if the request is too big to be hosted across the complete infrastructure
NetworkNode.NetworkException - if there are network connectivity problems within the infrastructure
VMManager.VMManagementException

requestVM

public VirtualMachine[] requestVM(VirtualAppliance va,
                                  ResourceConstraints rc,
                                  Repository vaSource,
                                  int count,
                                  HashMap<String,Object> schedulingConstraints)
                           throws VMManager.VMManagementException,
                                  NetworkNode.NetworkException
Allows the request of multiple VMs.

Specified by:
requestVM in interface VMManager<IaaSService,PhysicalMachine>
Parameters:
va - the VA to be used as the disk of the VM
rc - the resource requirements of the future VM
vaSource - the repository that currently stores the VA
count - the number of VMs that this request should be returning with
schedulingConstraints - The VM scheduler dependent additional requirements for the newly requested VMs (e.g. please go for a specific host etc.) For understanding what you can send here please have a look at the documentation of the particular VM scheduler in question.
Returns:
the list of VMs created by the call (please note the VMs returned might never actually get running, if the PMs are always blocked by some other activities, or if they go to NONSERVABLE state)
Throws:
VMManagementException - if there are no pms that could run the VMs. or if the request is too big to be hosted across the complete infrastructure
NetworkNode.NetworkException - if there are network connectivity problems within the infrastructure
VMManager.VMManagementException

terminateVM

public void terminateVM(VirtualMachine vm,
                        boolean killTasks)
                 throws VMManager.NoSuchVMException,
                        VMManager.VMManagementException
Requesting the destruction of a VM in a DESTROYED state will dequeue the VM from the scheduler's request queue. If the VM was not requested from this IaaSService then a nosuchvmexception is thrown.

Specified by:
terminateVM in interface VMManager<IaaSService,PhysicalMachine>
Parameters:
vm - the VM to be terminated
Throws:
VMManager.NoSuchVMException - if the request was issued for a VM unknown in the system
VMManager.VMManagementException - if the request cannot be fulfilled for some reason

listVMs

public Collection<VirtualMachine> listVMs()
lists all VMs running or requested (and queued at a VM scheduler) from the IaaSservice

Specified by:
listVMs in interface VMManager<IaaSService,PhysicalMachine>
Returns:
the VMs currently registered with the system (they are either alredy running or will run in the foreseeable future

registerHost

public void registerHost(PhysicalMachine pm)
This function allows the IaaS to grow in size with a single PM

Parameters:
pm - the new physical machine to be utilized within the system

bulkHostRegistration

public void bulkHostRegistration(List<PhysicalMachine> newPMs)
This function allows rapid registration of several PMs

Parameters:
newPMs - the list of PMs to be registered

realDeregistration

private void realDeregistration(PhysicalMachine pm)
Really deregisters a PM from the list of PMs.

Parameters:
pm - the PM to be deregistered

deregisterHost

public void deregisterHost(PhysicalMachine pm)
                    throws IaaSService.IaaSHandlingException
This function allows the IaaS to reduce in size.
This function might migrate VMs from the deregistered host to ones remaining in the system. If the deregistered host contains VMs that cannot be migrated, or there is nowhere to migrate the VMs then the function throws an exception. Currently there is no migration implemented!

Parameters:
pm - the physical machine to be dropped from the control of the system
Throws:
IaaSService.IaaSHandlingException

registerRepository

public void registerRepository(Repository r)
This function allows the IaaS to grow its storage capacities

Parameters:
r - the new repository to be utilized within the system

deregisterRepository

public void deregisterRepository(Repository r)
                          throws IaaSService.IaaSHandlingException
This function allows the IaaS to reduce its storage capacities. This function might transfer contents from the deregistered repository to ones remaining in the system. If the deregistered repository contains storage objects that cannot be transferred, or there is nowhere to transfer a few storage objects then the function throws an exception. Currently there is no transfer implemented!

Parameters:
r - the repository to be dropped from the control of the system
Throws:
IaaSService.IaaSHandlingException

getCapacities

public ResourceConstraints getCapacities()
returns with the total capacities of this service (cumulative value for all its PMs)

Specified by:
getCapacities in interface VMManager<IaaSService,PhysicalMachine>
Returns:
the total computing capacities of this VMManager

getRunningCapacities

public ResourceConstraints getRunningCapacities()
returns with the total running capacities of this service (cumulative value for all its PMs that are in a running state)


subscribeToCapacityChanges

public void subscribeToCapacityChanges(VMManager.CapacityChangeEvent<PhysicalMachine> e)
get notified about capacity changes (PM additions/removals) This call is propagated to StateDependentEventHandler.

Specified by:
subscribeToCapacityChanges in interface VMManager<IaaSService,PhysicalMachine>
Parameters:
e - the listener object which expects capacity change events

unsubscribeFromCapacityChanges

public void unsubscribeFromCapacityChanges(VMManager.CapacityChangeEvent<PhysicalMachine> e)
cancel the notifications about capacity changes (PM additions/removals) This call is propagated to StateDependentEventHandler.

Specified by:
unsubscribeFromCapacityChanges in interface VMManager<IaaSService,PhysicalMachine>
Parameters:
e - the listener object that no longer expects capacity change events

isRegisteredHost

public boolean isRegisteredHost(PhysicalMachine pm)
A function to determine if a host is within the premises of this IaaSService.

Parameters:
pm - the host in question
Returns:
  • true if the host is part of the IaaS
  • false otherwise

toString

public String toString()
Provides a convenient way to debug the IaaS.

Overrides:
toString in class Object

stateChanged

public void stateChanged(PhysicalMachine pm,
                         PhysicalMachine.State oldState,
                         PhysicalMachine.State newState)
Implements the PhysicalMachine's state change listener to manage the internalRunningMachines list.

Specified by:
stateChanged in interface PhysicalMachine.StateChangeListener
Parameters:
pm - the physical machine that is involved in the state change
oldState - the state the PM was in before this state change event was delivered
newState - the new state the PM will be in after the event is complete


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