Interface ResourceManageable

All Superinterfaces:
Resource, ResourceCapacity
All Known Subinterfaces:
Pe
All Known Implementing Classes:
Bandwidth, PeSimple, Processor, Ram, ResourceManageableAbstract, SimpleStorage

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 Details

  • Method Details

    • setCapacity

      boolean setCapacity(long newCapacity)
      Try to set the resource 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:
    • 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 the resource 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:
    • removeCapacity

      boolean removeCapacity(long capacityToRemove)
      Try to remove a given amount to the resource 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 negative
      IllegalStateException - when the capacity to remove is higher than the current total capacity
      See Also:
    • 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

      default boolean allocateResource(Resource resource)
      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:
    • 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 allocated resource to this new amount.
      Returns:
      true if newTotalAllocatedResource is not negative and there is enough resource to allocate, false otherwise
    • deallocateResource

      default boolean deallocateResource(Resource resource)
      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

      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