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>

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
           
static class PhysicalMachine.PowerStateKind
           
static class PhysicalMachine.ResourceAllocation
           
static class PhysicalMachine.State
          Represents the possible states of the physical machines modeled in the system
static interface PhysicalMachine.StateChangeListener
           
 
Nested classes/interfaces inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
ResourceSpreader.FreqSyncer, ResourceSpreader.PowerBehaviorChangeListener
 
Nested classes/interfaces inherited from interface hu.mta.sztaki.lpds.cloud.simulator.iaas.VMManager
VMManager.CapacityChangeEvent<F>, VMManager.NoSuchVMException, VMManager.VMManagementException
 
Field Summary
private  ResourceConstraints availableCapacities
           
private  long completedVMs
           
private  PhysicalMachine.State currentState
           
static int defaultAllocLen
           
private  EnumMap<PhysicalMachine.State,PowerState> hostPowerBehavior
           
private  CopyOnWriteArrayList<VMManager.CapacityChangeEvent<ResourceConstraints>> increasingFreeCapacityListeners
           
private  CopyOnWriteArrayList<PhysicalMachine.StateChangeListener> listeners
           
 Repository localDisk
           
static int migrationAllocLen
           
private  EnumMap<PhysicalMachine.State,PowerState> networkPowerBehavior
           
 int offDelay
           
 int onDelay
           
private  DeferredEvent onOffEvent
           
private  int promisedAllocationsCount
           
private  ResourceConstraints promisedCapacities
           
(package private)  ArrayList<PhysicalMachine.ResourceAllocation> promisedResources
           
 Set<VirtualMachine> publicVms
           
private  ResourceConstraints reallyFreeCapacities
           
static EnumSet<PhysicalMachine.State> StatesOfHighEnergyConsumption
           
private  EnumMap<PhysicalMachine.State,PowerState> storagePowerBehavior
           
static EnumSet<PhysicalMachine.State> ToOfforOff
           
static EnumSet<PhysicalMachine.State> ToOnorRunning
           
private  ResourceConstraints totalCapacities
           
private  HashSet<VirtualMachine> vms
           
 
Fields inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
lastNotifTime, negligableProcessing, perTickProcessingPower, toBeAdded, underProcessing
 
Constructor Summary
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()
           
 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)
           
private  boolean checkAllocationsPresence(PhysicalMachine.ResourceAllocation allocation)
           
 void deployVM(VirtualMachine vm, PhysicalMachine.ResourceAllocation ra, Repository vaSource)
           
 ResourceConstraints getAvailableCapacities()
          Returns capacities that does not actually have deployed VMs on them
 ResourceConstraints getCapacities()
           
 long getCompletedVMs()
           
 long getCurrentOnOffDelay()
           
 ResourceConstraints getFreeCapacities()
          Those capacities that are not even allocated
 PhysicalMachine.State getState()
           
protected  boolean isAcceptableConsumption(ResourceConsumption con)
           
 boolean isHostableRequest(ResourceConstraints requested)
           
 boolean isHostingVMs()
           
 boolean isRunning()
          Determines if the machine can be used for VM instantiation.
 Collection<VirtualMachine> listVMs()
          Provides an overview on the VMs currently in the system
 void migrateVM(VirtualMachine vm, PhysicalMachine target)
          Migrates a VM from the current system to another.
private  void notifyFreedUpCapacityListeners(ResourceConstraints freedUpResources)
           
 int numofCurrentVMs()
           
 void reallocateResources(VirtualMachine vm, ResourceConstraints newresources)
          Allows fine-grained resource utilization setup of the particular VM after it was allocated on the system.
 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)
          Scheduling constraints are ignored currently! As this is too low level to handle them in the current state of the simulator.
private  void setState(PhysicalMachine.State newState)
           
 void subscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)
           
 void subscribeToCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
           
 void subscribeToIncreasingFreeapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> 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)
          Terminates a VM in the system.
 String toString()
           
 void turnon()
          Turns on the physical machine so it allows energy and resource consumption and opens the possibility to receive VM requests.
 void unsubscribeFromCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
           
 void unsubscribeFromIncreasingFreeCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
           
 void unsubscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)
           
 
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
See Also:
Constant Field Values

migrationAllocLen

public static final int migrationAllocLen
See Also:
Constant Field Values

ToOnorRunning

public static final EnumSet<PhysicalMachine.State> ToOnorRunning

ToOfforOff

public static final EnumSet<PhysicalMachine.State> ToOfforOff

StatesOfHighEnergyConsumption

public static final EnumSet<PhysicalMachine.State> StatesOfHighEnergyConsumption

totalCapacities

private final ResourceConstraints totalCapacities

availableCapacities

