ResourceManageableAbstract

public abstract class ResourceManageableAbstract extends ResourceAbstract implements ResourceManageable

A class that represents simple resources such as RAM, CPU, Bandwidth or Pe. It stores, for instance, the resource capacity and amount of free available resource.

The class is abstract just to ensure there will be an specific subclass for each kind of resource, allowing to differentiate, for example, a RAM Resource from a BW Resource. The VM class also relies on this differentiation for generically getting a required resource.

Author:Uros Cibej, Anthony Sulistio, Manoel Campos da Silva Filho

Constructors

ResourceManageableAbstract

public ResourceManageableAbstract(long capacity)

Methods

addCapacity

public boolean addCapacity(long capacityToAdd)

allocateResource

public boolean allocateResource(long amountToAllocate)

deallocateAllResources

public long deallocateAllResources()

deallocateAndRemoveResource

public boolean deallocateAndRemoveResource(long amountToDeallocate)

deallocateResource

public boolean deallocateResource(long amountToDeallocate)

getAvailableResource

public long getAvailableResource()

removeCapacity

public boolean removeCapacity(long capacityToRemove)

setAllocatedResource

public boolean setAllocatedResource(long newTotalAllocatedResource)

setAvailableResource

protected final boolean setAvailableResource(long newAvailableResource)

Sets the given amount as available resource.

Parameters:
  • newAvailableResource – the new amount of available resource to set
Returns:

true if availableResource > 0 and availableResource <= capacity, false otherwise

setCapacity

public boolean setCapacity(long newCapacity)

sumAvailableResource

protected boolean sumAvailableResource(long amountToSum)

Sum a given amount (negative or positive) of available (free) resource to the total available resource.

Parameters:
  • amountToSum – the amount to sum in the current total available resource. If given a positive number, increases the total available resource; otherwise, decreases the total available resource.
Returns:

true if the total available resource was changed; false otherwise

toString

public String toString()