Skip Headers
Oracle® Fusion Middleware Developer's Guide for Oracle Complex Event Processing
11g Release 1 (11.1.1.6.3) for Eclipse

Part Number E14301-10
Go to Documentation Home
Home
Go to Book List
Book List
Go to Table of Contents
Contents
Go to Index
Index
Go to Master Index
Master Index
Go to Feedback page
Contact Us

Go to previous page
Previous
Go to next page
Next
PDF · Mobi · ePub

25 Testing Applications With the Load Generator and csvgen Adapter

This chapter describes how to use the included load generator and csvgen adapter to test Oracle Complex Event Processing (Oracle CEP) applications.

25.1 Overview of Testing Applications With the Load Generator and csvgen Adapter

The load generator is a simple utility provided by Oracle CEP to simulate a data feed. The utility is useful for testing the Oracle CQL or EPL rules in your application without needing to connect to a real-world data feed.

The load generator reads an ASCII file that contains the sample data feed information and sends each data item to the configured port. The load generator reads items from the sample data file in order and inserts them into the channel, looping around to the beginning of the data file when it reaches the end; this ensures that a continuous stream of data is available, regardless of the number of data items in the file. You can configure the rate of sent data, from the rate at which it starts, the final rate, and how long it takes the load generator to ramp up to the final rate.

In your application, you must use the Oracle CEP-provided csvgen adapter, rather than your own adapter, to read the incoming data; this is because the csvgen adapter is specifically coded to decipher the data packets generated by the load generator.

If you redeploy your application, you must also restart the load generator.

For more information on testing and debugging, see Section 5.4, "Debugging an Oracle CEP Application Running on an Oracle CEP Server".

25.2 Configuring and Running the Load Generator Utility

This procedure describes how to configure and run the load generator utility.

To configure and run the load generator utility:

  1. Optionally create a property file that contains configuration properties for particular run of the load generator; these properties specify the location of the file that contains simulated data, the port to which the generator feeds the data, and so on.

    Oracle CEP provides a default property file you can use if the default property values are adequate.

    See Section 25.3, "Creating a Load Generator Property File."

  2. Create a file that contains the actual data feed values.

    See Section 25.4, "Creating a Data Feed File."

  3. Configure the csvgen adapter so that it correctly reads the data feed generated by the load generator. You configure the adapter in the EPN assembly file that describes your Oracle CEP application.

    See Section 25.5, "Configuring the csvgen Adapter in Your Application."

  4. Be sure that you configure a builder factory for creating your event types. Although specifying event type builder factories is typically an optional task, it is required when using the load generator.

    See Chapter 2, "Using an Event Type Builder Factory" for details.

  5. Open a command window and set your environment as described in "Setting Your Development Environment" in the Oracle Fusion Middleware Getting Started Guide for Oracle Complex Event Processing.

  6. Change to the ORACLE_CEP_HOME\ocep_11.1\utils\load-generator directory, where ORACLE_CEP_HOME refers to the main Oracle CEP installation directory, such as d:\oracle_cep.

  7. Run the load generator specifying the properties file you created in step 1 to begin the simulated data feed. For example, if the name of your properties file is c:\loadgen\myDataFeed.prop, execute the following command:

    prompt> runloadgen.cmd c:\loadgen\myDataFeed.prop
    

25.3 Creating a Load Generator Property File

The load generator uses an ASCII properties file for its configuration purposes. Properties include the location of the file that contains the sample data feed values, the port to which the utility should send the data feed, and so on.

Oracle CEP provides a default properties file called csvgen.prop, located in the ORACLE_CEP_HOME\ocep_11.1\utils\load-generator directory, where ORACLE_CEP_HOME refers to the main Oracle CEP installation directory, such as d:\oracle_cep.

The format of the file is simple: each property-value pair is on its own line. The following example shows the default csvgen.prop file; Oracle recommends you use this file as a template for your own property file:

test.csvDataFile=test.csv
  test.port=9001
  test.packetType=CSV
  test.mode=client
  test.senders=1
  test.latencyStats=false
  test.statInterval=2000

