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

java.lang.Object
  extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
      extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.MaxMinFairSpreader
          extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.MaxMinProvider
              extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.PhysicalMachine
All Implemented Interfaces:
VMManager<PhysicalMachine,ResourceConstraints>

public class PhysicalMachine
extends MaxMinProvider
implements VMManager<PhysicalMachine,ResourceConstraints>

This class represents a single Physical machine with computing resources as well as local disks and network connections. The PM is a central part of the infrastructure simulation, it allows VM management, direct access to its resources and also provides several power management operations (like switch off/on).

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

Nested Class Summary
 class PhysicalMachine.PowerStateDelayer
          This class handles the delays and activites during the power state change procedures (e.g., switching off/turning on)
static class PhysicalMachine.PowerStateKind
          When defining powertransitions for the PM one has to label each transiton's properties with a kind
 class PhysicalMachine.ResourceAllocation
          This class is strongly connected with the physical machine's class, the two are collaborating to allow a fluid and minimal hassle operation of allocating resources on a PM.
static class PhysicalMachine.State
          Represents the possible states of the physical machines modeled in the system
static interface PhysicalMachine.StateChangeListener
          Defines the minimal interface for listeners on PM state changes.
 
Nested classes/interfaces inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
ResourceSpreader.FreqSyncer
 
Nested classes/interfaces inherited from interface hu.mta.sztaki.lpds.cloud.simulator.iaas.VMManager
VMManager.CapacityChangeEvent<F>, VMManager.NoSuchVMException, VMManager.VMManagementException
 
Field Summary
 UnalterableConstraintsPropagator availableCapacities
          This is the publicly disclosed set of those resources that are not having a VM running on them.
private  long completedVMs
          the number of VMs that were using resources from this PM at any time of the PM's existence
private  PhysicalMachine.State currentState
          The current state of the PM
static int defaultAllocLen
          This is the default length for how long a resource allocation will be kept before it becomes invalid.
 MaxMinConsumer directConsumer
          This consumer is added to the PM help simulate the pure (VM less) operations on the PM.
private  boolean directConsumerUsageMoratory
          shows when the PM's direct consumer cannot be used as a consumer for tasks (in general it is only usable for external users when the PM is running)
 UnalterableConstraintsPropagator freeCapacities
          This is the publicly disclosed set of those resources that are not even having an allocation.
private  EnumMap<PhysicalMachine.State,PowerState> hostPowerBehavior
          Mapping between the various PM states and its representative CPU/memory power behaviors.
private  StateDependentEventHandler<VMManager.CapacityChangeEvent<ResourceConstraints>,List<ResourceConstraints>> increasingFreeCapacityListenerManager
          this notification handler is used to send out events when some of the PM's resources are getting available for others to use
private  AlterableResourceConstraints internalAvailableCaps
          the resource set that does not have a VM running on it avaiableCapacities = freeCapacities + promisedCapacities
private  AlterableResourceConstraints internalReallyFreeCaps
          the amount of resources that are not running a VM or not allocated by some resource allocation
 Repository localDisk
          the internal disk of the physical machine.
static int migrationAllocLen
          This is the recommended length for how long a resource allocation will be kept before it becomes invalid in case the allocation is made for a VM migration.
private  EnumMap<PhysicalMachine.State,PowerState> networkPowerBehavior
          Mapping between the various PM states and its representative network power behaviors.
private  long offDelayEstimate
          around how many ticks the PM is estimated to run the tasks in the offTransition array.
private  double[] offTransition
          the tasks to do when switching the PM off.
private  long onDelayEstimate
          around how many ticks the PM is estimated to run the tasks in the onTransition array.
private  PhysicalMachine.PowerStateDelayer onOffEvent
          The currently operating state change handler - this field actually shows if a state change is on the way.
private  double[] onTransition
          the tasks to do when turning the PM on.
private  int promisedAllocationsCount
          the amount of resource allocations in the promisedResources array.
private  AlterableResourceConstraints promisedCapacities
          the amount of resources currently allocated but that have no VM assigned to them
