JBoss.orgCommunity Documentation
Teiid supports several mechanisms for updating the runtime system.
Data change events are used by Teiid to invalidate result set cache entries. Result set cache entires are tracked by the tables that contributed to their results.
By default Teiid will capture internal data events against physical sources and distribute them across the cluster.
This approach has several limitations. First updates are scoped only to their originating VDB/version. Second updates made out side of Teiid are not captured.
To increase data consistency external change data capture tools can be used to send events to Teiid. From within a Teiid cluster the org.teiid.events.EventDistributorFactory
and org.teiid.events.EventDistributor
can be used to distribute change events. The EventDistributorFactory
is implemented by the
RuntimeEngineDeployer
bean and should be looked up by its name "teiid/engine-deployer". See the example below.
Example 9.1. Usage of the EventDistributor
InitialContext ctx = new InitialContext(); EventDistributorFactory edf = (EventDistributorFactory)ctx.lookup("teiid/engine-deployer"); EventDistributor ed = edf.getEventDistributor(); ed.dataModification(vdbName, vdbVersion, schema, tableName);
This will distribute a change event for schema.tableName in vdb vdbName.vdbVersion.
When externally capturing all update events, <jboss-install>/server/<profile>/deploy/teiid/teiid-jboss-beans.xml
RuntimeEngineDeployer.detectingChangeEvents can be set to false, to not duplicate change events.
The use of the other EventDistributor
methods to manual distribute other events is not recommended.
Runtime updates via system procedures and DDL statements are by default ephemeral. They are effective across the cluster only for the currently running vdbs.
With the next vdb start the values will revert to whatever is stored in the vdb. Updates may be made persistent though by configuring a org.teiid.metadata.MetadataRepository
.
An instance of a MetadataRepository
can be installed via the <jboss-install>/server/<profile>/deploy/deployers/teiid.deployer/teiid-deployer-jboss-beans.xml
file in the VDBRepository
bean.
The MetadataRepository
repository instance may fully implement as many of the methods as needed and return null from any unneeded getter.
It is not recommended to directly manipulate org.teiid.metadata.AbstractMetadataRecord
instances.
System procedures and DDL statements should be used instead since the effects will be distributed through the cluster and will not introduce inconsistencies.
org.teiid.metadata.AbstractMetadataRecord
objects passed to the MetadataRepository
have not yet been modified.
If the MetadataRepository
cannot persist the update, then a RuntimeException
should be thrown to prevent the update from being applied by the runtime engine.
The MetadataRepository can be accessed by multiple threads both during load (if using dynamic vdbs) or at runtime with through DDL statements. Your implementation should handle any needed synchronization.
See the Reference for the system procedures SYSADMIN.setColumnStats
and SYSADMIN.setTableStats
.
To make costing updates persistent MetadataRepository
implementations should be provided for:
TableStats getTableStats(String vdbName, int vdbVersion, Table table); void setTableStats(String vdbName, int vdbVersion, Table table, TableStats tableStats); ColumnStats getColumnStats(String vdbName, int vdbVersion, Column column); void setColumnStats(String vdbName, int vdbVersion, Column column, ColumnStats columnStats);
See the Reference for supported DDL statements. To make schema updates persistent implementations should be provided for:
String getViewDefinition(String vdbName, int vdbVersion, Table table); void setViewDefinition(String vdbName, int vdbVersion, Table table, String viewDefinition); String getInsteadOfTriggerDefinition(String vdbName, int vdbVersion, Table table, Table.TriggerEvent triggerOperation); void setInsteadOfTriggerDefinition(String vdbName, int vdbVersion, Table table, Table.TriggerEvent triggerOperation, String triggerDefinition); boolean isInsteadOfTriggerEnabled(String vdbName, int vdbVersion, Table table, Table.TriggerEvent triggerOperation); void setInsteadOfTriggerEnabled(String vdbName, int vdbVersion, Table table, Table.TriggerEvent triggerOperation, boolean enabled); String getProcedureDefinition(String vdbName, int vdbVersion, Procedure procedure); void setProcedureDefinition(String vdbName, int vdbVersion, Procedure procedure, String procedureDefinition); LinkedHashMap<String, String> getProperties(String vdbName, int vdbVersion, AbstractMetadataRecord record); void setProperty(String vdbName, int vdbVersion, AbstractMetadataRecord record, String name, String value);