Class UtilizationModelPlanetLab
- All Implemented Interfaces:
UtilizationModel
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
Modifier and TypeFieldDescriptionstatic final int
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 final int
The default interval between each data line inside a PlanetLab trace file (in seconds)protected final double[]
The resource utilization for an entire day, in intervals defined byschedulingInterval
(each line on available trace files represent resource utilization for a time interval of 5 minutes).Fields inherited from class org.cloudbus.cloudsim.utilizationmodels.UtilizationModelAbstract
ALMOST_ZERO
Fields inherited from interface org.cloudbus.cloudsim.utilizationmodels.UtilizationModel
NULL
-
Constructor Summary
ConstructorDescriptionUtilizationModelPlanetLab
(double[] utilization, double schedulingInterval, UnaryOperator<Double> mapper) A constructor that enables creating a PlanetLab UtilizationModel where the utilization data is provided directly utilization array parameter.UtilizationModelPlanetLab
(String workloadFilePath, double schedulingInterval) Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory.UtilizationModelPlanetLab
(String workloadFilePath, double schedulingInterval, int dataSamples) Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory.UtilizationModelPlanetLab
(String workloadFilePath, UnaryOperator<Double> mapper) Instantiates a new PlanetLab resource utilization model from a trace file outside the application's resource directory. -
Method Summary
Modifier and TypeMethodDescriptionint
Gets the number of data samples actually read from the trace file.static UtilizationModelPlanetLab
getInstance
(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 thedefault one
.static UtilizationModelPlanetLab
getInstance
(String workloadFilePath, double schedulingInterval) Instantiates a PlanetLab utilization model from a trace file located inside the application's resource directory.static UtilizationModelPlanetLab
getInstance
(String workloadFilePath, UnaryOperator<Double> mapper) Instantiates a PlanetLab utilization model from a trace file located inside the application's resource directory.protected final int
getIntervalSize
(int startIndex, int endIndex) Gets the number ofutilization
samples between two indexes.double
Gets the time interval (in seconds) in which precise utilization can be got from the workload file.protected double
getUtilizationInternal
(double time) final void
setSchedulingInterval
(double schedulingInterval) Sets the scheduling interval.Methods inherited from class org.cloudbus.cloudsim.utilizationmodels.UtilizationModelAbstract
getSimulation, getUnit, getUtilization, getUtilization, isOverCapacityRequestAllowed, setOverCapacityRequestAllowed, setSimulation, setUnit, validateUtilizationField, validateUtilizationField
-
Field Details
-
DEF_DATA_SAMPLES
public static final int DEF_DATA_SAMPLESThe 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:
-
DEF_SCHEDULING_INTERVAL
public static final int DEF_SCHEDULING_INTERVALThe default interval between each data line inside a PlanetLab trace file (in seconds)- See Also:
-
utilization
protected final double[] utilizationThe resource utilization for an entire day, in intervals defined byschedulingInterval
(each line on available trace files represent resource utilization for a time interval of 5 minutes). The size of the array is defined according to the number of utilization samples specified in the constructor.If there is a
mapper
Function set, the values are returned and stored according to the operation performed by such a Function. If no mapper Function is set, the values are returned and stored as read from the trace file (always in scale from 0 to 1).- See Also:
-
readWorkloadFile(InputStreamReader, int)
-
-
Constructor Details
-
UtilizationModelPlanetLab
public UtilizationModelPlanetLab(String workloadFilePath, double schedulingInterval) throws 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:
NumberFormatException
- when a value inside the side is not a valid number- See Also:
-
UtilizationModelPlanetLab
public UtilizationModelPlanetLab(String workloadFilePath, double schedulingInterval, int dataSamples) throws 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 filedataSamples
- 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 justDEF_DATA_SAMPLES
lines from the trace.- Throws:
NumberFormatException
- when a value inside the side is not a valid number- See Also:
-
UtilizationModelPlanetLab
public UtilizationModelPlanetLab(String workloadFilePath, UnaryOperator<Double> mapper) throws 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
- AUnaryOperator
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 asvalue -> 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:
NumberFormatException
- when a value inside the side is not a valid number- See Also:
-
UtilizationModelPlanetLab
public UtilizationModelPlanetLab(double[] utilization, double schedulingInterval, UnaryOperator<Double> mapper) throws NumberFormatException A constructor that enables creating a PlanetLab UtilizationModel where the utilization data is provided directly utilization array parameter. This can be used when you don't want to load the utilization data from a file.- Parameters:
utilization
- the resource utilization data for an entire day, in intervals defined by a scheduling interval. If the data inside the array represents resource utilization in intervals of 5 minutes, your scheduling interval must be 300 seconds.schedulingInterval
- the time interval in which precise utilization can be got from the filemapper
- AUnaryOperator
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 asvalue -> 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:
NumberFormatException
- when a value inside the side is not a valid number
-
-
Method Details
-
getInstance
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 thedefault 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:
NumberFormatException
- when a value inside the side is not a valid number- See Also:
-
getInstance
public static UtilizationModelPlanetLab getInstance(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:
NumberFormatException
- when a value inside the side is not a valid number- See Also:
-
getInstance
public static UtilizationModelPlanetLab getInstance(String workloadFilePath, UnaryOperator<Double> mapper) throws 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
- AUnaryOperator
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 asvalue -> 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:
NumberFormatException
- when a value inside the side is not a valid number- See Also:
-
getDataSamples
public int getDataSamples()Gets the number of data samples actually read from the trace file.- Returns:
-
getUtilizationInternal
protected double getUtilizationInternal(double time) - Specified by:
getUtilizationInternal
in classUtilizationModelAbstract
-
getIntervalSize
protected final int getIntervalSize(int startIndex, int endIndex) Gets the number ofutilization
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 intervalendIndex
- 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
UtilizationModelAbstract.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:
-