Class TraceReaderAbstract

java.lang.Object
org.cloudsimplus.traces.FileReader
org.cloudsimplus.traces.TraceReaderAbstract
All Implemented Interfaces:
TraceReader
Direct Known Subclasses:
GoogleMachineEventsTraceReader, GoogleTaskEventsTraceReader, GoogleTaskUsageTraceReader, SwfWorkloadFileReader

public abstract class TraceReaderAbstract extends FileReader implements TraceReader

An abstract class to implement trace file readers for specific file formats.

NOTES

  • This class can only read trace files in the following format: ASCII text, zip, gz.
  • If you need to load multiple trace files, create multiple instances of this class.
  • If the size of the trace reader is huge or contains lots of traces, please increase the JVM heap size accordingly by using java -Xmx option when running the simulation. For instance, you can use java -Xmx200M to define the JVM heap size will be 200MB.
Since:
CloudSim Plus 4.0.0
Author:
Manoel Campos da Silva Filho
  • Constructor Details

    • TraceReaderAbstract

      public TraceReaderAbstract(@NonNull @NonNull String filePath)
      Create a TraceReader object.
      Parameters:
      filePath - the workload trace file path in one of the following formats: ASCII text, zip, gz.
      Throws:
      IllegalArgumentException - when the workload trace file name is null or empty; or the resource PE mips is less or equal to 0
      IllegalArgumentException - when the workload trace file name is null or empty
  • Method Details

    • getFieldValue

      public <T extends Enum> String getFieldValue(T field)
      Gets a field's value from the last parsed line as String.
      Parameters:
      field - an enum value representing the index of the field to get the value
      Returns:
      the field value as String
    • getFieldDoubleValue

      public <T extends Enum> double getFieldDoubleValue(T field)
      Gets a field's value from the last parsed line as double.
      Parameters:
      field - an enum value representing the index of the field to get the value
      Returns:
      the field value as double
    • getFieldDoubleValue

      public <T extends Enum> double getFieldDoubleValue(T field, double defaultValue)
      Gets a field's value from the last parsed line as double.
      Parameters:
      field - an enum value representing the index of the field to get the value
      defaultValue - the default value to be returned if the field value is not a number
      Returns:
      the field value as double
    • getFieldIntValue

      public <T extends Enum> int getFieldIntValue(T field)
      Gets a field's value from the last parsed line as an int.
      Parameters:
      field - an enum value representing the index of the field to get the value
      Returns:
      the field value as int
    • getFieldIntValue

      public <T extends Enum> int getFieldIntValue(T field, int defaultValue)
      Gets a field's value from the last parsed line as an int.
      Parameters:
      field - an enum value representing the index of the field to get the value
      defaultValue - the default value to be returned if the field value is not an int
      Returns:
      the field value as int
    • getFieldLongValue

      public <T extends Enum> long getFieldLongValue(T field)
      Gets a field's value from the last parsed line as an int.
      Parameters:
      field - an enum value representing the index of the field to get the value
      Returns:
      the field value as long
    • getFieldLongValue

      public <T extends Enum> long getFieldLongValue(T field, long defaultValue)
      Gets a field's value from the last parsed line as an int.
      Parameters:
      field - an enum value representing the index of the field to get the value
      defaultValue - the default value to be returned if the field value is not an int
      Returns:
      the field value as long
    • getLastParsedLineArray

      protected String[] getLastParsedLineArray()
      Returns:
      an array containing the field values from the last parsed trace line.
    • setLastParsedLineArray

      protected void setLastParsedLineArray(@NonNull @NonNull String[] lastParsedLineArray)
      Sets an array containing the field values from the last parsed trace line.
      Parameters:
      lastParsedLineArray - the field values from the last parsed trace line