WorkloadFileReader (cloudsim 3.1-SNAPSHOT API)

org.cloudbus.cloudsim.util

## Class WorkloadFileReader

- java.lang.Object
- - org.cloudbus.cloudsim.util.WorkloadFileReader

- All Implemented Interfaces:
    WorkloadModel

      public class WorkloadFileReader
      extends Object
      implements WorkloadModel

  This class is responsible for reading resource traces from a file and creating a list of jobs.

  NOTE:

  - This class can only take `one` trace file of the following format: ASCII text, zip, gz.
  - If you need to load multiple trace files, then you need to create multiple instances of this class `each with a unique entity name`.
  - If size of the trace file is huge or contains lots of traces please increase the JVM heap size accordingly by using `java -Xmx` option when running the simulation.
  - The default job file size for sending to and receiving from a resource is `gridsim.net.Link#DEFAULT_MTU`. However, you can specify the file size by using `#setGridletFileSize(int)`.
  - A job run time is only for 1 PE `not` the total number of allocated PEs. Therefore, a Gridlet length is also calculated for 1 PE.
    For example, job #1 in the trace has a run time of 100 seconds for 2 processors. This means each processor runs job #1 for 100 seconds, if the processors have the same specification.

  By default, this class follows the standard workload format as specified in http://www.cs.huji.ac.il/labs/parallel/workload/
  However, you can use other format by calling the below methods before running the simulation:

  - `setComment(String)`
  - `setField(int, int, int, int, int)`
  Since:
    5.0
  Author:
    Anthony Sulistio and Marcos Dias de Assuncao
  See Also:
    `Workload`

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `WorkloadFileReader(String fileName, int rating)` Create a new `WorkloadFileReader` object.

  - ### Method Summary

    Methods
    Modifier and Type | Method and Description
    --- | ---
    `ArrayList<Cloudlet>` | `generateWorkload()` Reads job information from a given file.
    `boolean` | `setComment(String cmt)` Identifies the start of a comment line.
    `boolean` | `setField(int maxField, int jobNum, int submitTime, int runTime, int numProc)` Tells this class what to look in the trace file.

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### WorkloadFileReader

          public WorkloadFileReader(String fileName,
                            int rating)
                             throws FileNotFoundException

      Create a new `WorkloadFileReader` object.
      Parameters:
        `fileName` - the workload trace filename in one of the following format: ASCII text, zip, gz.
        `rating` - the resource's PE rating
      Throws:
        `FileNotFoundException`
        `IllegalArgumentException` - This happens for the following conditions:
        - the workload trace file name is null or empty
        - the resource PE rating <= 0

  - ### Method Detail

    - #### generateWorkload

          public ArrayList<Cloudlet> generateWorkload()

      Reads job information from a given file.
      Specified by:
        `generateWorkload` in interface `WorkloadModel`
      Returns:
        the list of gridlets read from the file; `null` in case of failure.

    - #### setComment

          public boolean setComment(String cmt)

      Identifies the start of a comment line.
      Parameters:
        `cmt` - a character that denotes the start of a comment, e.g. ";" or "#"
      Returns:
        `true` if it is successful, `false` otherwise

    - #### setField

          public boolean setField(int maxField,
                         int jobNum,
                         int submitTime,
                         int runTime,
                         int numProc)

      Tells this class what to look in the trace file. This method should be called before the start of the simulation.

      By default, this class follows the standard workload format as specified in http://www.cs.huji.ac.il/labs/parallel/workload/
      However, you can use other format by calling this method.

      The parameters must be a positive integer number starting from 1. A special case is where `jobNum == -1`, meaning the job or gridlet ID starts at 1.

      Parameters:
        `maxField` - max. number of field/column in one row
        `jobNum` - field/column number for locating the job ID
        `submitTime` - field/column number for locating the job submit time
        `runTime` - field/column number for locating the job run time
        `numProc` - field/column number for locating the number of PEs required to run a job
      Returns:
        `true` if successful, `false` otherwise
      Throws:
        `IllegalArgumentException` - if any of the arguments are not within the acceptable ranges

Copyright © 2013 The Cloud Computing and Distributed Systems (CLOUDS) Laboratory, The University of Melbourne. All Rights Reserved.