Class GoogleMachineEventsTraceReader
- All Implemented Interfaces:
TraceReader
processed
, it creates a list of available Host
s for every line with a zero timestamp
and the event type
equals to MachineEventType.ADD
, meaning
that such Hosts will be immediately available at the simulation start.
Hosts addition events with timestamp greater than zero will be scheduled to be added
just at the specified type. In the same way, Hosts removal are accordingly scheduled.
Such trace files are the ones inside the machine_events sub-directory of downloaded Google traces. The instructions to download the traces are provided in the link above. A spreadsheet that makes it easier to understand the structure of trace files is provided in docs/google-cluster-data-samples.xlsx
The documentation for fields and values were obtained from the Google Cluster trace documentation in the link above. It's strongly recommended to read such a documentation before trying to use this class.
Check important details at TraceReaderAbstract
.
- Since:
- CloudSim Plus 4.0.0
- Author:
- Manoel Campos da Silva Filho
- See Also:
-
Field Summary
Fields inherited from interface org.cloudbus.cloudsim.util.TraceReader
LOGGER
-
Constructor Summary
ConstructorDescriptionGoogleMachineEventsTraceReader
(String filePath, Function<MachineEvent, Host> hostCreationFunction) Instantiates a GoogleMachineEventsTraceReader to read a "machine events" trace file. -
Method Summary
Modifier and TypeMethodDescriptionprotected final int
Gets the number of objects available (created) so far.findObject
(long id) protected Collection<Host>
Gets the Datacenter where the Hosts with timestamp greater than 0 will be created.getInstance
(String filePath, Function<MachineEvent, Host> hostCreationFunction) Gets aGoogleMachineEventsTraceReader
instance to read a "machine events" trace file inside the application's resource directory.int
Gets the maximum number ofPe
s (CPU cores) for created Hosts.long
Gets the maximum RAM capacity (in MB) for created Hosts.int
Gets the number of Hosts to be removed from some Datacenter.int
Gets the number of Hosts that are going to be created later, according to the timestamp in the trace file.protected void
Process hosts events occurring for a timestamp greater than zero.protected void
Executes any pre-process before starting to read the trace file, such as checking if required attributes were set.process()
Process thetrace file
creating a Set ofHost
s described in the file.protected boolean
Process the last parsed trace line.void
setDatacenterForLaterHosts
(Datacenter datacenterForLaterHosts) void
setHostCreationFunction
(Function<MachineEvent, Host> hostCreationFunction) Sets aBiFunction
that will be called for everyHost
to be created from a line inside the trace file.void
setMaxCpuCores
(int maxCpuCores) Sets the maximum number ofPe
s (CPU cores) for created Hosts.void
setMaxRamCapacity
(long maxRamCapacity) Sets the maximum RAM capacity (in MB) for created Hosts.Methods inherited from class org.cloudsimplus.traces.TraceReaderBase
getFieldDoubleValue, getFieldDoubleValue, getFieldIntValue, getFieldIntValue, getFieldLongValue, getFieldLongValue, getFieldValue, getLastParsedLineArray, setLastParsedLineArray
Methods inherited from class org.cloudbus.cloudsim.util.TraceReaderAbstract
getCommentString, getFieldDelimiterRegex, getFilePath, getInputStream, getLastLineNumber, getMaxLinesToRead, parseTraceLine, readFile, readGZIPFile, readTextFile, readZipFile, setCommentString, setFieldDelimiterRegex, setMaxLinesToRead
-
Constructor Details
-
GoogleMachineEventsTraceReader
public GoogleMachineEventsTraceReader(String filePath, Function<MachineEvent, Host> hostCreationFunction) throws IOExceptionInstantiates a GoogleMachineEventsTraceReader to read a "machine events" trace file. Created Hosts will have 16GB of maximum RAM and the maximum of 8Pe
s.- Parameters:
filePath
- the path to the trace filehostCreationFunction
- AFunction
that will be called for everyHost
to be created from a line inside the trace file. TheFunction
will receive aMachineEvent
object containing the Host data read from the trace and must return the created Host according to such data.- Throws:
FileNotFoundException
- when the trace file is not foundIllegalArgumentException
- when the trace file name is null or emptyIOException
- See Also:
-
-
Method Details
-
getInstance
public static GoogleMachineEventsTraceReader getInstance(String filePath, Function<MachineEvent, Host> hostCreationFunction) Gets aGoogleMachineEventsTraceReader
instance to read a "machine events" trace file inside the application's resource directory. Created Hosts will have 16GB of maximum RAM and the maximum of 8Pe
s. Use the available constructors if you want to load a file outside the resource directory.- Parameters:
filePath
- the workload trace relative file name in one of the following formats: ASCII text, zip, gz.hostCreationFunction
- AFunction
that will be called for everyHost
to be created from a line inside the trace file. TheFunction
will receive aMachineEvent
object containing the Host data read from the trace and must return the created Host according to such data.- Throws:
IllegalArgumentException
- when the trace file name is null or emptyUncheckedIOException
- when the file cannot be accessed (such as when it doesn't exist)- See Also:
-
process
Process thetrace file
creating a Set ofHost
s described in the file.It returns the Set of
Host
s that were available at timestamp 0 inside the trace file. Hosts available just after this initial timestamp (that represents the beginning of the simulation) will be dynamically requested to be created by sending a message to the given Datacenter.The Set of returned Hosts is not added to any Datacenter. The developer creating the simulation must add such Hosts to any Datacenter desired.
- Returns:
- the Set of
Host
s that were available at timestamp 0 inside the trace file.
-
preProcess
protected void preProcess()Executes any pre-process before starting to read the trace file, such as checking if required attributes were set. TODO Such a method should be defined as a Functional attribute. Since it won't be implemented by every subclass, by it being abstract, forces to subclasses to implement it (even if just including an empty method). -
postProcess
protected void postProcess()Process hosts events occurring for a timestamp greater than zero. -
processParsedLineInternal
protected boolean processParsedLineInternal()Process the last parsed trace line.- Returns:
- true if the parsed line was processed, false otherwise
- See Also:
-
getNumberOfLaterAvailableHosts
public int getNumberOfLaterAvailableHosts()Gets the number of Hosts that are going to be created later, according to the timestamp in the trace file.- Returns:
-
getNumberOfHostsForRemoval
public int getNumberOfHostsForRemoval()Gets the number of Hosts to be removed from some Datacenter.- Returns:
-
getDatacenterForLaterHosts
Gets the Datacenter where the Hosts with timestamp greater than 0 will be created.- Returns:
-
setDatacenterForLaterHosts
-
getMaxRamCapacity
public long getMaxRamCapacity()Gets the maximum RAM capacity (in MB) for created Hosts.- Returns:
-
setMaxRamCapacity
public void setMaxRamCapacity(long maxRamCapacity) Sets the maximum RAM capacity (in MB) for created Hosts.- Parameters:
maxRamCapacity
- the maximum RAM capacity (in MB) to set
-
getMaxCpuCores
public int getMaxCpuCores()Gets the maximum number ofPe
s (CPU cores) for created Hosts.- Returns:
-
setMaxCpuCores
public void setMaxCpuCores(int maxCpuCores) Sets the maximum number ofPe
s (CPU cores) for created Hosts.- Parameters:
maxCpuCores
- the maximum number ofPe
s (CPU cores) to set
-
setHostCreationFunction
Sets aBiFunction
that will be called for everyHost
to be created from a line inside the trace file. TheBiFunction
will receive the number ofPe
s (CPU cores) and RAM capacity for the Host to be created, returning the created Host. The provided function must instantiate the Host and defines Host's CPU cores and RAM capacity according the the received parameters. For other Hosts configurations (such as storage capacity), the provided function must define the value as desired, since the trace file doesn't have any other information for such resources.- Parameters:
hostCreationFunction
- the Host creationBiFunction
to set
-
availableObjectsCount
protected final int availableObjectsCount()Gets the number of objects available (created) so far.- Returns:
-
getAvailableObjects
-
findObject
-