Last updated January 24, 2011 13:37, by Jørgen Austvik
Feedicon  

Load Framework

JET has a flexible system to put load on your software. Traditionally this load has been JDBC transactions, but it is also generic enough to support any other type of load.


Declare

The load in JET can be used directly with Java (see e.g. RunBanking.java), or configured in the XML files as a load client. If you declare it in a test XML file, this is how it will look:

<TestSetup class="com.sun.jet.framework.load.LoadSetup" comment="Run with load">
  <LoadClient id="loadsetup"
              executeTime="60"
              scheduler="com.sun.jet.framework.load.scheduler.ParallelScheduler"
              thinktimeClass="com.sun.jet.framework.load.thinktime.NegExponentialThinkTime">
    <Transaction id="count" className="com.sun.jet.examples.CountTransaction"
                 instanceCount="2"/>
  </LoadClient>
  <TestSuite>
      <TestCase class="com.sun.jet.framework.testcase.SleepWaitTestCase"
          method="sleepBySeconds"
          comment="Run load for 10 seconds">
          <Binding key="jet.sleeptime" value="10"/>
      </TestCase>
  </TestSuite>
</TestSetup>

Setups

Before you start the load, it is normal to have a test setup that starts the product, populates it with data, creates data models for testing etc. This can be seen as a separate part from the load, but for more advanced loads like oltp and banking, you can check out the ModelSetup.java files.

The LoadSetup above is the setup that includes everything in this test that runs with load. It can have LoadClient elemments.

Load Client

The load client runs a set of transactions with a given scheduler and a given think time.

Schedulers

The scheduler selects when to run which transaction.

If you want to add a new scheduler, you must inherit com.sun.jet.framework.load.scheduler.Scheduler

The test framework comes with several schedulers:

ArrivingTransactionsScheduler
Transactions arrive at different times, simulates realistic database load
ParallelScheduler
Runs all transactions in parallel execute_count times
RandomScheduler
When one transaction is finished, it will start a new random transaction
SequentialScheduler
When one transaction is finished, starts the next transaction in the list

Think Time

The think time decides how much time one should wait after one transaction is finished until one starts the next, or how long time it goes between the transactions. It is a combination of an algorithm and a binding.

You can create an unique think time class (e.g. gaussian distribution) by extending com.sun.jet.framework.load.thinktime.ThinkTime, or use one of the think times provided by JET:

FixedThinkTime
waits exactly jet.thinktime each time
NegExponentialThinkTime
waits on average jet.thinktime, but the wait time is negative exponential distributed

Transactions

Transactions are where the load is generated.

This is how a transaction can look in Java code:

 import com.sun.jet.framework.load.Transaction;
 
 public class CountTransaction extends Transaction {
 
    ...
 
    @Override
    protected void doTransaction() {
        i++
        getMetrics().incCommits();
    }
 }

In the XML file you can set the instanceCount attribute to create many transactions of the same type to generate more load if you are e.g. running parallel transactions.

Take a look at the jet~example/jet-example-memcached example for load transactions against memcached.

Parallel work

You can run tests while your software in under load by including test cases in the TestSuite within the LoadSetup. In the example above, the SleepWaitTestCase is run. It's sleepBySeconds method sleeps jet.sleeptime seconds, and returns success afterwards.

Transaction Types

Non-Database Load

To run load against a product which is not a database, take a look at the jet~example/jet-example-memcached example.

JDBC Load

The JDBCTransaction class is a special load class for JDBC load, which handles retries, transient errors, metrics etc. If you want to write load that uses JDBC you should use it.

Bundled loads

JET come bundled with two JDBC loads, banking and oltp. Check out jet-examples/src/test/jet/jdbcload.xml for example usage.

Backends

Transaction backends is a way to let the JDBCTransaction understand different databases.

Take a look at TransactionBackendDerby.java for an example backend.

If you want to write a backend for your database, you must extend com.sun.jet.framework.load.backend.TransactionBackend. You specify which backend to use with the jet.transaction.backend property.

  • Mysql
  • Glassfish
  • Jruby
  • Rails
  • Nblogo
Terms of Use; Privacy Policy;
© 2010, Oracle Corporation and/or its affiliates
(revision 20120518.3c65429)
 
 
Close
loading
Please Confirm
Close