Class GoogleTaskEventsTraceReader

All Implemented Interfaces:
TraceReader

public class GoogleTaskEventsTraceReader extends TraceReaderBase
Process "task events" trace files from Google Cluster Data to create Cloudlets 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 Details

    • cloudletEvents

      protected final Map<Cloudlet,List<CloudSimEvent>> cloudletEvents
      List of messages to send to the DatacenterBroker 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 IOException
      Instantiates a GoogleTaskEventsTraceReader 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 - A Function that will be called for every Cloudlet to be created from a line inside the trace file. The Function will receive a TaskEvent 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 empty
      UncheckedIOException - 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 a GoogleTaskEventsTraceReader 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 - a InputStream object to read the file
      cloudletCreationFunction - A Function that will be called for every Cloudlet to be created from a line inside the trace file. The Function will receive a TaskEvent 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 empty
      UncheckedIOException - 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 a GoogleTaskEventsTraceReader 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 - A Function that will be called for every Cloudlet to be created from a line inside the trace file. The Function will receive a TaskEvent 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 empty
      UncheckedIOException - when the file cannot be accessed (such as when it doesn't exist)
      See Also:
    • process

      public final Collection<Cloudlet> process()
      Process the trace file creating a Set of Cloudlets described in the file. Each created Cloudlet is automatically submitted to its respective broker.

      It returns the Set of all submitted Cloudlets at any timestamp inside the trace file (the timestamp is used to delay the Cloudlet submission).

      Returns:
      the Set of all submitted Cloudlets 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

      protected void sendCloudletEvents(List<CloudSimEvent> events)
    • processParsedLineInternal

      protected boolean processParsedLineInternal()
      Process the last parsed trace line.
      Returns:
      true if the parsed line was processed, false otherwise
      See Also:
    • createCloudlet

      protected Cloudlet createCloudlet(TaskEvent taskEvent)
    • getCloudletCreationFunction

      protected Function<TaskEvent,Cloudlet> getCloudletCreationFunction()
      Gets a Function that will be called for every Cloudlet to be created from a line inside the trace file.
      Returns:
      See Also:
    • setCloudletCreationFunction

      public void setCloudletCreationFunction(Function<TaskEvent,Cloudlet> cloudletCreationFunction)
      Sets a Function that will be called for every Cloudlet to be created from a line inside the trace file. The Function will receive a TaskEvent 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 - the Function to set
    • getSimulation

      public CloudSim getSimulation()
    • getMaxCloudletsToCreate

      public int getMaxCloudletsToCreate()
      Gets the maximum number of Cloudlets to create from the trace file.
      Returns:
      See Also:
    • setMaxCloudletsToCreate

      public GoogleTaskEventsTraceReader setMaxCloudletsToCreate(int maxCloudletsToCreate)
      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 the TraceReaderAbstract.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. Use Integer.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

      public GoogleTaskEventsTraceReader setAutoSubmitCloudlets(boolean autoSubmitCloudlets)
      Sets if Cloudlets must be auto-submitted to the broker after created (default is true).
      Parameters:
      autoSubmitCloudlets - true to auto-submit, false otherwise
    • getBrokerManager

      public BrokerManager getBrokerManager()
      Gets the manager that creates and provide access to DatacenterBrokers used by the trace reader.
      Returns:
    • availableObjectsCount

      protected final int availableObjectsCount()
      Gets the number of objects available (created) so far.
      Returns:
    • getAvailableObjects

      protected Collection<Cloudlet> getAvailableObjects()
    • findObject

      protected final Optional<Cloudlet> findObject(long id)