private  PhysicalMachine.ResourceAllocation[] promisedResources
          this is the array of resource allocations which contain all not yet used/expired resource allocations.
 Set<VirtualMachine> publicVms
          the publicly available, read only set of currently running virtual machines on this PM
static double smallUtilization
          Amount of processing to be done if the PM need to be underutilized.
private  StateDependentEventHandler<PhysicalMachine.StateChangeListener,org.apache.commons.lang3.tuple.Pair<PhysicalMachine.State,PhysicalMachine.State>> stateListenerManager
          the manager of the PM's state change notifications.
static EnumSet<PhysicalMachine.State> StatesOfHighEnergyConsumption
          This is the list of PM states that mostly consume energy
private  EnumMap<PhysicalMachine.State,PowerState> storagePowerBehavior
          Mapping between the various PM states and its representative disk power behaviors.
static EnumSet<PhysicalMachine.State> ToOfforOff
          These are the PM states which are either leading to off or already off.
static EnumSet<PhysicalMachine.State> ToOnorRunning
          These are the PM states which are either leading to running or already running.
private  ConstantConstraints totalCapacities
          the complete resouce set of the pm
private  HashSet<VirtualMachine> vms
          the set of currently running virtual machines on this PM
 
Fields inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
lastNotifTime, negligableProcessing, perTickProcessingPower, toBeAdded, toBeRemoved, underProcessing
 
Constructor Summary
PhysicalMachine(double cores, double perCorePocessing, long memory, Repository disk, double[] turnonOperations, double[] switchoffOperations, EnumMap<PhysicalMachine.PowerStateKind,EnumMap<PhysicalMachine.State,PowerState>> powerTransitions)
          Defines a new physical machine, ensures that there are no VMs running so far
PhysicalMachine(double cores, double perCorePocessing, long memory, Repository disk, int onD, int offD, EnumMap<PhysicalMachine.PowerStateKind,EnumMap<PhysicalMachine.State,PowerState>> powerTransitions)
          Defines a new physical machine, ensures that there are no VMs running so far
 
Method Summary
private  void actualSwitchOff()
          does the actual switchoff, expected to be run only when there are no VMs running on the PM
 PhysicalMachine.ResourceAllocation allocateResources(ResourceConstraints requested, boolean strict, int allocationValidityLength)
          Ensures the requested amount of resources are going to be available in the foreseeable future on this physical machine.
 boolean cancelAllocation(PhysicalMachine.ResourceAllocation allocation)
          Terminate a resource allocation through the PM's interfaces
private  boolean checkAllocationsPresence(PhysicalMachine.ResourceAllocation allocation)
          check if a particular resource allocation is really issued by this pm.
 void deployVM(VirtualMachine vm, PhysicalMachine.ResourceAllocation ra, Repository vaSource)
          Bounds a VM to a particular PM on a previously agreed allocation
 ResourceConstraints getCapacities()
          collects the total resource capacity of the PM
 long getCompletedVMs()
          gets the number of VMs that have already left the PM but that were running on it once
 long getCurrentOnOffDelay()
          Gets an estimate for the duration (in ticks) of the poweron/off operation in progress.
 PhysicalMachine.State getState()
          retrieves the current state of the PM
protected  boolean isAcceptableConsumption(ResourceConsumption con)
          Determines if a resource consumption (i.e., a compute task utilizing the CPU of the PM) can be registered on the PM for execution.
 boolean isDirectConsumerUsageMoratory()
          determines if the direct consumer accepts compute tasks to be registered
 boolean isHostableRequest(ResourceConstraints requested)
          checks if at least in theory the requested resources could be hosted on the PM (i.e., when there are no other VMs hosted on the PM).
 boolean isHostingVMs()
          determines if there are any VMs on the PM or not.
 boolean isRunning()
          Determines if the machine can be used for VM instantiation.
 Collection<VirtualMachine> listVMs()
          a method to query the currently running VMs (this can also be accessed through the public field of publicVms).
 void migrateVM(VirtualMachine vm, PhysicalMachine target)
          Initiates the migration of a VM to another PM.
 int numofCurrentVMs()
          a method to determine the number of VMs currently hosted by the PM.
