TraceReaderAbstract

public abstract class TraceReaderAbstract implements TraceReader

An abstract class providing features for subclasses implementing trace file readers for specific file formats.

Author:Manoel Campos da Silva Filho

Constructors

TraceReaderAbstract

public TraceReaderAbstract(String filePath)

Create a new SwfWorkloadFileReader 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
  • FileNotFoundException – when the trace file is not found

TraceReaderAbstract

protected TraceReaderAbstract(String filePath, InputStream reader)

Create a new SwfWorkloadFileReader object.

Parameters:
  • filePath – the workload trace file path in one of the following formats: ASCII text, zip, gz.
  • reader – a InputStreamReader object to read the file
Throws:
  • IllegalArgumentException – when the workload trace file name is null or empty; or the resource PE mips <= 0

Methods

getCommentString

public String[] getCommentString()

{@inheritDoc}

It’s returned a defensive copy of the array.

Returns:{@inheritDoc}

getFieldDelimiterRegex

public String getFieldDelimiterRegex()

getFilePath

public String getFilePath()

getMaxLinesToRead

public int getMaxLinesToRead()

getReader

protected InputStream getReader()

parseTraceLine

protected String[] parseTraceLine(String line)

readFile

protected void readFile(Function<String[], Boolean> processParsedLineFunction)

Reads traces from the file indicated by the getFilePath(), then creates a Cloudlet for each line read.

Parameters:
  • processParsedLineFunction – a Function that receives each parsed line as an array and performs an operation over it, returning true if the operation was executed
Throws:
  • UncheckedIOException – if the there was any error reading the reader
Returns:

true if successful, false otherwise.

readGZIPFile

protected void readGZIPFile(InputStream inputStream, Function<String[], Boolean> processParsedLineFunction)

Reads traces from a gzip reader, then creates a Cloudlet for each line read.

Parameters:
  • inputStream – a InputStream to read the file
  • processParsedLineFunction – a Function that receives each parsed line as an array and performs an operation over it, returning true if the operation was executed
Throws:
  • IOException – if the there was any error reading the reader
Returns:

true if successful; false otherwise.

readTextFile

protected void readTextFile(InputStream inputStream, Function<String[], Boolean> processParsedLineFunction)

Reads traces from a text reader, then creates a Cloudlet for each line read.

Parameters:
  • inputStream – a InputStream to read the file
  • processParsedLineFunction – a Function that receives each parsed line as an array and performs an operation over it, returning true if the operation was executed
Throws:
  • IOException – if the there was any error reading the reader
Returns:

true if successful, false otherwise.

readZipFile

protected boolean readZipFile(InputStream inputStream, Function<String[], Boolean> processParsedLineFunction)

Reads a set of trace files inside a Zip reader, then creates a Cloudlet for each line read.

Parameters:
  • inputStream – a InputStream to read the file
  • processParsedLineFunction – a Function that receives each parsed line as an array and performs an operation over it, returning true if the operation was executed
Throws:
  • IOException – if the there was any error reading the reader
Returns:

true if reading a reader is successful; false otherwise.

setCommentString

public TraceReader setCommentString(String... commentString)

setFieldDelimiterRegex

public final TraceReader setFieldDelimiterRegex(String fieldDelimiterRegex)

setMaxLinesToRead

public TraceReader setMaxLinesToRead(int maxLinesToRead)