LiveView Create or Drop Table Output Adapter

Introduction

The TIBCO® LiveView Create or Drop Table output adapter allows a StreamBase application to create, start, and drop LiveView tables dynamically on running LiveView servers.

Properties

This section describes the properties you can set for this adapter, using the various tabs of the Properties view for the adapter's icon in StreamBase Studio.

General Tab

Name: Use this required field to specify or change the name of this instance of this component, which must be unique in the current EventFlow module. The name must contain only alphabetic characters, numbers, and underscores, and no hyphens or other special characters. The first character must be alphabetic or an underscore.

Adapter: A read-only field that shows the formal name of the adapter.

Class name: Shows the fully qualified class name that implements the functionality of this adapter. If you need to reference this class name elsewhere in your application, you can right-click this field and select Copy from the context menu to place the full class name in the system clipboard.

Start options: This field provides a link to the Cluster Aware tab, where you configure the conditions under which this adapter starts.

Enable Error Output Port: Select this check box to add an Error Port to this component. In the EventFlow canvas, the Error Port shows as a red output port, always the last port for the component. See Using Error Ports to learn about Error Ports.

Description: Optionally enter text to briefly describe the component's purpose and function. In the EventFlow Editor canvas, you can see the description by pressing Ctrl while the component's tooltip is displayed.

Adapter Properties Tab

This section describes the properties on the Adapter Properties tab in the Properties view for the LiveView Create or Drop Table adapter.

Property Description
Set Server URI to encapsulating LiveView Select this check box when the adapter is part of a LiveView project. In this case, the adapter connects to the port of the running LiveView server. When authentication is enabled, the credentials used to connect to the LiveView server are retrieved from the liveview.internal.username and liveview.internal.password system properties. The corresponding LiveView user must be configured with the appropriate permissions to allow this adapter to perform its operations.
LiveView Server URI A LiveView server URI, or an expression or variable that resolves to a LiveView server URI. For example, the URI for the local machine and default port is lv://localhost:10080.
Share LiveView Connection When selected (the default), this instance of the adapter shares a single LiveView connection to the configured LiveView server with all other LiveView adapters in the same container that also have the Share LiveView Connection property selected.
Connect Inline When selected, if the adapter does not currently have a LiveView connection to the configured server, it will attempt to connect immediately. This will block the application or concurrent region until the connection attempt succeeds or times out. Note that if the adapter is not currently connected there is a background thread that is periodically attempting reconnects. Thus, Connect Inline is only operable for a small timing window between when the background thread makes the LiveView connection and if a tuple arrives just before the background thread attempts the reconnection.
Log Level Controls the level of verbosity the adapter uses to send notifications to the console. This setting can be higher than the containing application's log level. If set lower, the system log level is used. Available values, in increasing order of verbosity, are: OFF, ERROR, WARN, INFO, DEBUG, TRACE.

Cluster Aware Tab

Use the settings in this tab to allow this operator or adapter to start and stop based on conditions that occur at runtime in a cluster with more than one node. During initial development of the fragment that contains this operator or adapter, and for maximum compatibility with TIBCO Streaming releases before 10.5.0, leave the Cluster start policy control in its default setting, Start with module.

Cluster awareness is an advanced topic that requires an understanding of StreamBase Runtime architecture features, including clusters, quorums, availability zones, and partitions. See Cluster Awareness Tab Settings on the Using Cluster Awareness page for instructions on configuring this tab.

Concurrency Tab

Use the Concurrency tab to specify parallel regions for this instance of this component, or multiplicity options, or both. The Concurrency tab settings are described in Concurrency Options, and dispatch styles are described in Dispatch Styles.

Caution

Concurrency settings are not suitable for every application, and using these settings requires a thorough analysis of your application. For details, see Execution Order and Concurrency, which includes important guidelines for using the concurrency options.

Adapter Ports

The LiveView Create or Drop Table adapter provides one input port, and two output ports:

  • The input port is used to send Create, Start, CreateStart, or Drop commands to the adapter.

  • The Status output port emits tuples that provide information about each table command, and the status of the connection to the configured LiveView server.

  • The other output port is a passthrough output of the input tuple.

As with other StreamBase adapters, you can optionally enable an Error Output Port, as described in Using Error Ports and Error Streams.

LiveView Create or Drop Table Adapter Input Port

The input port is used to send Create, Start, CreateStart, or Drop commands to the adapter. Refer to the LiveView dynamic table documentation for more information about state transitions when creating, starting, and dropping tables.

The input port's schema is shown in the following table. When sending a tuple to unregister an existing query, use only the first and last fields.

