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

java.lang.Object
  extended by hu.mta.sztaki.lpds.cloud.simulator.DeferredEvent
      extended by hu.mta.sztaki.lpds.cloud.simulator.iaas.PhysicalMachine.ResourceAllocation
All Implemented Interfaces:
VirtualMachine.StateChange
Enclosing class:
PhysicalMachine

public class PhysicalMachine.ResourceAllocation
extends DeferredEvent
implements VirtualMachine.StateChange

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. This allocation is then later on expected to be used by virtual machines to use. Before resource allocations are used they are allocated for a fixed amount of time. Thus if a user forgets about the allocation, the PMs resources are not occupied forever.

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"

Field Summary
 ResourceConstraints allocated
          The resource set that is virtually offered to the VM that uses this allocation.
private  int myPromisedIndex
          The index of this allocation in the allocation list located in the PM.
private  ResourceConstraints realAllocated
          The resource set that is actually reserved on the PM.
private  boolean swept
          If the resource allocation is not used before its expiry time then this is going to be true!
private  VirtualMachine user
          The VM that utilizes the allocation in question
 
Constructor Summary
private PhysicalMachine.ResourceAllocation(ResourceConstraints realAlloc, ResourceConstraints alloc, int until)
          The constructor of the resource allocation to be used by the physical machine only!
 
Method Summary
 void cancel()
          if a resource allocation is no longer needed (e.g.
protected  void eventAction()
          This function is called by deferred event when the allocation is expired.
 PhysicalMachine getHost()
          Allows to determine the Physical Machine the particular allocation is bound to.
 boolean isAvailable()
          Determines if the allocation is still available to use
 boolean isUnUsed()
          Allows users to determine if the allocation is already taken by a VM.
private  void promisedCapacityUpdater()
          updates the PM's respective fields about resource availability
(package private)  void release()
          If a VM no longer needs the resources then this function must be called.
 void stateChanged(VirtualMachine vm, VirtualMachine.State oldState, VirtualMachine.State newState)
          This function is called by the user VM if it is switching states.
 String toString()
          Shows basic information about the allocation useful for debugging
(package private)  void use(VirtualMachine vm)
          To complete the allocation process the VM must be told to use a particular allocation (e.g.
 
Methods inherited from class hu.mta.sztaki.lpds.cloud.simulator.DeferredEvent
isCancelled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

allocated

public final ResourceConstraints allocated
The resource set that is virtually offered to the VM that uses this allocation.


realAllocated

private final ResourceConstraints realAllocated
The resource set that is actually reserved on the PM. If allocated>realAllocated, then the VM might get resources up to allocated but only when the PM is not over-committed.


user

private VirtualMachine user
The VM that utilizes the allocation in question


myPromisedIndex

private final int myPromisedIndex
The index of this allocation in the allocation list located in the PM. Allows rapid cleaning of the allocation list.


swept

private boolean swept
If the resource allocation is not used before its expiry time then this is going to be true!

Constructor Detail

PhysicalMachine.ResourceAllocation

private PhysicalMachine.ResourceAllocation(ResourceConstraints realAlloc,
                                           ResourceConstraints alloc,
                                           int until)
The constructor of the resource allocation to be used by the physical machine only!

Parameters:
realAlloc - defines the actually reserved resources with the allocation
alloc - defines the promised resources for the user
until - defines the duration in ticks for which the allocation will be kept for the user. This period is useful to allow advanced scheduling operations where some resources are occupied in advance in order to ensure rapid VM creation.
Method Detail

eventAction

protected void eventAction()
This function is called by deferred event when the allocation is expired. The allocation expiry event is only happening if there are no VMs that use the allocation by the time the expiry period is over. REMARK: As expiry is considered a problem in most systems, this is actually printing out to standard error - as the error is not critical and there would be no way to propagate the error to the entity who issued the allocation.

Specified by:
eventAction in class DeferredEvent

promisedCapacityUpdater

private void promisedCapacityUpdater()
updates the PM's respective fields about resource availability


cancel

public void cancel()
if a resource allocation is no longer needed (e.g. because another allocation was used for the same VM), then this way one can not only cancel the allocation but also ensure that the expiry event is not fired.

Overrides:
cancel in class DeferredEvent

use

void use(VirtualMachine vm)
   throws VMManager.VMManagementException
To complete the allocation process the VM must be told to use a particular allocation (e.g. in its migration or starup calls). The VM then automatically tells this resource allocation object to finalize the allocation process by calling this use function. This function subscribes to the VM's state change events in order to ensure that VMs that are not running are not really using resources from the PM. WARNING: this function is to be used by the VM only as the VM knows for what operation it needs to use the allocation.

Parameters:
vm - the virtual machine that will use the allocated resources in the future
Throws:
VMManagementException - if the allocation passed to the VM is already expired or if the allocation is already used by some VM.
VMManager.VMManagementException

stateChanged

public void stateChanged(VirtualMachine vm,
                         VirtualMachine.State oldState,
                         VirtualMachine.State newState)
This function is called by the user VM if it is switching states. The function actually ensures that not running VMs are not having access to resources.

Specified by:
stateChanged in interface VirtualMachine.StateChange
oldState - the state before the change was issued
newState - the state after the change took effect

release

void release()
If a VM no longer needs the resources then this function must be called. As a result, the PM ensures that the relesed resources are again available to all interested parties.


isUnUsed

public boolean isUnUsed()
Allows users to determine if the allocation is already taken by a VM.

Returns:
  • true if there is a VM that is using the resource allocation
  • false otherwise

isAvailable

public boolean isAvailable()
Determines if the allocation is still available to use

Returns:
  • true if the allocation is still ok to use
  • falseotherwise

toString

public String toString()
Shows basic information about the allocation useful for debugging

Overrides:
toString in class Object

getHost

public PhysicalMachine getHost()
Allows to determine the Physical Machine the particular allocation is bound to.

Returns:
the physical machine which offers this allocation.


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