Package org.cloudbus.cloudsim.resources
Interface ResourceManageable
- All Superinterfaces:
Resource
,ResourceCapacity
- All Known Subinterfaces:
Pe
- All Known Implementing Classes:
Bandwidth
,PeSimple
,Processor
,Ram
,ResourceManageableAbstract
,Storage
public interface ResourceManageable extends Resource
An interface to represent a physical or virtual resource (like RAM, CPU or
Bandwidth) with features to manage resource capacity and allocation.
- Since:
- CloudSim Plus 1.0
- Author:
- Uros Cibej, Anthony Sulistio, Manoel Campos da Silva Filho
-
Field Summary
Fields Modifier and Type Field Description static ResourceManageable
NULL
An attribute that implements the Null Object Design Pattern forResourceManageable
objects. -
Method Summary
Modifier and Type Method Description boolean
addCapacity(long capacityToAdd)
Try to add a given amount to theresource capacity
.boolean
allocateResource(long amountToAllocate)
Try to allocate a given amount of the resource, reducing that amount from the total available resource.default boolean
allocateResource(Resource resource)
Try to allocate in this resource, the amount of resource specified by the capacity of the given resource.long
deallocateAllResources()
De-allocates 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.default boolean
deallocateResource(Resource resource)
Try to deallocate all the capacity of the given resource from this resource.boolean
isResourceAmountBeingUsed(long amountToCheck)
Checks if there is a specific amount of resource being used.boolean
isSuitable(long newTotalAllocatedResource)
Checks if it is possible to change the current allocated resource to a new amount, depending on the available resource remaining.boolean
removeCapacity(long capacityToRemove)
Try to remove a given amount to theresource capacity
.default boolean
setAllocatedResource(double newTotalAllocatedResource)
Try to set the current total amount of allocated resource, changing it to the given value.boolean
setAllocatedResource(long newTotalAllocatedResource)
Try to set the current total amount of allocated resource, changing it to the given value.boolean
setCapacity(long newCapacity)
Try to set theresource capacity
.boolean
sumCapacity(long amountToSum)
Sum a given amount (negative or positive) of capacity to the total resource capacity.Methods inherited from interface org.cloudbus.cloudsim.resources.Resource
getAllocatedResource, getAvailableResource, getPercentUtilization, isAmountAvailable, isAmountAvailable, isAmountAvailable, isFull, isSubClassOf
Methods inherited from interface org.cloudbus.cloudsim.resources.ResourceCapacity
getCapacity
-
Field Details
-
NULL
An attribute that implements the Null Object Design Pattern forResourceManageable
objects.
-
-
Method Details
-
setCapacity
boolean setCapacity(long newCapacity)Try to set theresource capacity
.- Parameters:
newCapacity
- the new resource capacity- Returns:
- true if capacity is greater or equal to 0 and capacity greater or equal to current allocated resource, false otherwise
- See Also:
Resource.getAllocatedResource()
-
sumCapacity
boolean sumCapacity(long amountToSum)Sum a given amount (negative or positive) of capacity to the total resource capacity.- Parameters:
amountToSum
- the amount to sum in the current total capacity. If given a positive number, increases the total capacity; otherwise, decreases it.- Returns:
- true if the total capacity was changed; false otherwise
-
addCapacity
boolean addCapacity(long capacityToAdd)Try to add a given amount to theresource capacity
.- Parameters:
capacityToAdd
- the amount to add- Returns:
- true if capacityToAdd is greater than 0, false otherwise
- Throws:
IllegalArgumentException
- when the capacity to add is negative- See Also:
Resource.getAllocatedResource()
-
removeCapacity
boolean removeCapacity(long capacityToRemove)Try to remove a given amount to theresource capacity
.- Parameters:
capacityToRemove
- the amount to remove- Returns:
- true if capacityToRemove is greater than 0, the current allocated resource is less or equal to the expected new capacity and the capacity to remove is not higher than the current capacity; false otherwise
- Throws:
IllegalArgumentException
- when the capacity to remove is negativeIllegalStateException
- when the capacity to remove is higher than the current total capacity- See Also:
Resource.getAllocatedResource()
-
allocateResource
boolean allocateResource(long amountToAllocate)Try to allocate a given amount of the resource, reducing that amount from the total available resource.- Parameters:
amountToAllocate
- the amount of resource to be allocated- Returns:
- true if amountToAllocate is greater than 0 and there is enough resource to allocate, false otherwise
-
allocateResource
Try to allocate in this resource, the amount of resource specified by the capacity of the given resource. This method is commonly used to allocate a specific amount from a physical resource (this Resource instance) to a virtualized resource (the given Resource).- Parameters:
resource
- the resource to try to allocate its capacity from the current resource- Returns:
- true if required capacity from the given resource is greater than 0 and there is enough resource to allocate, false otherwise
- See Also:
allocateResource(long)
-
setAllocatedResource
boolean setAllocatedResource(long newTotalAllocatedResource)Try to set the current total amount of allocated resource, changing it to the given value. It doesn't increase the current allocated resource by the given amount, instead, it changes the allocated resource to that specified amount.- Parameters:
newTotalAllocatedResource
- the new total amount of resource to allocate, changing the allocate resource to this new amount.- Returns:
- true if newTotalAllocatedResource is not negative and there is enough resource to allocate, false otherwise
-
setAllocatedResource
default boolean setAllocatedResource(double newTotalAllocatedResource)Try to set the current total amount of allocated resource, changing it to the given value. It doesn't increase the current allocated resource by the given amount, instead, it changes the allocated resource to that specified amount.This method is just a shorthand to avoid explicitly converting a double to long.
- Parameters:
newTotalAllocatedResource
- the new total amount of resource to allocate, changing the allocate resource to this new amount.- Returns:
- true if newTotalAllocatedResource is not negative and there is enough resource to allocate, false otherwise
-
deallocateResource
Try to deallocate all the capacity of the given resource from this resource. This method is commonly used to deallocate a specific amount of a physical resource (this Resource instance) that was being used by a virtualized resource (the given Resource).- Parameters:
resource
- the resource that its capacity will be deallocated- Returns:
- true if capacity of the given resource is greater than 0 and there is enough resource to deallocate, false otherwise
- See Also:
deallocateResource(long)
-
deallocateResource
boolean deallocateResource(long amountToDeallocate)Try to deallocate a given amount of the resource.- Parameters:
amountToDeallocate
- the amount of resource to be deallocated- Returns:
- true if amountToDeallocate is greater than 0 and there is enough resource to deallocate, false otherwise
-
deallocateAndRemoveResource
boolean deallocateAndRemoveResource(long amountToDeallocate)Try to deallocate a given amount of the resource and then remove such amount from the total capacity. If the given amount is greater than the total allocated resource, all the resource will be deallocated and that amount will be removed from the total capacity.- Parameters:
amountToDeallocate
- the amount of resource to be deallocated and then removed from the total capacity- Returns:
- true if amountToDeallocate is greater than 0 and there is enough resource to deallocate, false otherwise
-
deallocateAllResources
long deallocateAllResources()De-allocates all allocated resources, restoring the total available resource to the resource capacity.- Returns:
- the amount of resource freed
-
isResourceAmountBeingUsed
boolean isResourceAmountBeingUsed(long amountToCheck)Checks if there is a specific amount of resource being used.- Parameters:
amountToCheck
- the amount of resource to check if is used.- Returns:
- true if the specified amount is being used; false otherwise
-
isSuitable
boolean isSuitable(long newTotalAllocatedResource)Checks if it is possible to change the current allocated resource to a new amount, depending on the available resource remaining.- Parameters:
newTotalAllocatedResource
- the new total amount of resource to allocate.- Returns:
- true, if it is possible to allocate the new total resource; false otherwise
-