Field Data Type Description
Command string The table command to execute which must be one of the following strings:
Create — Creates a table with the specified schema, indexes, and optional AggregationQuery and Description. CreateStart — This command combines the above two into single command for convenience.
Start — Once a table has been successfully created, it can be started. Only the TableName field is needed. Drop — Removes a created or started table from the connected LiveView server. Only the TableName field is needed.
TableName string The name of the table to operate on. This field must be set for all commands.
Indices list<list<string>> Defines the indexes for the table for use with the Create command. The inner list is a comma-separated list of field names that comprise a single index. The first list<string> in the outer list is the primary key for the table, while subsequent list<string> are secondary indexes. For example, an Indices value of list(list( "MyLong", "MyString"), list("MyDouble")) will create a table with primary key of MyLong,MyString and a secondary index of MyDouble.
Description string An optional text string for the Create command which is to be included in the Description field of the LiveView server's LVTables system table.
Schema string This string defines the schema of the table to be used with the Create command. The string format is a comma-separated list of name-data type pairs, the whole enclosed in parentheses. For example, (x int, s string) represents a table with two fields, the first of which is x of type int and the second of which is s of type string.
WaitTime int The number of milliseconds to wait before declaring a timeout when Creating, Starting, or Dropping a table. If null, the default is 180,000 ms. This default can be changed by setting the system property streambase.adapter.lvcreatedrop.waitMS.
AggregationQuery string If non-null, the table being created is an aggregate table and this field should have a fully specified LiveQL select statement that uses aggregate functions. For example, select count() as MyCount, s from MyBaseTable group by s. This AggregationQuery says to use MyBaseTable as the base table and the aggregate function is a count of the number of rows in the group s.
Synchronous boolean If true, do not emit the output pass-through tuple until the command completes, whether successfully or in failure. If null or false, emit the pass-through tuple immediately. In any case, the success or failure of a command is reported on the status port.
TableConfig tuple Optional. A tuple that contains all the advanced dynamic table creation configuration information.

The adapter can import a proposed schema for the input port that you can use as a starting point.

To import an input schema, click the Import proposed schemas hyperlink in the top right corner above the Adapter Properties tab. From the dialog, click Browse to select an existing destination interface file, or click New File to save a Named schema file to a project folder.

The TableConfig tuple has advanced table creation feature configurations. The tuple fields are defined in the table below.

Field Data Type Description
SaveInProject boolean If true, save the tables to the server even after the restart of the LiveView server.
ShortDescription string A short description for the table being created.
RowDeleteRule string An optional rule specifying a predicate that is evaluated against the data in any incoming insert or update. If the incoming data satisfies the predicate and a row with a matching primary key exists, then no update occurs and the row is deleted. If the incoming data satisfies the predicate and no row with a matching primary key exists, then no insert occurs. If the incoming data does not satisfy the predicate, then an insert or update occurs as normal.
TableDeleteRules list<string> Used for retention policy to specify a condition when the rows present in this table are to be deleted. Set one of the following Table Delete Rules:
Elapsed Time Rule — Define how long to store table data before the table is trimmed. Optionally, generate a Timestamp field. The chosen timestamp is added as a secondary index for the table. Valid timestamp fields in the data table's schema populate the drop-down list. You can set a timestamp for event arrival; this action creates a field rule. No Data Retention Policy — Table rows will not be trimmed — based on retention policy. See Managing the Size of Data Tables for table trimming options that you can configure independently from retention policies.
Predicate Rule — Build a rule to register a query against the table where rows are added to the result set are deleted through the publish data path. For this reason, the predicate usually has a time component (see WHEN and FOR clauses for more information).  
SnapshotParallelism int Defines the number of table partitions and the number of parallel regions used to scan a table during the snapshot portion of a query.
SnapshotConcurrency int Defines the maximum number of snapshot queries (one per thread) within a partition that are executed at once.
PersistenceFolder string Used to set the persistent folder where this table will be persisted.
PersistenceRestoreDataOnStart boolean If true, recovers the data is to be restored after the table is restarted.
FilteredTableAliases list<tuple> A list of FilteredTableAlias tuples used to specify an alias format string that will provide a new name pattern for data that matches the predicate filter specified. See the FilteredTableAlias tuple fields definition for details.
Variables list<tuple> A list of variable tuples that can be used in both test and assignment expressions in the FieldRules. If there is a non-trivial expression that will be used more than once in the evaluation of FieldRules, then use a Variable to save the value of that expression. Note that all Variables are evaluated for every insert and update of every value. Variables can also be the target of assignments in RuleCases, if there are expressions that only need to be evaluated for certain cases.
FieldRules list<tuple> A list of field rule tuples that will be evaluated on every insert or update. See FieldRule tuple fields definition for details.
CaseInsensitiveFieldNames list<string> Defines a list of fields that will contain case-insensitive values. If a field is specified as case-insensitive, for example, Toy, tOy, and toy are treated the same.

The FilteredTableAlias tuple contains configuration information that specify an alias format string that will provide a new name pattern for data that matches the predicate filter specified. The tuple fields are defined in the table below.

