Skip to content

Tutorial: Creating a Workload

yungsters edited this page Sep 14, 2010 · 3 revisions

This tutorial will help you create a Rain workload. A basic Rain workload consists of three (3) main components:

  1. A set of operation classes that can be executed to generate work.
    • For a key-value storage-type workload, operations might include GetOperation and SetOperation.
    • For an HTTP web application, operations might include HomePageOperation and LoginOperation.
  2. A generator class.
    • Indexes the operations and contains factory methods for instantiating operations.
    • Produces the next operation to execute given the last operation executed.
    • Generates the cycle time or think time to use (i.e. delay between operation executions).
  3. A JSON (JavaScript Object Notation) configuration file.

Requirements

The workload you want to generate must conform to the following fundamental requirements:

  • The target must have a single point of entry (i.e. IP address and port) accessible from a workload server.
  • The operations must be transcribable in Java.

Instructions

The following instructions will be accompanied by examples for creating a workload named example.

  1. Create a new package: radlab.rain.workload.example
  2. Copy all of the classes from radlab.rain.workload.sample to radlab.rain.workload.example.
  3. Rename SampleGenerator to ExampleGenerator and SampleOperation to ExampleOperation.
  4. Modify Operation1 and Operation2 to be operations relevant to your workload.
    1. Rename the class to something more descriptive (e.g. DoNothingOperation).
    2. In the class constructor, change the assignments:
      • _operationName: A name used for logging and result presentation.
      • _operationIndex: A unique index (starting from 0) as specified in ExampleGenerator.
      • If the operation must be executed synchronously, set this._mustBeSync = true;.
    3. Update the factory methods at the bottom of ExampleGenerator.
      • Update the switch statement in ExampleGenerator.getOperation().
    4. Implement execute() to generate requests for your operation.
      • Take a look in radlab.rain.util for shared utilities (e.g. HttpTransport).
      • Make use of Rain’s trace capabilities by logging a trace after every request.
    5. Implement properties and methods shared by all operations in ExampleOperation.
      • Each operation must store enough state necessary to run asynchronously.
      • ExampleOperation.prepare() should be used to assign operation properties.
    6. Create more operation classes as necessary.
  5. Create the JSON configuration files by making copies of the sample JSON files.
    • profiles.config.example.json
      • Change the track name (i.e. the string keys for the root JSON object).
      • Update the generator, behavior, loadProfile, and target.
      • Adjust the rest or leave the defaults for now.
    • rain.config.example.json
      • Change profiles to point to the the file above.
      • Adjust the timing as necessary or leave the defaults for now.

Clone this wiki locally