Package org.cloudsimplus.traces.google
Class GoogleTaskEventsTraceReader
java.lang.Object
org.cloudbus.cloudsim.util.TraceReaderAbstract
org.cloudsimplus.traces.TraceReaderBase
org.cloudsimplus.traces.google.GoogleTaskEventsTraceReader
- All Implemented Interfaces:
TraceReader
Process "task events" trace files from
Google Cluster Data
to create
Cloudlet
s belonging to cloud customers (users).
Customers are represented as DatacenterBroker
instances created from the trace file.
The trace files are the ones inside the task_events sub-directory of downloaded Google traces.
The instructions to download the traces are provided in the link above.
The class also creates the required brokers to represent the customers (users) defined by the username field inside the trace file.
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
Modifier and TypeFieldDescriptionprotected final Map<Cloudlet,
List<CloudSimEvent>> List of messages to send to theDatacenterBroker
that owns each created Cloudlet.Fields inherited from interface org.cloudbus.cloudsim.util.TraceReader
LOGGER
-
Constructor Summary
ModifierConstructorDescriptionprotected
GoogleTaskEventsTraceReader
(CloudSim simulation, String filePath, InputStream reader, Function<TaskEvent, Cloudlet> cloudletCreationFunction) Instantiates aGoogleTaskEventsTraceReader
to read a "task events" from a given InputStream.GoogleTaskEventsTraceReader
(CloudSim simulation, String filePath, Function<TaskEvent, Cloudlet> cloudletCreationFunction) Instantiates aGoogleTaskEventsTraceReader
to read a "task events" file. -
Method Summary
Modifier and TypeMethodDescriptionprotected boolean
Checks if the maximum number of Cloudlets to create was not reached.protected final int
Gets the number of objects available (created) so far.protected Cloudlet
createCloudlet
(TaskEvent taskEvent) findObject
(long id) protected Collection<Cloudlet>
Gets the manager that creates and provide access toDatacenterBroker
s used by the trace reader.static GoogleTaskEventsTraceReader
getInstance
(CloudSim simulation, String filePath, Function<TaskEvent, Cloudlet> cloudletCreationFunction) Gets aGoogleTaskEventsTraceReader
instance to read a "task events" trace file inside the application's resource directory.int
Gets the maximum number of Cloudlets to create from the trace file.boolean
Checks if Cloudlets will be auto-submitted to the broker after created (default is true).protected void
Executes any post-process after the trace file was totally parsed.protected void
There is no pre-process requirements for this implementation.final Collection<Cloudlet>
process()
Process thetrace file
creating a Set ofCloudlet
s described in the file.protected boolean
Process the last parsed trace line.protected void
sendCloudletEvents
(List<CloudSimEvent> events) setAutoSubmitCloudlets
(boolean autoSubmitCloudlets) Sets if Cloudlets must be auto-submitted to the broker after created (default is true).void
setCloudletCreationFunction
(Function<TaskEvent, Cloudlet> cloudletCreationFunction) setMaxCloudletsToCreate
(int maxCloudletsToCreate) Sets the maximum number of Cloudlets to create from the trace file.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
-
Field Details
-
cloudletEvents
List of messages to send to theDatacenterBroker
that owns each created Cloudlet. Such events request a Cloudlet's status change or attributes change.- See Also:
-
addCloudletStatusChangeEvents(CloudSimEvent, TaskEvent)
-
-
Constructor Details
-
GoogleTaskEventsTraceReader
public GoogleTaskEventsTraceReader(CloudSim simulation, String filePath, Function<TaskEvent, Cloudlet> cloudletCreationFunction) throws IOExceptionInstantiates aGoogleTaskEventsTraceReader
to read a "task events" file.- Parameters:
simulation
- the simulation instance that the created tasks and brokers will belong to.filePath
- the workload trace relative file name in one of the following formats: ASCII text, zip, gz.cloudletCreationFunction
- AFunction
that will be called for everyCloudlet
to be created from a line inside the trace file. TheFunction
will receive aTaskEvent
object containing the task data read from the trace and must return a new Cloudlet 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)IOException
- See Also:
-
GoogleTaskEventsTraceReader
protected GoogleTaskEventsTraceReader(CloudSim simulation, String filePath, InputStream reader, Function<TaskEvent, Cloudlet> cloudletCreationFunction) Instantiates aGoogleTaskEventsTraceReader
to read a "task events" from a given InputStream.- Parameters:
simulation
- the simulation instance that the created tasks and brokers will belong to.filePath
- the workload trace relative file name in one of the following formats: ASCII text, zip, gz.reader
- aInputStream
object to read the filecloudletCreationFunction
- AFunction
that will be called for everyCloudlet
to be created from a line inside the trace file. TheFunction
will receive aTaskEvent
object containing the task data read from the trace and must return a new Cloudlet 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:
-
-
Method Details
-
getInstance
public static GoogleTaskEventsTraceReader getInstance(CloudSim simulation, String filePath, Function<TaskEvent, Cloudlet> cloudletCreationFunction) Gets aGoogleTaskEventsTraceReader
instance to read a "task events" trace file inside the application's resource directory.- Parameters:
simulation
- the simulation instance that the created tasks and brokers will belong to.filePath
- the workload trace relative file name in one of the following formats: ASCII text, zip, gz.cloudletCreationFunction
- AFunction
that will be called for everyCloudlet
to be created from a line inside the trace file. TheFunction
will receive aTaskEvent
object containing the task data read from the trace and must return a new Cloudlet 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 ofCloudlet
s described in the file. Each created Cloudlet is automatically submitted to its respective broker.It returns the Set of all submitted
Cloudlet
s at any timestamp inside the trace file (the timestamp is used to delay the Cloudlet submission).- Returns:
- the Set of all submitted
Cloudlet
s for any timestamp inside the trace file. - See Also:
-
preProcess
protected void preProcess()There is no pre-process requirements for this implementation. -
postProcess
protected void postProcess()Executes any post-process after the trace file was totally parsed. 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). -
sendCloudletEvents
-
processParsedLineInternal
protected boolean processParsedLineInternal()Process the last parsed trace line.- Returns:
- true if the parsed line was processed, false otherwise
- See Also:
-
createCloudlet
-
getCloudletCreationFunction
Gets aFunction
that will be called for everyCloudlet
to be created from a line inside the trace file.- Returns:
- See Also:
-
setCloudletCreationFunction
Sets aFunction
that will be called for everyCloudlet
to be created from a line inside the trace file. TheFunction
will receive aTaskEvent
object containing the task data read from the trace and should the created Cloudlet. The provided function must instantiate the Host and defines Host's CPU cores and RAM capacity according 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:
cloudletCreationFunction
- theFunction
to set
-
getSimulation
-
getMaxCloudletsToCreate
public int getMaxCloudletsToCreate()Gets the maximum number of Cloudlets to create from the trace file.- Returns:
- See Also:
-
setMaxCloudletsToCreate
Sets the maximum number of Cloudlets to create from the trace file. Since the number of lines in the file may be greater to the number of Cloudlets that will be created from it (since there may be lines representing different cloudlet requests, such as creation, execution, pause, destruction, etc), using theTraceReaderAbstract.setMaxLinesToRead(int)
may not ensure only a given number of Cloudlets will be created.- Parameters:
maxCloudletsToCreate
- the maximum number of Cloudlets to create from the file. UseInteger.MAX_VALUE
to disable this configuration.- Returns:
- See Also:
-
allowCloudletCreation
protected boolean allowCloudletCreation()Checks if the maximum number of Cloudlets to create was not reached.- Returns:
- true to indicate the Cloudlet is allowed to be created, false otherwise.
-
isAutoSubmitCloudlets
public boolean isAutoSubmitCloudlets()Checks if Cloudlets will be auto-submitted to the broker after created (default is true).- Returns:
- true if auto-submit is enabled, false otherwise
-
setAutoSubmitCloudlets
Sets if Cloudlets must be auto-submitted to the broker after created (default is true).- Parameters:
autoSubmitCloudlets
- true to auto-submit, false otherwise
-
getBrokerManager
Gets the manager that creates and provide access toDatacenterBroker
s used by the trace reader.- Returns:
-
availableObjectsCount
protected final int availableObjectsCount()Gets the number of objects available (created) so far.- Returns:
-
getAvailableObjects
-
findObject
-