|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objecthu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader
hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.MaxMinFairSpreader
hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.MaxMinProvider
hu.mta.sztaki.lpds.cloud.simulator.iaas.PhysicalMachine
public class PhysicalMachine
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).
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 |
---|
public static final int defaultAllocLen
public static final int migrationAllocLen
public static final double smallUtilization
public static final EnumSet<PhysicalMachine.State> ToOnorRunning
public static final EnumSet<PhysicalMachine.State> ToOfforOff
public static final EnumSet<PhysicalMachine.State> StatesOfHighEnergyConsumption
private final ConstantConstraints totalCapacities
private final AlterableResourceConstraints internalAvailableCaps
public final UnalterableConstraintsPropagator availableCapacities
private AlterableResourceConstraints promisedCapacities
private final AlterableResourceConstraints internalReallyFreeCaps
public final UnalterableConstraintsPropagator freeCapacities
public final Repository localDisk
private PhysicalMachine.ResourceAllocation[] promisedResources
private int promisedAllocationsCount
private PhysicalMachine.State currentState
private final double[] onTransition
private final double[] offTransition
private final long onDelayEstimate
private final long offDelayEstimate
private final EnumMap<PhysicalMachine.State,PowerState> hostPowerBehavior
private final EnumMap<PhysicalMachine.State,PowerState> storagePowerBehavior
private final EnumMap<PhysicalMachine.State,PowerState> networkPowerBehavior
private final StateDependentEventHandler<PhysicalMachine.StateChangeListener,org.apache.commons.lang3.tuple.Pair<PhysicalMachine.State,PhysicalMachine.State>> stateListenerManager
private final HashSet<VirtualMachine> vms
public final Set<VirtualMachine> publicVms
private long completedVMs
private PhysicalMachine.PowerStateDelayer onOffEvent
private final StateDependentEventHandler<VMManager.CapacityChangeEvent<ResourceConstraints>,List<ResourceConstraints>> increasingFreeCapacityListenerManager
public final MaxMinConsumer directConsumer
private boolean directConsumerUsageMoratory
Constructor Detail |
---|
public PhysicalMachine(double cores, double perCorePocessing, long memory, Repository disk, int onD, int offD, EnumMap<PhysicalMachine.PowerStateKind,EnumMap<PhysicalMachine.State,PowerState>> powerTransitions)
cores
- defines the number of CPU cores this machine has under controlperCorePocessing
- 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 controlonD
- defines the time delay between the machine's switch on and the
first time it can serve VM requestsoffD
- defines the time delay the machine needs to shut down all of
its operations while it does not serve any more VMspowerTransitions
- 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.public PhysicalMachine(double cores, double perCorePocessing, long memory, Repository disk, double[] turnonOperations, double[] switchoffOperations, EnumMap<PhysicalMachine.PowerStateKind,EnumMap<PhysicalMachine.State,PowerState>> powerTransitions)
cores
- defines the number of CPU cores this machine has under controlperCorePocessing
- 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 controlturnonOperations
- 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 |
---|
private long prepareTransitionalTasks(boolean on, double[] array)
on
- which taskset needs to be preparedarray
- the task array - for format see powerstatedelayer
public boolean switchoff(PhysicalMachine migrateHere) throws VMManager.VMManagementException, NetworkNode.NetworkException
migrateHere
- the physical machine where the currently hosted VMs of this VM
should go before the actual switch off operation will happen
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
stateprivate void actualSwitchOff()
public boolean isRunning()
public PhysicalMachine.State getState()
public void turnon()
public void migrateVM(VirtualMachine vm, PhysicalMachine target) throws VMManager.VMManagementException, NetworkNode.NetworkException
migrateVM
in interface VMManager<PhysicalMachine,ResourceConstraints>
vm
- the VM to be migratedtarget
- the PM to be used by the VM after the migration completes
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
public void reallocateResources(VirtualMachine vm, ResourceConstraints newresources)
reallocateResources
in interface VMManager<PhysicalMachine,ResourceConstraints>
vm
- The VM to be adjustednewresources
- The new amount of resources needed (this could not only raise
the available resources of the VM but also decrease thempublic PhysicalMachine.ResourceAllocation allocateResources(ResourceConstraints requested, boolean strict, int allocationValidityLength) throws VMManager.VMManagementException
requested
- The amount of resources needed by the callerstrict
- 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.
VMManager.VMManagementException
private boolean checkAllocationsPresence(PhysicalMachine.ResourceAllocation allocation)
allocation
- the untrusted allocation
public boolean cancelAllocation(PhysicalMachine.ResourceAllocation allocation)
allocation
- the resource allocation to terminate
public boolean isHostableRequest(ResourceConstraints requested)
requested
- the resource set to be checked for hostability
public void deployVM(VirtualMachine vm, PhysicalMachine.ResourceAllocation ra, Repository vaSource) throws VMManager.VMManagementException, NetworkNode.NetworkException
vm
- the VM to be deployed on the PMra
- the resource allocation to be uesed for the VMvaSource
- the repository that stores the virtual appliance of the VM
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
public VirtualMachine[] requestVM(VirtualAppliance va, ResourceConstraints rc, Repository vaSource, int count) throws VMManager.VMManagementException, NetworkNode.NetworkException
va
- The appliance for the VM to be created.rc
- The resource requirements of the VMvaSource
- The storage where the VA resides.count
- The number of VMs to be created with the above specification
VMManagementException
- If the machine is not accepting requests currently.VMManager.VMManagementException
NetworkNode.NetworkException
public VirtualMachine[] requestVM(VirtualAppliance va, ResourceConstraints rc, Repository vaSource, int count, HashMap<String,Object> schedulingConstraints) throws VMManager.VMManagementException, NetworkNode.NetworkException
requestVM
in interface VMManager<PhysicalMachine,ResourceConstraints>
va
- the kind of VM to be created
VMManager.VMManagementException
- if the request cannot be fulfilled for some reason
NetworkNode.NetworkException
public void terminateVM(VirtualMachine vm, boolean killTasks) throws VMManager.NoSuchVMException, VMManager.VMManagementException
terminateVM
in interface VMManager<PhysicalMachine,ResourceConstraints>
vm
- to be switched offkillTasks
- 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.
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
public Collection<VirtualMachine> listVMs()
listVMs
in interface VMManager<PhysicalMachine,ResourceConstraints>
public int numofCurrentVMs()
protected boolean isAcceptableConsumption(ResourceConsumption con)
isAcceptableConsumption
in class ResourceSpreader
con
- the consumption that is asked to be registered
public boolean isHostingVMs()
public long getCompletedVMs()
public long getCurrentOnOffDelay()
IllegalStateException
- if there is no power state change in progresspublic String toString()
toString
in class MaxMinProvider
public void subscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)
sl
- the listener object which expects state change eventspublic void unsubscribeStateChangeEvents(PhysicalMachine.StateChangeListener sl)
sl
- the listener object that no longer expects state change eventsprivate void setState(PhysicalMachine.State newState)
newState
- the new PM state to be set.public ResourceConstraints getCapacities()
getCapacities
in interface VMManager<PhysicalMachine,ResourceConstraints>
public void subscribeToCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
subscribeToCapacityChanges
in interface VMManager<PhysicalMachine,ResourceConstraints>
e
- the listener object which expects capacity change eventspublic void unsubscribeFromCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
unsubscribeFromCapacityChanges
in interface VMManager<PhysicalMachine,ResourceConstraints>
e
- the listener object that no longer expects capacity change eventspublic void subscribeToIncreasingFreeapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
e
- the listener object which expects free capacity eventspublic void unsubscribeFromIncreasingFreeCapacityChanges(VMManager.CapacityChangeEvent<ResourceConstraints> e)
e
- the listener object that no longer expects free capacity
eventspublic boolean isDirectConsumerUsageMoratory()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |