|
||||||||||
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.MaxMinConsumer
hu.mta.sztaki.lpds.cloud.simulator.iaas.VirtualMachine
public class VirtualMachine
This class represents a single virtual machine in the system. It simulates its behavior. Currently it supports three approaches for VM image storage:
Nested Class Summary | |
---|---|
private static class |
VirtualMachine.EventSetup
This internal interface is used to customize internal state change actions in the VM class. |
(package private) class |
VirtualMachine.InitialTransferEvent
The event that will be received upon the completion of the VA's copy from vasource to vatarget. |
private static class |
VirtualMachine.StartupProcedure
Provides an implementation of the eventsetup class for the startup procedure which is modelled with a single taks that utilizes a single core of the VM for a specified amount of time (in ticks) |
static class |
VirtualMachine.State
the possible states of a virtual machine in DISSECT-CF. |
static interface |
VirtualMachine.StateChange
This interface helps to receive events on status changes in virtual machines. |
static class |
VirtualMachine.StateChangeException
This class is defined to ensure one can differentiate errors that were caused because the functions on the VM class are called in an improper order. |
Nested classes/interfaces inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader |
---|
ResourceSpreader.FreqSyncer |
Field Summary | |
---|---|
static EnumSet<VirtualMachine.State> |
consumingStates
the set of those VM states that are expected to consume energy |
private VirtualMachine.State |
currState
the current state of the VM |
private StorageObject |
disk
the VM's disk that is stored on the vatarget. |
static EnumSet<VirtualMachine.State> |
preScheduleState
the set of states that show that a VM scheduler was not able to schedule the VM (maybe just yet) |
static EnumSet<VirtualMachine.State> |
preStartupStates
the states that can preceed the startup phase |
private PhysicalMachine.ResourceAllocation |
ra
the resource allocation of this VM (this is only not null when the VM is actually running on a pm, or about to run) |
private StorageObject |
savedmemory
if the VM is suspended then its memory is saved in the following storage object. |
private static VirtualMachine.EventSetup |
sdEvent
The operations to do on shutdown |
private static VirtualMachine.EventSetup |
susEvent
The operations to do on suspend |
static EnumSet<VirtualMachine.State> |
suspendedStates
the states in which the VM is suspended to disk |
private ArrayList<ResourceConsumption> |
suspendedTasks
the list of resourceconsumptions (i.e. |
private static VirtualMachine.EventSetup |
switchonEvent
The operations to do on switchon |
static EnumSet<VirtualMachine.State> |
transferringStates
the set of those VM states that are transferring VM related data |
private VirtualAppliance |
va
the virtual appliance that this VM is using for its disk |
private Repository |
vasource
where should the VM's virtual appliance be located |
private Repository |
vatarget
where should the VM's disk storage be placed during the VM's initiation procedure. |
private StateDependentEventHandler<VirtualMachine.StateChange,org.apache.commons.lang3.tuple.Triple<VirtualMachine,VirtualMachine.State,VirtualMachine.State>> |
vmStateChangelistenerManager
the local handler of VM state change events. |
Fields inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.ResourceSpreader |
---|
lastNotifTime, negligableProcessing, perTickProcessingPower, toBeAdded, toBeRemoved, underProcessing |
Constructor Summary | |
---|---|
VirtualMachine(VirtualAppliance va)
Instantiates a VM object |
Method Summary | |
---|---|
private void |
actualMigration(PhysicalMachine.ResourceAllocation target)
This function is responsible for the actual transfer between the old physical machine and the new one. |
void |
destroy(boolean killTasks)
Destroys the VM, and cleans up all repositories that could contain disk or memory states. |
PhysicalMachine.ResourceAllocation |
getResourceAllocation()
Determines what is the resource allocation currently used by the VM. |
VirtualMachine.State |
getState()
Queries the current state of the VM |
VirtualAppliance |
getVa()
Queries the VA used by this VM |
private void |
initialTransfer(Repository vasource,
Repository vatarget,
VirtualMachine.EventSetup es)
Ensures the transfer of the VM to the appropriate location. |
protected boolean |
isAcceptableConsumption(ResourceConsumption con)
determines if a resourceconsumption object can be registered. |
void |
migrate(PhysicalMachine.ResourceAllocation target)
Moves all data necessary for the VMs execution from its current physical machine to another. |
ResourceConsumption |
newComputeTask(double total,
double limit,
ResourceConsumption.ConsumptionEvent e)
This is the function that users are expected to use to create computing tasks on the VMs (not using resourceconsumptions directly). |
void |
prepare(Repository vasource,
Repository vatarget)
Prepares the VM so it can be started without the need to clone its VA first. |
private void |
realResume()
Actually manages the resume operation (could be invoked from migration as well as from resume) |
void |
resume()
Resumes an already suspended VM. |
private void |
resumeAfterMigration(PhysicalMachine.ResourceAllocation target)
This function is called after the disk and memory images of the VM are located on its new hosting repository. |
void |
setNonservable()
If there are not enough resources for the VM currently, to recover from this state (and allow the VM to be rescheduled) just issue a destroy command on the VM |
void |
setResourceAllocation(PhysicalMachine.ResourceAllocation newRA)
Allows to set a new resource allocation for the VM This function will notify the resource allocation about the acquiration of the resources by utilizing the use function! |
private void |
setState(VirtualMachine.State newstate)
Always use this function to set the current VM state. |
void |
subscribeStateChange(VirtualMachine.StateChange consumer)
Use this function to get notified about state changes on this VM |
void |
suspend()
Suspends an already running VM. |
private void |
suspend(VirtualMachine.EventSetup ev)
Just like regular suspend but allows eventsetup hooks. |
void |
switchoff(boolean killTasks)
Switches off an already running machine. |
void |
switchOn(PhysicalMachine.ResourceAllocation allocation,
Repository vasource)
Initiates the startup procedure of a VM. |
String |
toString()
A nice single line output for the VM that shows its state and resource allocation as well as the tasks it is running. |
void |
unsubscribeStateChange(VirtualMachine.StateChange consumer)
Use this function to be no longer notified about state changes on this VM |
Methods inherited from class hu.mta.sztaki.lpds.cloud.simulator.iaas.resourcemodel.MaxMinConsumer |
---|
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 |
---|
private static final VirtualMachine.EventSetup sdEvent
private static final VirtualMachine.EventSetup susEvent
private static final VirtualMachine.EventSetup switchonEvent
private VirtualAppliance va
private PhysicalMachine.ResourceAllocation ra
private StorageObject disk
private StorageObject savedmemory
private Repository vasource
private Repository vatarget
public static final EnumSet<VirtualMachine.State> consumingStates
public static final EnumSet<VirtualMachine.State> transferringStates
public static final EnumSet<VirtualMachine.State> suspendedStates
public static final EnumSet<VirtualMachine.State> preStartupStates
public static final EnumSet<VirtualMachine.State> preScheduleState
private VirtualMachine.State currState
private final StateDependentEventHandler<VirtualMachine.StateChange,org.apache.commons.lang3.tuple.Triple<VirtualMachine,VirtualMachine.State,VirtualMachine.State>> vmStateChangelistenerManager
private final ArrayList<ResourceConsumption> suspendedTasks
Constructor Detail |
---|
public VirtualMachine(VirtualAppliance va)
va
- the virtual appliance that should be the base for this VM,
IllegalStateException
- if the va is nullMethod Detail |
---|
private void setState(VirtualMachine.State newstate)
newstate
- The new state the VM is in.public VirtualAppliance getVa()
public VirtualMachine.State getState()
public void prepare(Repository vasource, Repository vatarget) throws VMManager.VMManagementException, NetworkNode.NetworkException
vatarget
- the disk that will host the VM.vasource
- the repository where the VA for this VM is found. If null, the
function assumes it is found in the hosting PM's repository.
VirtualMachine.StateChangeException
- if the VM is not destroyed
VMManager.VMManagementException
- if the VA transfer failed and the state change was reverted
NetworkNode.NetworkException
private void initialTransfer(Repository vasource, Repository vatarget, VirtualMachine.EventSetup es) throws VMManager.VMManagementException, NetworkNode.NetworkException
vatarget
- the storage that will host the VM's working image (typically
this is going to be the disk of the PM that will host the VM).vasource
- the repository where the VA for this VM is found. If null, the
function assumes it is found in the hosting PM's repository.es
- The way the VM's state should be changed the function will
fire an event on this channel if the VA is cloned properly
VMManager.VMManagementException
- if the VA transfer failed and the state change was reverted
NetworkNode.NetworkException
- if the VA's transfer cannot be completed (e.g., because of
connectivity issues)public void switchOn(PhysicalMachine.ResourceAllocation allocation, Repository vasource) throws VMManager.VMManagementException, NetworkNode.NetworkException
allocation
- the resource allocation which will be used to deploy the VM on.vasource
- the repository where the VA for this VM is found. If null, the
function assumes it is found in the hosting PM's repository.
VirtualMachine.StateChangeException
- if the VM is not destroyed or shutdown
VMManager.VMManagementException
- if the VA transfer failed and the state change was reverted
NetworkNode.NetworkException
private void resumeAfterMigration(PhysicalMachine.ResourceAllocation target) throws NetworkNode.NetworkException
target
- the new resource allocation on which the resume operation
should take place
VMManager.VMManagementException
- in case some errors were reported during the resume operation
at the new physical machine
NetworkNode.NetworkException
private void actualMigration(PhysicalMachine.ResourceAllocation target) throws NetworkNode.NetworkException
target
- the new resource allocation on which the resume operation
should take place
NetworkNode.NetworkException
public void migrate(PhysicalMachine.ResourceAllocation target) throws VMManager.VMManagementException, NetworkNode.NetworkException
target
- the new resource allocation on which the resume operation
should take place
VirtualMachine.StateChangeException
- if the VM is not in running state currently
VMManager.VMManagementException
- if the system have had troubles during the suspend operation.
NetworkNode.NetworkException
public void destroy(boolean killTasks) throws VMManager.VMManagementException
VirtualMachine.StateChangeException
- if some parts of the VM are under transfer so it cannot be
determined what to clean up.
VMManager.VMManagementException
public void switchoff(boolean killTasks) throws VirtualMachine.StateChangeException
VirtualMachine.StateChangeException
- if is not running currentlypublic void suspend() throws VMManager.VMManagementException, NetworkNode.NetworkException
VirtualMachine.StateChangeException
- if the machine is not in running state
VMManager.VMManagementException
- if there is not enough space to store the memory state (first
locally, then locally/remotely depending on the VM storage
scenario
NetworkNode.NetworkException
private void suspend(VirtualMachine.EventSetup ev) throws VMManager.VMManagementException, NetworkNode.NetworkException
ev
- the eventsetup hook to be used when the suspend operation is
complete.
VirtualMachine.StateChangeException
- see at regular suspend
VMManager.VMManagementException
- see at regular suspend
NetworkNode.NetworkException
private void realResume() throws VMManager.VMManagementException
VMManager.VMManagementException
- if the VM's memory cannot be recalled.public void resume() throws VMManager.VMManagementException, NetworkNode.NetworkException
VirtualMachine.StateChangeException
- if the machine is not in suspended state
VMManager.VMManagementException
- if there is not enough space to retreive the memory state to
the PM's repository
NetworkNode.NetworkException
public void subscribeStateChange(VirtualMachine.StateChange consumer)
consumer
- the party to be notified when the state changespublic void unsubscribeStateChange(VirtualMachine.StateChange consumer)
consumer
- the party who previously received notificationsprotected boolean isAcceptableConsumption(ResourceConsumption con)
isAcceptableConsumption
in class ResourceSpreader
con
- the consumption that is asked to be registered
public ResourceConsumption newComputeTask(double total, double limit, ResourceConsumption.ConsumptionEvent e) throws NetworkNode.NetworkException
total
- the amount of processing to be done (in number of
instructions)limit
- the amount of processing this new compute task is allowed to
do in a single tick (in instructions/tick). If there should be
no limit for the processing then one can use the constant
named ResourceConsumption.unlimitedProcessing.e
- the object to be notified about the completion of the
computation ordered here
NetworkNode.NetworkException
- if the background network load is not possible to simulate.public void setResourceAllocation(PhysicalMachine.ResourceAllocation newRA) throws VMManager.VMManagementException
newRA
- the allocation to be used later on
VMManager.VMManagementException
- if the VM is already running using a hostpublic PhysicalMachine.ResourceAllocation getResourceAllocation()
public void setNonservable()
public String toString()
toString
in class MaxMinConsumer
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |