Class GoogleMachineEventsTraceReader

All Implemented Interfaces:
TraceReader

public final class GoogleMachineEventsTraceReader extends TraceReaderBase
Process "machine events" trace files from Google Cluster Data. When a trace file is processed, it creates a list of available Hosts 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:
  • Constructor Details

  • Method Details

    • getInstance

      public static GoogleMachineEventsTraceReader getInstance(String filePath, Function<MachineEvent,Host> hostCreationFunction)
      Gets a GoogleMachineEventsTraceReader 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 8 Pes. 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 - A Function that will be called for every Host to be created from a line inside the trace file. The Function will receive a MachineEvent 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 empty
      UncheckedIOException - when the file cannot be accessed (such as when it doesn't exist)
      See Also:
    • process

      public Collection<Host> process()
      Process the trace file creating a Set of Hosts described in the file.

      It returns the Set of Hosts 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 Hosts 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

      public Datacenter getDatacenterForLaterHosts()
      Gets the Datacenter where the Hosts with timestamp greater than 0 will be created.
      Returns:
    • setDatacenterForLaterHosts

      public void setDatacenterForLaterHosts(Datacenter datacenterForLaterHosts)
    • 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 of Pes (CPU cores) for created Hosts.
      Returns:
    • setMaxCpuCores

      public void setMaxCpuCores(int maxCpuCores)
      Sets the maximum number of Pes (CPU cores) for created Hosts.
      Parameters:
      maxCpuCores - the maximum number of Pes (CPU cores) to set
    • setHostCreationFunction

      public void setHostCreationFunction(Function<MachineEvent,Host> hostCreationFunction)
      Sets a BiFunction that will be called for every Host to be created from a line inside the trace file. The BiFunction will receive the number of Pes (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 creation BiFunction to set
    • availableObjectsCount

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

      protected Collection<Host> getAvailableObjects()
    • findObject

      protected final Optional<Host> findObject(long id)