Persistence of Query Tables

By default, Query Tables are ephemeral. That is, a table's data is stored in Java heap memory that is released when the node running the EventFlow fragment exits. You can however, configure a Query Table to store its data either on disk or in transactional memory.

A selection made in the Type drop-down list applies only to the current Query Table. You can have a mix of differently persisted Query Tables in your application. To select a storage Type option, the Data Location selection must be Local.

On Heap Option

In the following figure, the Table Settings tab of the Properties view for a Query Table is shown with all default values. Notice that the selected Query Table is declared to be On heap.

With this configuration, data in the Query Table remains valid and usable as long as the containing EventFlow module stays running. When the node that contains this EventFlow module is stopped, on heap Query Table data is released.

Transactional Memory Option

Select In transactional memory to store this Query Table's data in the node's transactional memory. Using transactional memory allows this Query Table to be shared between nodes. Transactional memory does persist beyond the life of the containing node, because it is based on System V shared memory.

When you make this selection, a link Configure data distribution appears. Clicking this link opens the Data Distribution tab of this Query Table's Properties view. If you select the Distribute Data check box in that tab, the current Studio project must specify the name of a data distribution policy in a configuration file of type node with root object NodeDeploy. See Transactional Memory and Transactions for a discussion of these concepts.

On Disk Option

For disk-based Query Tables, the data can persist indefinitely. For example, you could store data for a StreamBase application that runs only during market trading hours, and requires data from the previous day's run during initialization each day. Another possible use of persistent Query Tables tables is to maintain state information for an EventFlow fragment.

If you specify On disk in the Type drop-down list, the disk default storage location for Query Table data is in the node directory for the node that contains the running EventFlow fragment. The node directory itself can be ephemeral for nodes run for short periods; node directories for nodes at the end of the node lifecycle are not preserved.

To preserve on-disk Query Table data beyond the life of the node, specify the dataAreaPath property in a configuration file of type sbengine with root object StreamBaseEngine.

The following configuration file from the javaoperator-datadir StreamBase sample shows several possible settings for the dataAreaPath property.

name = "data-area-path-test"
version = "1.0.0"
type = "com.tibco.ep.streambase.configuration.sbengine"
configuration = {
  StreamBaseEngine = {
    streamBase = 
    {
      // Use a path like the following to create the folder in the Studio 
      // project folder if you opened this sample from the Import Samples and
      // Community Content dialog.
    dataAreaPath = "../../../../sample_javaoperator-datadir/myDataDir"
      // Use the following alternative to create the folder in the Studio 
      // project folder if you copied this sample independent of the Load 
      // StreamBase Samples dialog.
    // dataAreaPath = "../../../../javaoperator-datadir/myDataDir"
      // Use a path like the following to simply rename the default data directory
      // folder in its default location.
    // dataAreaPath = "myDataDir"
      // Use a path like the following to create your data directory folder 
      // one level up from its default location, as a subfolder under "fragments".
    // dataAreaPath = "../myDataDir"
      // Use a path like the following to place myDataDir at the root of your
      // node directory.
    // dataAreaPath = "../../myDataDir"
      // Use a path like the following to specify an absolute operating system 
      // path for your data directory when running this sample as part of a 
      // StreamBase application at the command line with epadmin.
    // dataAreaPath = "/tmp/myDataDir"
    // dataAreaPath = "C:/tmp/myDataDir"  
      // Use a path like the following to specify a substitution variable to
      // contain the path for your data directory with a default value included.
      // Fill in this value at the epadmin command line with a value much like
      // epadmin ... substitutions="DATADIR=/Users/sbuser/output/myDataDir" ...
    // dataAreaPath = "${DATADIR:-/tmp/myDataDir}"
    }
  }
}

Back to Top