Interface Resource

All Superinterfaces:
ResourceCapacity
All Known Subinterfaces:
FileStorage, Pe, ResourceManageable
All Known Implementing Classes:
Bandwidth, HarddriveStorage, PeSimple, Processor, Ram, ResourceAbstract, ResourceManageableAbstract, SanStorage, SimpleStorage, VmRam

public interface Resource extends ResourceCapacity
An interface to represent a physical or virtual resource (like RAM, CPU or Bandwidth) that doesn't provide direct features to change the allocated amount of resource. Objects that directly implement this interface are supposed to define the capacity and amount of allocated resource only in their constructors.
Since:
CloudSim Plus 1.0
Author:
Uros Cibej, Anthony Sulistio, Manoel Campos da Silva Filho
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final Resource
    An attribute that implements the Null Object Design Pattern for Resource objects.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the current total amount of allocated resource.
    long
    Returns the available amount of the resource that is free to be used.
    default double
    Gets the current percentage of resource utilization.
     
    default boolean
    isAmountAvailable(double amountToCheck)
    Checks if there is a specific amount of resource available (free), where such an amount is a double value that will be converted to long.
    boolean
    isAmountAvailable(long amountToCheck)
    Checks if there is a specific amount of resource available (free).
    default boolean
    Checks if the capacity required by a given resource is available (free) at this resource.
    default boolean
    Checks if the resource is full or not.
    default boolean
    isSubClassOf(Class classWanted)
    Checks if this object is an instance of a given class.

    Methods inherited from interface org.cloudsimplus.resources.ResourceCapacity

    getCapacity
  • Field Details

    • NULL

      static final Resource NULL
      An attribute that implements the Null Object Design Pattern for Resource objects.
  • Method Details

    • isSubClassOf

      default boolean isSubClassOf(Class classWanted)
      Checks if this object is an instance of a given class.
      Parameters:
      classWanted - the class to verify if the object is an instance of
      Returns:
      true if the object is an instance of the given class, false otherwise
    • getAvailableResource

      long getAvailableResource()
      Returns the available amount of the resource that is free to be used. The data unit depends on the implementing classes.
      Returns:
      the available amount of the resource that is free to be used
    • getAllocatedResource

      long getAllocatedResource()
      Returns the current total amount of allocated resource. The data unit depends on the implementing classes, according to the getUnit().
      Returns:
      the current total amount of allocated resource
    • isAmountAvailable

      default boolean isAmountAvailable(Resource resource)
      Checks if the capacity required by a given resource is available (free) at this resource. This method is commonly used to check if there is a specific amount of resource free at a physical resource (this Resource instance) that is required by a virtualized resource (the given Resource).
      Parameters:
      resource - the resource to check if its capacity is available at the current resource
      Returns:
      true if the capacity required by the given Resource is free; false otherwise
      See Also:
    • isAmountAvailable

      default boolean isAmountAvailable(double amountToCheck)
      Checks if there is a specific amount of resource available (free), where such an amount is a double value that will be converted to long.

      This method is just a shorthand to avoid explicitly converting a double to long.

      Parameters:
      amountToCheck - the amount of resource to check if is free. The data unit depends on the implementing classes, according to the getUnit().
      Returns:
      true if the specified amount is free; false otherwise
      See Also:
    • isAmountAvailable

      boolean isAmountAvailable(long amountToCheck)
      Checks if there is a specific amount of resource available (free).
      Parameters:
      amountToCheck - the amount of resource to check if is free. The data unit depends on the implementing classes, according to the getUnit().
      Returns:
      true if the specified amount is free; false otherwise
      See Also:
    • getUnit

      String getUnit()
      Returns:
      the measurement unit of this resource.
    • isFull

      default boolean isFull()
      Checks if the resource is full or not.
      Returns:
      true if the storage is full, false otherwise
    • getPercentUtilization

      default double getPercentUtilization()
      Gets the current percentage of resource utilization. It is the percentage of the total resource capacity that is currently allocated.
      Returns:
      current resource utilization (allocation) percentage (in scale from 0 to 1)