GoogleMachineEventsTraceReader

public final class GoogleMachineEventsTraceReader extends GoogleTraceReaderAbstract<Host>

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.

Author:Manoel Campos da Silva Filho

See also: .getInstance(String,Function), .process()

Constructors

GoogleMachineEventsTraceReader

public GoogleMachineEventsTraceReader(String filePath, Function<MachineEvent, Host> hostCreationFunction)

Instantiates a GoogleMachineEventsTraceReader to read a “machine events” trace file. Created Hosts will have 16GB of maximum RAM and the maximum of 8 Pes.

Parameters:
  • filePath – the path to the trace file
  • 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
  • FileNotFoundException – when the trace file is not found

See also: .setMaxRamCapacity(long), .setMaxCpuCores(int), .process()

Methods

addHostToRemovalList

protected boolean addHostToRemovalList(Host host)

Adds a Host to the List of Hosts to be removed from the Datacenter.

Parameters:
  • host

addLaterAvailableHost

protected boolean addLaterAvailableHost(Host host)

Adds a Host that will become available for the Datacenter just at the time specified by the timestamp in the trace line, which is set as the host startup time.

Parameters:
  • host – the Host to be added

createHostFromTraceLine

protected Host createHostFromTraceLine()

Creates a Host instance from the last parsed line, using the given host create function.

Returns:the Host instance

getDatacenterForLaterHosts

public Datacenter getDatacenterForLaterHosts()

Gets the Datacenter where the Hosts with timestamp greater than 0 will be created.

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: .setMaxRamCapacity(long), .setMaxCpuCores(int), .process()

getMaxCpuCores

public int getMaxCpuCores()

Gets the maximum number of Pes (CPU cores) for created Hosts.

getMaxRamCapacity

public long getMaxRamCapacity()

Gets the maximum RAM capacity (in MB) for created Hosts.

getNumberOfHostsForRemoval

public int getNumberOfHostsForRemoval()

Gets the number of Hosts to be removed from some Datacenter.

getNumberOfLaterAvailableHosts

public int getNumberOfLaterAvailableHosts()

Gets the number of Hosts that are going to be created later, according to the timestamp in the trace file.

postProcess

protected void postProcess()

Process hosts events occurring for a timestamp greater than zero.

preProcess

protected void preProcess()

process

public Set<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.

processParsedLineInternal

protected boolean processParsedLineInternal()

setDatacenterForLaterHosts

public void setDatacenterForLaterHosts(Datacenter datacenterForLaterHosts)

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

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

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