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
public final class GoogleTaskEventsTraceReader extends TraceReaderBase
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:
process()
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
GoogleTaskEventsTraceReader.FieldIndex
The index of each field in the trace file.static class
GoogleTaskEventsTraceReader.MissingInfo
Defines the type of information missing in the trace file. -
Constructor Summary
Constructors Constructor Description GoogleTaskEventsTraceReader(CloudSim simulation, String filePath, Function<TaskEvent,Cloudlet> cloudletCreationFunction)
Instantiates aGoogleTaskEventsTraceReader
to read a "task events" file. -
Method Summary
Modifier and Type Method Description protected DatacenterBroker
createBrokerIfAbsent(String username)
Creates a new broker if a previous one with the specified username was not createdprotected Cloudlet
createCloudlet(TaskEvent taskEvent)
protected TaskEvent
createTaskEventFromTraceLine()
protected DatacenterBroker
getBroker()
Gets anDatacenterBroker
instance representing the username from the last trace line read.List<DatacenterBroker>
getBrokers()
Gets the List of brokers created according to the username from the trace file, representing a customer.protected Function<TaskEvent,Cloudlet>
getCloudletCreationFunction()
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.Simulation
getSimulation()
protected void
postProcess()
Executes any post-process after the trace file was totally parsed.protected void
preProcess()
There is no pre-process requirements for this implementation.Set<Cloudlet>
process()
Process thetrace file
creating a Set ofCloudlet
s described in the file.protected boolean
processParsedLineInternal()
Process the last parsed trace line.void
setCloudletCreationFunction(Function<TaskEvent,Cloudlet> cloudletCreationFunction)
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
-
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:
process()
-
-
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
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:
getBrokers()
-
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. -
processParsedLineInternal
protected boolean processParsedLineInternal()Process the last parsed trace line.- Returns:
- true if the parsed line was processed, false otherwise
- See Also:
processParsedLine(String[])
,TraceReaderBase.getLastParsedLineArray()
-
createTaskEventFromTraceLine
-
createCloudlet
-
getCloudletCreationFunction
Gets aFunction
that will be called for everyCloudlet
to be created from a line inside the trace file.- Returns:
- See Also:
setCloudletCreationFunction(Function)
-
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 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
-
getBrokers
Gets the List of brokers created according to the username from the trace file, representing a customer.- Returns:
-
createBrokerIfAbsent
Creates a new broker if a previous one with the specified username was not created- Parameters:
username
- the username of the broker- Returns:
- an already existing broker with the given username or a new one if there was no broker with such an username
-
getBroker
Gets anDatacenterBroker
instance representing the username from the last trace line read.- Returns:
- the
DatacenterBroker
instance
-
getSimulation
-