The Infinispan translator, known by the name of infinispan-cache, is a bridge for reading and writing java objects to/from an Infinispan/JDG Cache. This translator extends the Object Translator and uses it for the core processing of reading and writing objects. The Infinispan Cache Translator is written so that it can control how the cache is searched and any capabilities that are needed to control that behavior.
Supports the options for using either DSL searching (JDG 6.3+), Hibernate/Lucene searching (now deprecated), or Key searching (when no indexing is used). See the jdg-local-cache quick start for an example. Note, this assumes you will be installing JDG into the same server installation, running in library mode.
The infinispan-cache translator is not configured, out-of-the-box, in the standalone-teiid.xml configuration. To configure the translator, run the add-infinispan-cache-translator.cli script. This script can also be found in the teiid-jboss-dist.zip kit, under docs/teiid/datasources/infinispan.
Name | Description | Required | Default |
---|---|---|---|
SupportsDSLSearching | Setting to true assumes your are using JDG v6.3 or better and your cache has indexing enabled | N | false |
SupportsLuceneSearching (deprecated) | Setting to true assumes your objects are annotated and Hibernate/Lucene will be used to search the cache | N | false |
SupportsNotCriteria | Setting to true enabled support of NOT operators like '<' or '<' | N | false |
SupportsIsNullCriteria | Setting to true enabled support of IsNull criteria | N | false |
SupportsCompareCriteriaOrdered | Setting to true enables support for criteria with the '=>' or '<=' | N | false |
SupportsNotCriteria defaults to false because the testing of column <> 1 returns true when the column is null, which isn't correct by SQL standards. There is an enhancement coming that will enable adding "column IS NOT NULL" when column <> 1 type criteria is detected.
SupportsIsNullCriteria defaults to false because Infinispan/JDG has an issue with issuing a IS NULL check on a numeric type attribute. Set this to true if you need this check and can control which non-numeric columns that this will be issued against.
SupportsCompareCriteriaOrdered defaults to false because the '=>' and '<=' operations are dependent upon SupportsNotCriteria being enabled. If this is to be enabled, will also need to enable SupportsNotCritera.
The following are the connector capabilities when Key Searching is used:
The following are the connector capabilities when DSL Searching is enabled:
The following is an example of a key search and a view that associated player names with their team. It uses a dynamic vdb to define the physical source and views using DDL. It uses a TeamObject class, shown below, with a teamName field that is used as its cache key and a String list of players.
public class TeamObject { private String teamName; private List<String> players = new ArrayList<String>(); public String getTeamName() { return teamName; } public void setTeamName(String teamName) { this.teamName = teamName; } public List<String> getPlayers() { return players; } }
Note that by just using a dynamic vdb, the native import logic will provide you with a TeamObject physical table that can be queried. An equivalent Team table is shown here for demonstration purposes.
<vdb name="team" version="1"> <model name="Team" visible="false"> <source name="objsource" translator-name="infinispan1" connection-jndi-name="java:infinispan-jndi"/> <metadata type="DDL"><![CDATA[ CREATE FOREIGN TABLE Team ( TeamObject Object OPTIONS (NAMEINSOURCE 'this', SEARCHABLE 'Unsearchable'), teamName varchar(255) PRIMARY KEY) OPTIONS (NAMEINSOURCE 'teams'); ]]> </metadata> </model> <model name="TeamView" type="VIRTUAL"> <metadata type="DDL"><![CDATA[ CREATE VIEW Players ( TeamName varchar(255) PRIMARY KEY, PlayerName varchar(255) ) AS SELECT t.TeamName, y.Name FROM Team as T, OBJECTTABLE('m.players' PASSING T.TeamObject as m COLUMNS Name string 'teiid_row') as y; ]]> </metadata> </model> <translator name="infinispan1" type="infinispan-cache"> <property name="SupportsLuceneSearching" value="true"/> </translator> </vdb>
Notice the use of the OBJECTABLE function to parse the object from Team and transform into rows and column. This is only for demonstration purposes, and is not required in order to parse the object into rows and columns.
This metadata could also be defined by using the Teiid Designer Teiid Connection Importer.
See the Infinispan Datasources resource adapter for this translator. It can be configured to lookup the cache container via JNDI or created (i.e., ConfigurationFileName (deprecated) or RemoteServerList).