private  long prepareTransitionalTasks(boolean on, double[] array)
          Makes a copy of the given array to the correct target (on/offTransition), and calculates the estimates for the on/offDelay
 void reallocateResources(VirtualMachine vm, ResourceConstraints newresources)
          Not implemented, would allow VMs to receive more resources in the future
 VirtualMachine[] requestVM(VirtualAppliance va, ResourceConstraints rc, Repository vaSource, int count)
          Initiates a VM on this physical machine.
 VirtualMachine[] requestVM(VirtualAppliance va, ResourceConstraints rc, Repository vaSource, int count, HashMap<String,Object> schedulingConstraints)
          Requests a few VMs just as before.
private  void setState(PhysicalMachine.State newState)
          manages the state change operation of the PM.
 void subscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)
          manages the subscriptions for state change events
 void subscribeToCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
          not implemented
 void subscribeToIncreasingFreeapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
          manages the subscriptions for free capacity events (i.e.
 boolean switchoff(PhysicalMachine migrateHere)
          Starts the turn off procedure for the physical machine so it no longer accepts VM requests but it does not consume anymore
 void terminateVM(VirtualMachine vm, boolean killTasks)
          Switches off the VM in question if the VM is hosted by this particular PM.
 String toString()
          offers a nice single line format summary of the properties of this PM - good for debugging and tracing.
 void turnon()
          Turns on the physical machine so it allows energy and resource consumption (i.e.
 void unsubscribeFromCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
          not implemented
 void unsubscribeFromIncreasingFreeCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
          manages the subscriptions for free capacity events (i.e.
 void unsubscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)
          manages the subscriptions for state change events
 
Methods inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.MaxMinProvider
getCounterPart, getSamePart, isConsumer, processSingleConsumption, updateConsumptionLimit
 
Methods inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.MaxMinFairSpreader
singleGroupwiseFreqUpdater
 
Methods inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
getCurrentPowerBehavior, getPerTickProcessingPower, getSyncer, getTotalProcessed, hashCode, removeTheseConsumptions, setCurrentPowerBehavior, setPerTickProcessingPower, subscribePowerBehaviorChangeEvents, unsubscribePowerBehaviorChangeEvents
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

defaultAllocLen

public static final int defaultAllocLen
This is the default length for how long a resource allocation will be kept before it becomes invalid. It is specified in ticks.

See Also:
Constant Field Values

migrationAllocLen

public static final int migrationAllocLen
This is the recommended length for how long a resource allocation will be kept before it becomes invalid in case the allocation is made for a VM migration. It is specified in ticks.

See Also:
Constant Field Values

smallUtilization

public static final double smallUtilization
Amount of processing to be done if the PM need to be underutilized. This constant is used for calculating the emulation of on and off operations if they are specified with single delays in the PM's constructor.

See Also:
Constant Field Values

ToOnorRunning

public static final EnumSet<PhysicalMachine.State> ToOnorRunning
These are the PM states which are either leading to running or already running.


ToOfforOff

public static final EnumSet<PhysicalMachine.State> ToOfforOff
These are the PM states which are either leading to off or already off.


StatesOfHighEnergyConsumption

public static final EnumSet<PhysicalMachine.State> StatesOfHighEnergyConsumption
This is the list of PM states that mostly consume energy


totalCapacities

private final ConstantConstraints totalCapacities
the complete resouce set of the pm


internalAvailableCaps

private final AlterableResourceConstraints internalAvailableCaps
the resource set that does not have a VM running on it avaiableCapacities = freeCapacities + promisedCapacities


availableCapacities

public final UnalterableConstraintsPropagator availableCapacities
This is the publicly disclosed set of those resources that are not having a VM running on them. This field is read only! This field can automatically update between two checks! If you need unaltered data please make a copy (e.g., new ConstantConstraints(pm.freeCapacities)).


promisedCapacities

private AlterableResourceConstraints promisedCapacities
the amount of resources currently allocated but that have no VM assigned to them


internalReallyFreeCaps

private final AlterableResourceConstraints internalReallyFreeCaps
the amount of resources that are not running a VM or not allocated by some resource allocation


freeCapacities

public final UnalterableConstraintsPropagator freeCapacities
This is the publicly disclosed set of those resources that are not even having an allocation. This field is read only! This field can automatically update between two checks! If you need unaltered data please make a copy (e.g., new ConstantConstraints(pm.freeCapacities)).


localDisk

public final Repository localDisk
the internal disk of the physical machine. this field is also used to represent the PM's network connections as the disk is represented with the repository interface.


promisedResources

private PhysicalMachine.ResourceAllocation[] promisedResources
this is the array of resource allocations which contain all not yet used/expired resource allocations. This array might contain null values in between two resourceallocation objects.


promisedAllocationsCount

private int promisedAllocationsCount
the amount of resource allocations in the promisedResources array.


currentState

private PhysicalMachine.State currentState
The current state of the PM


onTransition

private final double[] onTransition
the tasks to do when turning the PM on. The format of the array is documented in the powerstatedelayer class.


offTransition

private final double[] offTransition
the tasks to do when switching the PM off. The format of the array is documented in the powerstatedelayer class.


onDelayEstimate

private final long onDelayEstimate
around how many ticks the PM is estimated to run the tasks in the onTransition array.


offDelayEstimate

private final long offDelayEstimate
around how many ticks the PM is estimated to run the tasks in the offTransition array.


hostPowerBehavior

private final EnumMap<PhysicalMachine.State,PowerState> hostPowerBehavior
Mapping between the various PM states and its representative CPU/memory power behaviors.


storagePowerBehavior

private final EnumMap<PhysicalMachine.State,PowerState> storagePowerBehavior
Mapping between the various PM states and its representative disk power behaviors.


networkPowerBehavior

private final EnumMap<PhysicalMachine.State,PowerState> networkPowerBehavior
Mapping between the various PM states and its representative network power behaviors.


stateListenerManager

private final StateDependentEventHandler<PhysicalMachine.StateChangeListener,org.apache.commons.lang3.tuple.Pair<PhysicalMachine.State,PhysicalMachine.State>> stateListenerManager
the manager of the PM's state change notifications.


vms

private final HashSet<VirtualMachine> vms
the set of currently running virtual machines on this PM


publicVms

public final Set<VirtualMachine> publicVms
the publicly available, read only set of currently running virtual machines on this PM


completedVMs

private long completedVMs
the number of VMs that were using resources from this PM at any time of the PM's existence


onOffEvent

private PhysicalMachine.PowerStateDelayer onOffEvent
The currently operating state change handler - this field actually shows if a state change is on the way. in order to be really consistent, the field is directly managed by the powerstatedelayer class.


increasingFreeCapacityListenerManager

private final StateDependentEventHandler<VMManager.CapacityChangeEvent<ResourceConstraints>,List<ResourceConstraints>> increasingFreeCapacityListenerManager
this notification handler is used to send out events when some of the PM's resources are getting available for others to use


directConsumer

public final MaxMinConsumer directConsumer
This consumer is added to the PM help simulate the pure (VM less) operations on the PM. E.g., the VMM's operations can be resourceconsumptions registered between this consumer and the PM.


directConsumerUsageMoratory

private boolean directConsumerUsageMoratory
shows when the PM's direct consumer cannot be used as a consumer for tasks (in general it is only usable for external users when the PM is running)

Constructor Detail

PhysicalMachine

public PhysicalMachine(double cores,
                       double perCorePocessing,
                       long memory,
                       Repository disk,
                       int onD,
                       int offD,
                       EnumMap<PhysicalMachine.PowerStateKind,EnumMap<PhysicalMachine.State,PowerState>> powerTransitions)
Defines a new physical machine, ensures that there are no VMs running so far

Parameters:
cores - defines the number of CPU cores this machine has under control
perCorePocessing - defines the processing capabilities of a single CPU core in this machine (in instructions/tick)
memory - defines the total physical memory this machine has under control (in bytes)
disk - defines the local physical disk & networking this machine has under control
onD - defines the time delay between the machine's switch on and the first time it can serve VM requests
offD - defines the time delay the machine needs to shut down all of its operations while it does not serve any more VMs
powerTransitions - determines the applied power state transitions while the physical machine state changes. This is the principal way to alter a PM's energy consumption behavior.

PhysicalMachine

public PhysicalMachine(double cores,
                       double perCorePocessing,
                       long memory,
                       Repository disk,
                       double[] turnonOperations,
                       double[] switchoffOperations,
                       EnumMap<PhysicalMachine.PowerStateKind,EnumMap<PhysicalMachine.State,PowerState>> powerTransitions)
Defines a new physical machine, ensures that there are no VMs running so far

Parameters:
cores - defines the number of CPU cores this machine has under control
perCorePocessing - defines the processing capabilities of a single CPU core in this machine (in instructions/tick)
memory - defines the total physical memory this machine has under control (in bytes)
disk - defines the local physical disk & networking this machine has under control
turnonOperations - defines the tasks to execute before the PM can be turned on - this can be considered as the simulation of the boot process. for the complete definition of this array have a look at the powerstatedelayer class.
switchoffOperations - defines the tasks to execute before the PM can be switched off - this can be considered as the simulation of the shutdown process. for the complete definition of this array have a look at the powerstatedelayer class.
powerTransitions - determines the applied power state transitions while the physical machine state changes. This is the principal way to alter a PM's energy consumption behavior.
Method Detail

prepareTransitionalTasks

private long prepareTransitionalTasks(boolean on,
                                      double[] array)
Makes a copy of the given array to the correct target (on/offTransition), and calculates the estimates for the on/offDelay

Parameters:
on - which taskset needs to be prepared
array - the task array - for format see powerstatedelayer
Returns:
the estimated runtime of all tasks in the array

switchoff

public boolean switchoff(PhysicalMachine migrateHere)
                  throws VMManager.VMManagementException,
                         NetworkNode.NetworkException
Starts the turn off procedure for the physical machine so it no longer accepts VM requests but it does not consume anymore

Parameters:
migrateHere - the physical machine where the currently hosted VMs of this VM should go before the actual switch off operation will happen
Returns:
  • true if the switch off procedure has started
  • false if there are still VMs running and migration target was not specified thus the switch off is not possible
Throws:
NetworkNode.NetworkException - if the migration would need to use network connections that are not set up correctly.
VMManager.VMManagementException - if the migration fails because the VM is not in correct state or the PM does not have enough storage for the memory/disk state

actualSwitchOff

private void actualSwitchOff()
does the actual switchoff, expected to be run only when there are no VMs running on the PM


isRunning

public boolean isRunning()
Determines if the machine can be used for VM instantiation.

Returns:
  • true if the machine is ready to accept VM requests
  • false otherwise

getState

public PhysicalMachine.State getState()
retrieves the current state of the PM

Returns:
the current state

turnon

public void turnon()
Turns on the physical machine so it allows energy and resource consumption (i.e. compute tasks) and opens the possibility to receive VM requests.


migrateVM

public void migrateVM(VirtualMachine vm,
                      PhysicalMachine target)
               throws VMManager.VMManagementException,
                      NetworkNode.NetworkException
Initiates the migration of a VM to another PM.

Specified by:
migrateVM in interface VMManager<PhysicalMachine,ResourceConstraints>
Parameters:
vm - the VM to be migrated
target - the PM to be used by the VM after the migration completes
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
NetworkNode.NetworkException

reallocateResources

public void reallocateResources(VirtualMachine vm,
                                ResourceConstraints newresources)
Not implemented, would allow VMs to receive more resources in the future

Specified by:
reallocateResources in interface VMManager<PhysicalMachine,ResourceConstraints>
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

allocateResources

public PhysicalMachine.ResourceAllocation allocateResources(ResourceConstraints requested,
                                                            boolean strict,
                                                            int allocationValidityLength)
                                                     throws VMManager.VMManagementException
Ensures the requested amount of resources are going to be available in the foreseeable future on this physical machine.

Parameters:
requested - The amount of resources needed by the caller
strict - if the PM should not return an allocation if it cannot completely meet the request.
allocationValidityLength - for how long the PM should keep the allocation in place. Depending on the purpose of the allocation, it is recommended to use either the defaultAllocLen or the migrationAllocLen constants of the PM for this field.
Returns:
With a time limited offer on the requested resources. If the requested resourceconstraints cannot be met by the function then it returns with the maximum amount of resources it can serve. If there are no available resources it returns with null! If the requested resources can be exactly met then the original requested resourceconstraints object is stored in the returned resource allocation. If the resourceconstraints only specified a minimum resource limit, then a new resourceconstraints object is returned with details of the maximum possible resource constraints that can fit into the machine.
Throws:
VMManager.VMManagementException

checkAllocationsPresence

private boolean checkAllocationsPresence(PhysicalMachine.ResourceAllocation allocation)
check if a particular resource allocation is really issued by this pm.

Parameters:
allocation - the untrusted allocation
Returns:
  • true if the PM issued the allocation
  • false otherwise

cancelAllocation

public boolean cancelAllocation(PhysicalMachine.ResourceAllocation allocation)
Terminate a resource allocation through the PM's interfaces

Parameters:
allocation - the resource allocation to terminate
Returns:
  • true if the allocation was cancelled
  • false otherwise

isHostableRequest

public boolean isHostableRequest(ResourceConstraints requested)
checks if at least in theory the requested resources could be hosted on the PM (i.e., when there are no other VMs hosted on the PM).

Parameters:
requested - the resource set to be checked for hostability
Returns:
  • true if the such resource request has a chance of acceptance
  • false otherwise

deployVM

public void deployVM(VirtualMachine vm,
                     PhysicalMachine.ResourceAllocation ra,
                     Repository vaSource)
              throws VMManager.VMManagementException,
                     NetworkNode.NetworkException
Bounds a VM to a particular PM on a previously agreed allocation

Parameters:
vm - the VM to be deployed on the PM
ra - the resource allocation to be uesed for the VM
vaSource - the repository that stores the virtual appliance of the VM
Throws:
VMManagementException - if the VA is not present on the source, or if the allocation specified is already expired/used, or if the VM cannot be switched on for some reason
NetworkNode.NetworkException - if the VA is not transferrable from the vaSource to its destination
VMManager.VMManagementException

requestVM

public VirtualMachine[] requestVM(VirtualAppliance va,
                                  ResourceConstraints rc,
                                  Repository vaSource,
                                  int count)
                           throws VMManager.VMManagementException,
                                  NetworkNode.NetworkException
Initiates a VM on this physical machine. If the physical machine cannot host VMs for some reason an exception is thrown, if the machine cannot host this particular VA then a null VM is returned.

Parameters:
va - The appliance for the VM to be created.
rc - The resource requirements of the VM
vaSource - The storage where the VA resides.
count - The number of VMs to be created with the above specification
Returns:
The virtual machine(s) that will be instantiated on the PM. Null if the constraints specify VMs that cannot fit the available resources of the machine.
Throws:
VMManagementException - If the machine is not accepting requests currently.
If the VM startup has failed.
VMManager.VMManagementException
NetworkNode.NetworkException

requestVM

public VirtualMachine[] requestVM(VirtualAppliance va,
                                  ResourceConstraints rc,
                                  Repository vaSource,
                                  int count,
                                  HashMap<String,Object> schedulingConstraints)
                           throws VMManager.VMManagementException,
                                  NetworkNode.NetworkException
Requests a few VMs just as before. Scheduling constraints are ignored currently! As this is too low level to handle them in the current state of the simulator.

Specified by:
requestVM in interface VMManager<PhysicalMachine,ResourceConstraints>
Parameters:
va - the kind of VM to be created
Returns:
the new VM
Throws:
VMManager.VMManagementException - if the request cannot be fulfilled for some reason
NetworkNode.NetworkException

terminateVM

public void terminateVM(VirtualMachine vm,
                        boolean killTasks)
                 throws VMManager.NoSuchVMException,
                        VMManager.VMManagementException
Switches off the VM in question if the VM is hosted by this particular PM.

Specified by:
terminateVM in interface VMManager<PhysicalMachine,ResourceConstraints>
Parameters:
vm - to be switched off
killTasks - if the VM must be switched off without caring about its tasks then this should be true. if this is false, then the VM can only be instructed to be switched off if there are no tasks currently running on it.
Throws:
NoSuchVMException - if the VM is not hosted on this PM
VMManagementException - if the VM is not in a state to be switched off
VMManager.NoSuchVMException
VMManager.VMManagementException

listVMs

public Collection<VirtualMachine> listVMs()
a method to query the currently running VMs (this can also be accessed through the public field of publicVms).

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

numofCurrentVMs

public int numofCurrentVMs()
a method to determine the number of VMs currently hosted by the PM.

Returns:
the number of VMs on the PM at the current time instance.

isAcceptableConsumption

protected boolean isAcceptableConsumption(ResourceConsumption con)
Determines if a resource consumption (i.e., a compute task utilizing the CPU of the PM) can be registered on the PM for execution. Registration is only allowed if (i.e. the return value is true only if):

Overrides:
isAcceptableConsumption in class ResourceSpreader
Parameters:
con - the consumption that is asked to be registered
Returns:
true if the consumption can be registered in this spreader's underprocessing list

isHostingVMs

public boolean isHostingVMs()
determines if there are any VMs on the PM or not.

Returns:
  • true if there are some VMs hosted on the PM.
  • false otherwise

getCompletedVMs

public long getCompletedVMs()
gets the number of VMs that have already left the PM but that were running on it once

Returns:
the number of past VMs related to this PM

getCurrentOnOffDelay

public long getCurrentOnOffDelay()
Gets an estimate for the duration (in ticks) of the poweron/off operation in progress.

Returns:
the estimated complete duration of the power state changing operation
Throws:
IllegalStateException - if there is no power state change in progress

toString

public String toString()
offers a nice single line format summary of the properties of this PM - good for debugging and tracing.

Overrides:
toString in class MaxMinProvider

subscribeStateChangeEvents

public void subscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)
manages the subscriptions for state change events

Parameters:
sl - the listener object which expects state change events

unsubscribeStateChangeEvents

public void unsubscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)
manages the subscriptions for state change events

