public abstract class ResourceManageableAbstract extends ResourceAbstract implements ResourceManageable
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.
capacity
NULL
Constructor and Description |
---|
ResourceManageableAbstract(long capacity) |
Modifier and Type | Method and Description |
---|---|
boolean |
addCapacity(long capacityToAdd)
Try to add a given amount to the
resource capacity . |
boolean |
allocateResource(long amountToAllocate)
Try to allocate a given amount of the resource, reducing that amount from the
total available resource.
|
long |
deallocateAllResources()
Deallocates all allocated resources, restoring the total available
resource to the resource capacity.
|
boolean |
deallocateAndRemoveResource(long amountToDeallocate)
Try to deallocate a given amount of the resource and then
remove such amount from the total capacity.
|
boolean |
deallocateResource(long amountToDeallocate)
Try to deallocate a given amount of the resource.
|
long |
getAvailableResource()
Gets the amount of the resource that is available (free).
|
boolean |
removeCapacity(long capacityToRemove)
Try to remove a given amount to the
resource capacity . |
boolean |
setAllocatedResource(long newTotalAllocatedResource)
Try to set the current total amount of allocated resource, changing it to the
given value.
|
protected boolean |
setAvailableResource(long newAvailableResource)
Sets the given amount as available resource.
|
boolean |
setCapacity(long newCapacity)
Try to set the
resource capacity . |
protected boolean |
sumAvailableResource(long amountToSum)
Sum a given amount (negative or positive) of available (free) resource to the total
available resource.
|
boolean |
sumCapacity(long amountToSum)
Sum a given amount (negative or positive) of capacity to the total
resource capacity.
|
String |
toString() |
getAllocatedResource, getCapacity, isAmountAvailable, isAmountAvailable, isResourceAmountBeingUsed, isSuitable
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
allocateResource, deallocateResource, isResourceAmountBeingUsed, isSuitable, setAllocatedResource
getAllocatedResource, getPercentUtilization, isAmountAvailable, isAmountAvailable, isAmountAvailable, isFull, isSubClassOf
getCapacity
public boolean setCapacity(long newCapacity)
ResourceManageable
resource capacity
.setCapacity
in interface ResourceManageable
newCapacity
- the new resource capacityResource.getAllocatedResource()
public boolean sumCapacity(long amountToSum)
ResourceManageable
sumCapacity
in interface ResourceManageable
amountToSum
- the amount to sum in the current total capacity.
If given a positive number, increases the total capacity; otherwise, decreases it.public boolean addCapacity(long capacityToAdd)
ResourceManageable
resource capacity
.addCapacity
in interface ResourceManageable
capacityToAdd
- the amount to addResource.getAllocatedResource()
public boolean removeCapacity(long capacityToRemove)
ResourceManageable
resource capacity
.removeCapacity
in interface ResourceManageable
capacityToRemove
- the amount to removeResource.getAllocatedResource()
protected boolean sumAvailableResource(long amountToSum)
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.protected final boolean setAvailableResource(long newAvailableResource)
newAvailableResource
- the new amount of available resource to setavailableResource > 0 and availableResource <= capacity
, false otherwisepublic long getAvailableResource()
Resource
getAvailableResource
in interface Resource
public boolean allocateResource(long amountToAllocate)
ResourceManageable
allocateResource
in interface ResourceManageable
amountToAllocate
- the amount of resource to be allocatedpublic boolean setAllocatedResource(long newTotalAllocatedResource)
ResourceManageable
setAllocatedResource
in interface ResourceManageable
newTotalAllocatedResource
- the new total amount of resource to
allocate, changing the allocate resource to this new amount.public boolean deallocateAndRemoveResource(long amountToDeallocate)
ResourceManageable
deallocateAndRemoveResource
in interface ResourceManageable
amountToDeallocate
- the amount of resource to be deallocated and then removed from
the total capacitypublic boolean deallocateResource(long amountToDeallocate)
ResourceManageable
deallocateResource
in interface ResourceManageable
amountToDeallocate
- the amount of resource to be deallocatedpublic long deallocateAllResources()
ResourceManageable
deallocateAllResources
in interface ResourceManageable
Copyright © 2015–2019 Systems, Security and Image Communication Lab - Instituto de Telecomunica����es (IT) - Universidade da Beira Interior (UBI) - Instituto Federal de Educa����o Ci��ncia e Tecnologia do Tocantins (IFTO). All rights reserved.