private ResourceConstraints availableCapacities

promisedCapacities

private ResourceConstraints promisedCapacities

reallyFreeCapacities

private ResourceConstraints reallyFreeCapacities

localDisk

public final Repository localDisk

promisedResources

final ArrayList<PhysicalMachine.ResourceAllocation> promisedResources

promisedAllocationsCount

private int promisedAllocationsCount

onDelay

public final int onDelay

offDelay

public final int offDelay

currentState

private PhysicalMachine.State currentState

hostPowerBehavior

private final EnumMap<PhysicalMachine.State,PowerState> hostPowerBehavior

storagePowerBehavior

private final EnumMap<PhysicalMachine.State,PowerState> storagePowerBehavior

networkPowerBehavior

private final EnumMap<PhysicalMachine.State,PowerState> networkPowerBehavior

listeners

private CopyOnWriteArrayList<PhysicalMachine.StateChangeListener> listeners

vms

private final HashSet<VirtualMachine> vms

publicVms

public final Set<VirtualMachine> publicVms

completedVMs

private long completedVMs

onOffEvent

private DeferredEvent onOffEvent

increasingFreeCapacityListeners

private CopyOnWriteArrayList<VMManager.CapacityChangeEvent<ResourceConstraints>> increasingFreeCapacityListeners
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.
Method Detail

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
VMManager.VMManagementException

actualSwitchOff

private void actualSwitchOff()

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()

turnon

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


migrateVM

public void migrateVM(VirtualMachine vm,
                      PhysicalMachine target)
               throws VMManager.VMManagementException,
                      NetworkNode.NetworkException
Description copied from interface: VMManager
Migrates a VM from the current system to another. The VM is not going to be running during this period. It will not consume resources on the current system anymore

Specified by:
migrateVM in interface VMManager<PhysicalMachine,ResourceConstraints>
Parameters:
vm - the VM to be relocated
target - the target system that should host the VM in the future
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)
Description copied from interface: VMManager
Allows fine-grained resource utilization setup of the particular VM after it was allocated on the system. Even during its runtime. Don't forget that in real VMs resource availability changes might cause troubles. Apply it rarely if you are not sure it will also work in the real world!

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
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 are available 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)

cancelAllocation

public boolean cancelAllocation(PhysicalMachine.ResourceAllocation allocation)

isHostableRequest

public boolean isHostableRequest(ResourceConstraints requested)

deployVM

public void deployVM(VirtualMachine vm,
                     PhysicalMachine.ResourceAllocation ra,
                     Repository vaSource)
              throws VMManager.VMManagementException,
                     NetworkNode.NetworkException
Throws:
VMManager.VMManagementException
NetworkNode.NetworkException

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
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
Description copied from interface: VMManager
Terminates a VM in the system. Ensures that it is not running after the request completes anymore.

Specified by:
terminateVM in interface VMManager<PhysicalMachine,ResourceConstraints>
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()
Description copied from interface: VMManager
Provides an overview on the VMs currently in the system

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()

isAcceptableConsumption

protected boolean isAcceptableConsumption(ResourceConsumption con)
Overrides:
isAcceptableConsumption in class ResourceSpreader

isHostingVMs

public boolean isHostingVMs()

getCompletedVMs

public long getCompletedVMs()

getCurrentOnOffDelay

public long getCurrentOnOffDelay()

toString

public String toString()
Overrides:
toString in class MaxMinProvider

subscribeStateChangeEvents

public void subscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)

unsubscribeStateChangeEvents

public void unsubscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)

setState

private void setState(PhysicalMachine.State newState)

getCapacities

public ResourceConstraints getCapacities()
Specified by:
getCapacities in interface VMManager<PhysicalMachine,ResourceConstraints>

getFreeCapacities

public ResourceConstraints getFreeCapacities()
Those capacities that are not even allocated

Returns:

getAvailableCapacities

public ResourceConstraints getAvailableCapacities()
Returns capacities that does not actually have deployed VMs on them

Returns:

subscribeToCapacityChanges

public void subscribeToCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
Specified by:
subscribeToCapacityChanges in interface VMManager<PhysicalMachine,ResourceConstraints>

unsubscribeFromCapacityChanges

public void unsubscribeFromCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
Specified by:
unsubscribeFromCapacityChanges in interface VMManager<PhysicalMachine,ResourceConstraints>

subscribeToIncreasingFreeapacityChanges

public void subscribeToIncreasingFreeapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)

unsubscribeFromIncreasingFreeCapacityChanges

public void unsubscribeFromIncreasingFreeCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)

notifyFreedUpCapacityListeners

private void notifyFreedUpCapacityListeners(ResourceConstraints freedUpResources)


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