Field Data Type Description
Filter string A predicate string that when it is matched, a new name pattern specified in field Formatter will be generated.
Formatter string An alias format string. For example, %s_alias accepts the current table name and appends an underscore and the string alias.

The Variable tuple contains variable configuration information. It can be used in both test and assignment expressions in the FieldRules. If there is a non-trivial expression that will be used more than once in the evaluation of FieldRules, then use a Variable to save the value of that expression. Note that all Variables will be evaluated for every insert and update of every value. Variables can also be the target of assignments in RuleCases, if there are expressions that only need to be evaluated for certain cases. For example, if there is a variable var, you can put current.var in an Assignment tuple Value field to access the current value of variable, var.

Field Data Type Description
Name string The name of the variable.
InsertInitialValue string Initial value on an insert operation. As of 10.6.0, this field is currently not supported.
UpdateInitialValue string Initial value on an update operation. As of 10.6.0, this field is currently not supported.

A FieldRule is a list of cases that will be evaluated on every insert or update. A RuleCase represents one case for a FieldRule, with a test, a list of assignments for an insert operation, and a list of assignments for an update operation. The first case whose test is true will be executed. If none are true and there is a default case, that case will be executed. If the RuleCase used as default includes a test, the test will be ignored. The FieldRule tuple fields are defined in the following table.

Field Data Type Description
Description string The description of this field rule.
DefaultCase tuple A default RuleCase tuple. If none of Cases are true, it will be executed.
Cases list<tuple> A list of RuleCase tuples used by this field rule. The first case whose test is true will be executed

A RuleCase represents one case for a FieldRule, with a test, a list of assignments for an insert operation, and a list of assignments for an update operation. The first case whose test is true is executed. If none are true and there is a default case, that case is executed. If the RuleCase used as default includes a test, the test is ignored. The RuleCase tuple fields are defined in the following table.

Field Data Type Description
Test string A predicate string. If true, this rule case may be executed.
InsertAssignments list<tuple> A list of Assignment tuples that will be executed on an insert operation if Test is true.
UpdateAssignments list<tuple> A list of Assignment tuples that will be executed on an update operation if Test is true.

An Assignment tuple represents one assignment to either a Field or a Variable. The fields are defined in the following table; you must set at least one of FieldName or VariableName.

Field Data Type Description
FieldName string The field name that the value will be assigned to.
VariableName string The variable name that the value will be assigned to.
Value string Required. The value that will be assigned.

LiveView Create or Drop Table Output Ports

The LiveView Create or Drop Table adapter has one output status port and one through tuple output port.

The status port has the fields shown in the following table:

Field Data Type Description
Type string The basic state reported, always one of the following:
CONNECTION TABLE_START
TABLE — Used if the command type cannot be determined. TABLE_DROP
TABLE_CREATE  
Object string The name on the EventFlow canvas of the adapter reporting the status.
Action string The action that occurred, one of the following:
CONNECTED FAILED
COMPLETED ERROR
Message string A human-readable string that provides additional context for the status message. TABLE_* actions always start with Table: MyTableName.
Time timestamp The time the action occurred.

The LiveView Create or Drop Table adapter has an output port that uses the schema of the input port and passes on the input tuple either immediately if not Synchronous, or delayed until the command action is completed if Synchronous — whether the command completes successfully or in failure. In all cases, the success or failure of the command is determined by looking at the status output port.

Adding the Adapter to an EventFlow Application

Add an instance of the adapter to a new EventFlow application with the following steps:

  1. In StreamBase Studio, create a project, including an empty StreamBase EventFlow application file to host the adapter.

  2. From the Operators and Adapters drawer of the Palette view, drag the Adapters, Java Operators icon to the canvas. This opens the Insert an Operator or Adapter dialog.

  3. In the search field, type a string such as liveview to narrow the list of adapters. Select the icon for the LiveView Create or Drop Table adapter, then click OK.

  4. Double-click the adapter's icon and select the Adapter Properties tab in the Properties view.

  5. Next, either:

    1. If this adapter is part of an EventFlow module that is itself part of a LiveView project, select the Set Server URI to encapsulating LiveView check box. This check box tells the adapter to connect to the host and port for the current project's LiveView server.

    2. Or specify the URI for a local or remote LiveView server to connect to (or accept the default URI, lv:/localhost:10080).

  6. Specify the other options in the Adapter Properties tab as required.

  7. Specify a schema for the input port, as described in LiveView Create or Drop Table Adapter Input Port.

  8. Add two Output Streams and connect arcs to them from the LiveView Create or Drop Table adapter's output ports.

  9. At runtime, this LiveView Create or Drop Table adapter connects to the specified LiveView server and is then ready to accept commands.

Typechecking and Error Handling

The LiveView Create or Drop Table adapter uses typecheck messages to help you configure the adapter.

The adapter generates warning messages at runtime under various conditions, including:

  • The configured LiveView server is not available.

Suspend and Resume Behavior

This adapter does not change behavior when suspended.