Caution:

If you create your own properties file, you must include the test.packetType, test.mode, test.senders, test.latencyStats, and test.statInterval properties exactly as shown above.

In the preceding sample properties file, the file that contains the sample data is called test.csv and is located in the same directory as the properties file. The load generator will send the data feed to port 9001.

The following table lists the additional properties you can set in your properties file.

Table 25-1 Load Generator Properties

Property Description Data Type Required?

test.csvDataFile

Specifies the file that contains the data feed values.

String

Yes

test.port

The port number to which the load generator should send the data feed.

Each input adapter must be associated with its own test.port as Section 25.5, "Configuring the csvgen Adapter in Your Application" describes.

Integer

Yes

test.secs

Total duration of the load generator run, in seconds.

The default value is 30.

Integer

No

test.rate

Final data rate, in messages per second.

The default value is 1.

Integer

No

test.startRate

Initial data rate, in messages per second.

The default value is 1.

Integer

No

test.rampUpSecs

Number of seconds to ramp up from test.startRate to test.rate.

The default value is 0.

Integer

No


25.4 Creating a Data Feed File

A load generator data feed file contains the sample data feed values that correspond to the event type registered for your Oracle CEP application.

Example 25-1 shows an EmployeeEvent and Example 25-2 shows a load generator data feed file corresponding to this event type.

Example 25-1 EmployeeEvent Event Type

<wlevs:event-type-repository>
        <wlevs:event-type type-name="EmployeeEvent">
            <wlevs:properties>
                <wlevs:property name="name" type="char" />
                <wlevs:property name="age" type="int" />
                <wlevs:property name="birthplace" type="char" length="512" />
        </wlevs:properties>
    </wlevs:event-type>
...
</wlevs:event-type-repository>

Example 25-2 Data Feed File for EmployeeEvent Event Type

Lucy,23,Madagascar
 Nick,44,Canada
 Amanda,12,Malaysia
 Juliet,43,Spain
 Horatio,80,Argentina

A load generator data feed file follows a simple format:

Note:

The load generator does not fully comply with the CSV specification (http://www.creativyst.com/Doc/Articles/CSV/CSV01.htm).

For more information, see "Event Types for use With the csvgen Adapter".

25.5 Configuring the csvgen Adapter in Your Application

When using the load generator utility, you must use the csvgen adapter in your application because this Oracle CEP-provided adapter is specifically coded to read the data packets generated by the load generator.

You register the csvgen adapter using the wlevs:adapter element in the EPN assembly file of your application, as with all adapters. Set the provide attribute to csvgen to specify that the provider is the csvgen adapter, rather than your own adapter. Additionally, you must specify the following child tags:

Before showing an example of how to configure the adapter, first assume that your application registers an event type called PersonType in the EPN assembly file using the wlevs:metada element shown below:

<wlevs:event-type-repository>
        <wlevs:event-type type-name="PersonType">
            <wlevs:properties>
               <wlevs:property name="name" type="char"/>
               <<wlevs:property name="age" type="int"/>
               <<wlevs:property name="birthplace" type="char"/>
            </wlevs:properties>
        </wlevs:event-type>
</wlevs:event-type-repository>

This event type corresponds to the data feed file shown in Section 25.4, "Creating a Data Feed File."

To configure the csvgen adapter that receives this data, use the following wlevs:adapter element:

<wlevs:adapter id="csvgenAdapter" provider="csvgen">
   <wlevs:instance-property name="port" value="9001"/>
   <wlevs:instance-property name="eventTypeName" value="PersonType"/>
   <wlevs:instance-property name="eventPropertyNames" value="name,age,birthplace"/>
</wlevs:adapter>

Note how the bold values in the adapter configuration example correspond to the PersonType event type registration.

If you use the wlevs:class element to specify your own JavaBean when registering the event type, then the eventPropertyNames value corresponds to the JavaBean properties. For example, if your JavaBean has a getName method, then one of the properties of your JavaBean is name.

For more information on event types, see Chapter 2, "Creating Oracle CEP Event Types".