StreamBase Feed Simulation Configuration XML

This topic describes the XML structure of the StreamBase feed simulation configuration file, .sbfs. To create a feed simulation file, see the Using the Feed Simulation Editor topic.

Note

The current XML format was introduced in StreamBase 3.7 and supersedes the format used in previous StreamBase releases. You can upgrade any legacy .sbfs configuration file (created in StreamBase 3.5 and earler) by opening and saving it in the current StreamBase Studio, or by using the sbfeedsim --convert command.

Legacy feed simulation .sbfs files can still be run using the sbfeedsim-old command as described in StreamBase Legacy Feed Simulation Configuration XML. For more information on upgrading a legacy feed simulation file, see Upgrading Legacy Feed Simulations in the Test/Debug Guide.

sbfs:Simulation is the root element for a StreamBase feed simulation configuration. It has the following child elements:

Example 1. Simulation

<?xml version="1.0" encoding="ASCII"?>
<sbfs:Simulation xmi:version="2.0" xmlns:xmi="http://www.omg.org/XMI" 
                          xmlns:sbfs="http://www.streambase.com/SBFS">
  <SimStreams Name="Orders" Description="Stock Orders">
  ...
  </SimStreams>
  <SimStreams Name="TradesIn" Description="Test trade data feed">
    ...
  </SimStreams>
</Simulation>      

When you generate an sbfs file in StreamBase, the Simulation element and by inheritance, all child elements, are qualified with the unique sbfs namespace.

SimStreams

Identifies a load on a single stream. Has the following child elements:

Example 2. SimStreams

The following example defines a data source and schema for one stream of a feed simulation.

  <SimStreams Name="Orders" Description="v">
    <ProcessingOptions DataRatePerSecond="1.0" DataGenerationMethod="DataFile">
      <DataSource Name="toys.csv" DataSourceURI="toys.csv"/>
    </ProcessingOptions>
    <Schema>
      <Fields Name="Category" DataTypeName="string" FieldLength="32">
        <Distribution/>
        <DataSourceMapping/>
      </Fields>
      <Fields Name="Item" DataTypeName="string" FieldLength="32">
        <Distribution/>
        <DataSourceMapping DestFieldNum="2"/>
      </Fields>
      <Fields Name="Quantity" DataTypeName="int" FieldLength="4">
        <Distribution/>
        <DataSourceMapping DestFieldNum="3"/>
      </Fields>
    </Schema>
  </SimStreams>      

Attributes

Attribute Required Description
Name Yes The unique name of an input stream to the feed simulation.

ProcessingOptions

Specifies how data will be supplied to the feed simulation input streams. Has the following child elements:

Attributes

Attribute Required Description
DataRatePerSecond No The rate in seconds at which tuples should run through this stream. Default: 10.
DataGenerationMethod No The method by which data will be fed to this stream. One of the following:
  • Default: If you omit this attribute, the feed simulator generates uniformly random data for all fields.

  • DataFile: Reads data for all fields from a file, such as a text-based .csv file. Specify the file in a child DataSource element.

  • Custom: Allows you to customize the data for each field, using [TBS] attributes.

DataGenRateMethod No The method by which the data rate is determined. One of the following:
  • AsFastAsPossible: the data will run as fast as the processor can allow.

  • TimestampFromColumn: declares that you will use a timestamp in the data file to set relative times (used only if DataGenerationMethod="DataFile"). Use the TimeStampColumn attribute to set the column that contains the timestamp.

TimeStampColumn No If DataGenRateMethod="TimestampFromColumn", the number of the column in the data file whose timestamp value will be used.
UseFirstValueAsStartTime No If TimeStampColumn is used, the value to be used as the start time. One of:
  • Default (omitted) zero will be used as the start time.

  • true: the first TimeStampColumn value that arrives from the data file will be used.

LogToInput No Specifies whether the generated feed simulation data will be shown in the SB Test/Debug perspective's Application Input view. One of the following:
  • Default (omitted): Yes.

  • false: No.

MaxTuples No The number of tuples to process during the simulation. If you omit the attribute or use it with the default value of 0, there is no limit: all input data is processed.
MaxTime No The maximum time (in seconds) that the simulation should run. If the attribute is not used or used with the default value of 0, there is no limit: the simulation runs until stopped.

Example 3. ProcessingOptions at 1 TPS

The following example shows settings for a feed simulation that uses an external data file and runs at one tuple per second (system time).

<ProcessingOptions DataRatePerSecond="1.0" DataGenerationMethod="DataFile">

Example 4. ProcessingOptions at 11 TPS

In the next example we customized data and an external data file. It runs at 11 tuples per second, based on timestamp fields in the data file instead of system time.

<ProcessingOptions DataRatePerSecond="11.0" TimeStampColumn="1" DataGenerationMethod="Custom" 
    DataGenRateMethod="TimestampFromColumn">
    <DataSource Name="DataSource" DataSourceURI="toys.csv"/>
</ProcessingOptions>

DataSource

If DataGenerationMethod attribute="DataFile" in the ProcessingOptions element, use this element to identify the file that will be used to feed data to the feed simulation.

Attributes

Attribute Required Description
Name Yes A label identifying the data file.
DataSourceURI Yes The file-based URI of the data source, such as the location of myfile.csv that...

Schema

Schema has the following child elements:

Example 5. Schema