Parameters:
sl - the listener object that no longer expects state change events

setState

private void setState(PhysicalMachine.State newState)
manages the state change operation of the PM. Notifies the state change observers. With the state change it also handles the power state changes according to the hostPowerBehavior, networkPowerBehavior and storagePowerBehavior maps.

Parameters:
newState - the new PM state to be set.

getCapacities

public ResourceConstraints getCapacities()
collects the total resource capacity of the PM

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

subscribeToCapacityChanges

public void subscribeToCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
not implemented

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

unsubscribeFromCapacityChanges

public void unsubscribeFromCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
not implemented

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

subscribeToIncreasingFreeapacityChanges

public void subscribeToIncreasingFreeapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
manages the subscriptions for free capacity events (i.e. those cases when there are some resources that are either not allocated anymore or when there is a VM that terminates on the PM)

Parameters:
e - the listener object which expects free capacity events

unsubscribeFromIncreasingFreeCapacityChanges

public void unsubscribeFromIncreasingFreeCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
manages the subscriptions for free capacity events (i.e. those cases when there are some resources that are either not allocated anymore or when there is a VM that terminates on the PM)

Parameters:
e - the listener object that no longer expects free capacity events

isDirectConsumerUsageMoratory

public boolean isDirectConsumerUsageMoratory()
determines if the direct consumer accepts compute tasks to be registered

Returns:
  • true if new tasks can be set up between the direct consumer and the PM
  • false otherwise


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