Class UtilizationModelPlanetLab

java.lang.Object
org.cloudbus.cloudsim.utilizationmodels.UtilizationModelAbstract
org.cloudbus.cloudsim.utilizationmodels.UtilizationModelPlanetLab
All Implemented Interfaces:
UtilizationModel

public class UtilizationModelPlanetLab
extends UtilizationModelAbstract
Defines a resource utilization model based on a PlanetLab Datacenter workload (trace) file.

Each PlanetLab trace file available contains CPU utilization measured at every 5 minutes (300 seconds) inside PlanetLab VMs. This value in seconds is commonly used for the scheduling interval attribute when instantiating an object of this class.

  • Nested Class Summary

    Nested classes/interfaces inherited from interface org.cloudbus.cloudsim.utilizationmodels.UtilizationModel

    UtilizationModel.Unit
  • Field Summary

    Fields 
    Modifier and Type Field Description
    static int DEF_DATA_SAMPLES
    The number of 5 minutes intervals inside one day (24 hours), since the available PlanetLab traces store resource utilization collected every 5 minutes along 24 hours.
    static int DEF_SCHEDULING_INTERVAL
    The default interval between each data line inside a PlanetLab trace file (in seconds)

    Fields inherited from class org.cloudbus.cloudsim.utilizationmodels.UtilizationModelAbstract

    ALMOST_ZERO

    Fields inherited from interface org.cloudbus.cloudsim.utilizationmodels.UtilizationModel

    NULL
  • Constructor Summary

    Constructors 
    Constructor Description
    UtilizationModelPlanetLab​(java.lang.String workloadFilePath, double schedulingInterval)
    Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory.
    UtilizationModelPlanetLab​(java.lang.String workloadFilePath, double schedulingInterval, int dataSamples)
    Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory.
    UtilizationModelPlanetLab​(java.lang.String workloadFilePath, java.util.function.UnaryOperator<java.lang.Double> mapper)
    Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory.
  • Method Summary

    Modifier and Type Method Description
    int getDataSamples()
    Gets the number of data samples actually read from the trace file.
    static UtilizationModelPlanetLab getInstance​(java.lang.String workloadFilePath)
    Instantiates a new PlanetLab utilization model from a trace file inside the application's resource directory, considering that the interval between each data line inside a PlanetLab trace file is the default one.
    static UtilizationModelPlanetLab getInstance​(java.lang.String workloadFilePath, double schedulingInterval)
    Instantiates a PlanetLab utilization model from a trace file located inside the application's resource directory.
    static UtilizationModelPlanetLab getInstance​(java.lang.String workloadFilePath, java.util.function.UnaryOperator<java.lang.Double> mapper)
    Instantiates a PlanetLab utilization model from a trace file located inside the application's resource directory.
    protected int getIntervalSize​(int startIndex, int endIndex)
    Gets the number of utilization samples between two indexes.
    double getSchedulingInterval()
    Gets the time interval (in seconds) in which precise utilization can be got from the workload file.
    double getUtilization​(double time)
    Gets the expected utilization of resource at a given simulation time.
    void setSchedulingInterval​(double schedulingInterval)
    Sets the scheduling interval.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEF_DATA_SAMPLES

      public static final int DEF_DATA_SAMPLES
      The number of 5 minutes intervals inside one day (24 hours), since the available PlanetLab traces store resource utilization collected every 5 minutes along 24 hours. This is default number of samples to try to read from the trace file if a different value isn't provided to the constructors.
      See Also:
      Constant Field Values
    • DEF_SCHEDULING_INTERVAL

      public static final int DEF_SCHEDULING_INTERVAL
      The default interval between each data line inside a PlanetLab trace file (in seconds)
      See Also:
      Constant Field Values
  • Constructor Details

    • UtilizationModelPlanetLab

      public UtilizationModelPlanetLab​(java.lang.String workloadFilePath, double schedulingInterval) throws java.lang.NumberFormatException
      Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory.

      It checks if the first line of the trace has a comment representing its number of lines. In this case, it will be used to accordingly create an array of that size to store the values read from the trace. If the file doesn't have such a comment with a valid line number, it will be tried to read just DEF_DATA_SAMPLES lines from the trace.

      Parameters:
      workloadFilePath - the path of a PlanetLab Datacenter workload file.
      schedulingInterval - the time interval in which precise utilization can be got from the file
      Throws:
      java.lang.NumberFormatException - when a value inside the side is not a valid number
      See Also:
      getSchedulingInterval(), getInstance(String)
    • UtilizationModelPlanetLab

      public UtilizationModelPlanetLab​(java.lang.String workloadFilePath, java.util.function.UnaryOperator<java.lang.Double> mapper) throws java.lang.NumberFormatException
      Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory.

      It checks if the first line of the trace has a comment representing its number of lines. In this case, it will be used to accordingly create an array of that size to store the values read from the trace. If the file doesn't have such a comment with a valid line number, it will be tried to read just DEF_DATA_SAMPLES lines from the trace.

      Parameters:
      workloadFilePath - the path of a PlanetLab Datacenter workload file.
      mapper - A UnaryOperator Function that will be used to map the utilization values read from the trace value to a different value. That Function is useful when you don't want to use the values from the trace as they are, but you want to scale the values applying any mathematical operation over them. For instance, you can provide a mapper Function that scale the values in 10 times, by giving a Lambda Expression such as setMapper(value -> value * 10).

      If a mapper Function is not set, the values are used as read from the trace file, without any change (except that the scale is always converted to [0..1]).

      Throws:
      java.lang.NumberFormatException - when a value inside the side is not a valid number
      See Also:
      getSchedulingInterval(), getInstance(String)
    • UtilizationModelPlanetLab

      public UtilizationModelPlanetLab​(java.lang.String workloadFilePath, double schedulingInterval, int dataSamples) throws java.lang.NumberFormatException
      Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory.
      Parameters:
      workloadFilePath - the path of a PlanetLab Datacenter workload file.
      schedulingInterval - the time interval in which precise utilization can be got from the file
      dataSamples - number of samples to read from the workload file. If -1 is given, it checks if the first line of the trace has a comment. In this case, that comment is expected to represent the number of lines inside the trace and it will be used to accordingly create an array of that size to store the values read from the trace. If the file doesn't have such a comment with a valid line number, it will be tried to read just DEF_DATA_SAMPLES lines from the trace.
      Throws:
      java.lang.NumberFormatException - when a value inside the side is not a valid number
      See Also:
      getSchedulingInterval(), getInstance(String)
  • Method Details

    • getInstance

      public static UtilizationModelPlanetLab getInstance​(java.lang.String workloadFilePath)
      Instantiates a new PlanetLab utilization model from a trace file inside the application's resource directory, considering that the interval between each data line inside a PlanetLab trace file is the default one.

      It checks if the first line of the trace has a comment representing its number of lines. In this case, it will be used to accordingly create an array of that size to store the values read from the trace. If the file doesn't have such a comment with a valid line number, it will be tried to read just DEF_DATA_SAMPLES lines from the trace.

      Parameters:
      workloadFilePath - the relative path of a PlanetLab Datacenter trace file.
      Throws:
      java.lang.NumberFormatException - when a value inside the side is not a valid number
      See Also:
      getSchedulingInterval()
    • getInstance

      public static UtilizationModelPlanetLab getInstance​(java.lang.String workloadFilePath, double schedulingInterval)
      Instantiates a PlanetLab utilization model from a trace file located inside the application's resource directory.

      It checks if the first line of the trace has a comment representing its number of lines. In this case, it will be used to accordingly create an array of that size to store the values read from the trace. If the file doesn't have such a comment with a valid line number, it will be tried to read just DEF_DATA_SAMPLES lines from the trace.

      Parameters:
      workloadFilePath - the relative path of a PlanetLab Datacenter trace file.
      schedulingInterval - the time interval in which precise utilization can be got from the file
      Throws:
      java.lang.NumberFormatException - when a value inside the side is not a valid number
      See Also:
      getSchedulingInterval()
    • getInstance

      public static UtilizationModelPlanetLab getInstance​(java.lang.String workloadFilePath, java.util.function.UnaryOperator<java.lang.Double> mapper) throws java.lang.NumberFormatException
      Instantiates a PlanetLab utilization model from a trace file located inside the application's resource directory.

      It checks if the first line of the trace has a comment representing its number of lines. In this case, it will be used to accordingly create an array of that size to store the values read from the trace. If the file doesn't have such a comment with a valid line number, it will be tried to read just DEF_DATA_SAMPLES lines from the trace.

      Parameters:
      workloadFilePath - the path of a PlanetLab Datacenter workload file.
      mapper - A UnaryOperator Function that will be used to map the utilization values read from the trace value to a different value. That Function is useful when you don't want to use the values from the trace as they are, but you want to scale the values applying any mathematical operation over them. For instance, you can provide a mapper Function that scale the values in 10 times, by giving a Lambda Expression such as setMapper(value -> value * 10).

      If a mapper Function is not set, the values are used as read from the trace file, without any change (except that the scale is always converted to [0..1]).

      mapper - a UnaryOperator Function to set
      Throws:
      java.lang.NumberFormatException - when a value inside the side is not a valid number
      See Also:
      getSchedulingInterval(), getInstance(String)
    • getDataSamples

      public int getDataSamples()
      Gets the number of data samples actually read from the trace file.
      Returns:
    • getUtilization

      public double getUtilization​(double time)
      Description copied from interface: UtilizationModel
      Gets the expected utilization of resource at a given simulation time. Such a value can be a percentage in scale from [0 to 1] or an absolute value, depending on the UtilizationModel.getUnit().

      It is an expected usage value because the actual Cloudlet resource usage depends on the available Vm resource.

      Parameters:
      time - the time to get the resource usage.
      Returns:
      the resource utilization at the given time
      See Also:
      UtilizationModel.getUnit()
    • getIntervalSize

      protected final int getIntervalSize​(int startIndex, int endIndex)
      Gets the number of utilization samples between two indexes.

      Since the utilization array is implemented as a circular list, when the last index is read, it restarts from the first index again. Accordingly, we can have situations where the end index is the last array element and the start index is the first or some subsequent index. This way, computing the difference between the two indexes would return a negative value. The method ensures that a positive value is returned, correctly computing the size of the interval between the two indexes.

      Consider that the trace file has 288 lines, indexed from line 0 to 287. Think of the trace as a circular list with indexes 0, 1, 2, 3 ...... 286, 287, 0, 1, 2, 3 ... If the start index is 286 and the end index 2, then the interval size is 4 (the number of indexes between 286 and 2).

      Parameters:
      startIndex - the start index in the interval
      endIndex - the end index in the interval
      Returns:
      the number of samples inside such indexes interval
    • getSchedulingInterval

      public double getSchedulingInterval()
      Gets the time interval (in seconds) in which precise utilization can be got from the workload file.

      That means if the getUtilization(double) is called passing any time that is multiple of this scheduling interval, the utilization returned will be the value stored for that specific time. Otherwise, the value will be an arithmetic mean of the beginning and the ending of the interval in which the given time is.

      Returns:
      the scheduling interval in seconds
    • setSchedulingInterval

      public final void setSchedulingInterval​(double schedulingInterval)
      Sets the scheduling interval.
      Parameters:
      schedulingInterval - the scheduling interval to set
      See Also:
      getSchedulingInterval()