For an example, see SimStreams.


Fields

Defines a field in a schema. Has the following child elements:

Attributes

Attribute Required Description
Name Yes A unique identifier for the field in the schema.
DataTypeName Yes The data type of the field. Valid values are int, long, double, string, boolean, and timestamp.
FieldLength Yes The length of the field in bytes.

Example 6. Fields

For an example, see SimStreams.


Distribution

Defines how generated data are distributed in fields. Recognized at runtime only when you specify DataGenerationMethod="Custom" in the ProcessingOptions element. Has the following child elements:

Attributes

Attribute Required Description
GenerationMethod Yes The type of field data to be generated. One of the following:
  • Constant: use together with ConstantValue attribute.

  • Enumerated: use together with either of these associated attributes:

    • EnumeratedDistMethod

    • NumRandomEnumValues

  • Incremented: a numeric value that starts at a particular value, then is incremented by a particular value until it is outside a restricted range. Use together with any of these associated attributes for which you want to change the defaults shown:

    • MinValue (0)

    • MaxValue (10000)

    • StartValue (0.0)

    • Delta (1.0)

    • NullProbability (0.0)

    • ResetValues (false)

  • Random: a numeric value that starts at a particular value, increments by a particular value, and has a restricted range, defined by minimum and maximum values. If you specify a double as the increment, that increment will be used as is, but the result will be truncated.

  • Uniform: a uniformly-generated random number in the range defined by minimum and maximum values

  • Undefined: No custom value will be generated for this field.

NumRandomEnumValues No If GenerationMethod="Enumerated", generates a specified number of random values of equal weight.
EnumeratedDistMethod = "SpecifiedValues" No If GenerationMethod="Enumerated", enables you to specify a list of values and weights. Use together with child element EnumeratedDist.
ConstantValue No If GenerationMethod="Constant", specifies the constant value to generate.
MinValue No If GenerationMethod="Incremented", specifies the smallest value in the incremented range.
MaxValue No If GenerationMethod="Incremented", specifies the largest allowed incremented value.
StartValue No If GenerationMethod="Incremented", specifies the value at which to begin incrementing.
Delta No If GenerationMethod="Incremented", specifies the number by which the value increases at each iteration.
NullProbability No If GenerationMethod="Incremented", defines the probability that a null value will be generated by the Feed Simulator for this field, as part of the runtime feed simulation.
Cycle No If GenerationMethod="Incremented", specifies what happens when the field increments beyond the MaxValue. By default (if you omit the attribute), nothing occurs; if you set Cycle="true", the values are reset and the increment cycle is repeated.

Example 7. Distribution

The following example includes Distribution elements in several Fields elements (not shown). In the first instance, the Distribution element is empty: as a result, only default attribute values are used. The second instance defines how custom values will be incremented. The remaining instances show some of the other available attributes. For an additional example, see EnumeratedDist.

<Distribution/>
...
<Distribution GenerationMethod="Incremented" MinValue="1.145454281485E12" 
   MaxValue="9.999999999999E12" StartValue="1.145454281486E12"/>
 ...
<Distribution GenerationMethod="Uniform" MinValue="20.0" MaxValue="800.0"/>
...
<Distribution GenerationMethod="Constant" ConstantValue="2"/>
 ...
<Distribution GenerationMethod="Random" MinValue="20.0" MaxValue="25.0" StartValue="22.0" Delta="0.1"/>
  

EnumeratedDist

If GenerationMethod="Enumerated", use this element to list each customized field, defining its value and relative priority (weight).

Attributes

Attribute Required Description
value Yes The value of the enumerated field. See the example.
weight No The weight of the field relative to other enumerated fields. This setting influences how often the field's value is used in the generated tuples. The default weight is 1.0; that is, all values are weighted equally by default.

Example 8. EnumeratedDist

In the following configuration example, the ITEM_NAME field is given enumerated values:

<Fields Name="ITEM_NAME" DataTypeName="string" FieldLength="10">
  <Distribution GenerationMethod="Enumerated" EnumeratedDistMethod="SpecifiedValues">
    <EnumeratedDist weight="1.0" value="CEREAL"/>
    <EnumeratedDist weight="1.0" value="MILK"/>
    <EnumeratedDist weight="2.0" value="EGGS"/>
  </Distribution>
</Fields>

DataSourceMapping

If DataGenerationMethod="DataFile" in the ProcessingOptions element, add this element in each Fields element to correlate the fields in your schema to the columns in your DataSource file.

Attributes

Attribute Required Description
DestFieldNum Yes, after the first field Specify a column number in the data file that corresponds to the schema field. The default value is 1, so the first instance of the element can be empty.

Example 9. DataSourceMapping

In the following configuration example, we map each data file column number to a field in the schema. Notice that the first instance of DataSourceMapping is empty: it implicitly maps column 1 to the Category field.

    <Schema>
      <Fields Name="Category" DataTypeName="string" FieldLength="32">
        <Distribution/>
        <DataSourceMapping/>
      </Fields>
      <Fields Name="Item" DataTypeName="string" FieldLength="32">
        <Distribution/>
        <DataSourceMapping DestFieldNum="2"/>
      </Fields>
      <Fields Name="Quantity" DataTypeName="int" FieldLength="4">
        <Distribution/>
        <DataSourceMapping DestFieldNum="3"/>
      </Fields>
    </Schema>