Red Hat Training

A Red Hat training course is available for Red Hat JBoss Data Virtualization

13.15. Infinispan DSL Translator

The Infinispan DSL Translator, known by the type infinispan-cache-dsl, can read the Java objects from a remote Infinispan Cache via the Hot Rod client using the Google Protobuf for serialization. The benefit of this JBoss Data Grid design is that it will enable Teiid to query the cache using DSL, which is similar to doing Lucene searching on a local cache. If you are using Infinispan in Library mode, see the Object Translator for this type of configuration.
The Infinispan DSL Translator currently has no import or execution properties. See the JCA resource adapter section below for information on how to configure the cache to be queried.
Here are the connector's capabilities:
  • Compare Criteria - EQ, NE, LT, GT, LE, GE.
  • And/Or Criteria
  • (Not) In Criteria
  • (Not) Like Criteria
  • (Not) IsNull
  • INSERT, UPDATE, DELETE (non-transactional)
Here are its limitations:
  • One-to-Many, currently only supports Collection or Array, not Maps
  • Write transactions not supported by JDG when using Hot Rod client
Use it to retrieve objects from a cache and transform into rows and columns and to perform writes to the cache.
Here are the definition requirements:
  • Each Google registered class in the cache will have a corresponding table created.
  • The table for the root class, must have a primary key defined, which must map to an attribute in the class.
  • The table "name in source" (NIS) will be the name of the JDG cache this table/class is stored
  • The table columns will be created from the Google protobuf definition, that corresponds to a registered class.
  • Attributes defined as repeatable (i.e., collections, arrays, etc.) or a container class, will be supported as 1-to-* relationships, and will have corresponding registered class (if they are to be searched).
  • A one-to-many relationship class must have a foreign key to map to the root class/table, where the name in source for the foreign key is the name of the root class method to access those child objects. Note, this is the class method, not a reference in the Google protobuf definition.
  • A container/child class will have attributes where the NIS contain a period. Example: phone.number. This is because this maps to the Google protobuf definition and what is expected to be used in the DSL query.
There are several options to defining the metadata representing your object in the cache:
  • The recommended approach is to use the Teiid Connection Importer in Teiid Designer to create the physical source model based on your object cache.
  • Another option is to use dynamic VDB that only defines the data source to use. The metadata will be resolved by reverse engineering the defined object in the cache. This can be useful when using the Teiid Designer Teiid Connection Importer for building the physical source model(s).
    <model name="People" type="Physical">
        <property name="importer.useFullSchemaName" value="false"/>
            
        <source name="infinispan-cache-dsl-connector" translator-name="infinispan-cache-dsl" connection-jndi-name="java:/infinispanRemoteDSL" />
    </model>
    
    The metadata will be resolved by reverse engineering the defined object in the cache. This can be useful when using the Teiid Designer Teiid Connection Importer for building the physical source model(s).
  • Use dynamic VDB without defining the metadata using DDL.

    Note

    This code also shows a container class, PhoneNumber, as an example of the foreign key that defines the relationship.
    <vdb name="PeopleVDB" version="1">
        <model name="People" visible="true">
            <property name="importer.useFullSchemaName" value="false"/>
            
            <source name="infinispan-cache-dsl-connector" translator-name="infinispan-cache-dsl" connection-jndi-name="java:/infinispanRemote" />
     
            <metadata type="DDL"><![CDATA[
     
     CREATE FOREIGN TABLE Person (
        PersonObject object OPTIONS (NAMEINSOURCE 'this', UPDATABLE FALSE, SEARCHABLE 'Unsearchable', NATIVE_TYPE 'java.lang.Object'),
        id integer NOT NULL OPTIONS (SEARCHABLE 'Searchable', NATIVE_TYPE 'int'),
        name string OPTIONS (SEARCHABLE 'Searchable', NATIVE_TYPE 'java.lang.String'),
        email string OPTIONS (SEARCHABLE 'Searchable', NATIVE_TYPE 'java.lang.String'),
        CONSTRAINT PK_ID PRIMARY KEY(id)
    ) OPTIONS (NAMEINSOURCE 'PersonsCache', UPDATABLE TRUE);
     
    CREATE FOREIGN TABLE PhoneNumber (
        number string OPTIONS (NAMEINSOURCE 'phone.number', SEARCHABLE 'Searchable', NATIVE_TYPE 'java.lang.String'),
        type string OPTIONS (NAMEINSOURCE 'phone.type', SEARCHABLE 'Searchable', NATIVE_TYPE 'java.lang.String'),
        id integer NOT NULL OPTIONS (SELECTABLE FALSE, UPDATABLE FALSE, SEARCHABLE 'Searchable', NATIVE_TYPE 'int'),
        CONSTRAINT FK_PERSON FOREIGN KEY(id) REFERENCES Person (id) OPTIONS (NAMEINSOURCE 'phones')
    ) OPTIONS (NAMEINSOURCE 'PersonsCache', UPDATABLE TRUE);
              </metadata>
        </model>
     
    </vdb>
    
  • Use Teiid Designer to manually create the physical source model based on your object cache using the above usage patterns.
See the Infinispan-DSL resource adapter for this translator. It can be configured to lookup the cache container via JNDI, server list, or hot rod properties.

Important

CompareCriteriaOrdered has been disabled due to a Red Hat JBoss Data Grid issue with filtering when GTE/LTE criteria is specified on String type attributes. This criteria is not sent to JBoss Data Grid for processing, but is processed in Teiid. As a result, a performance issue can arise with these types of queries, depending on what other criteria has also been specified.
If you wish to enable this capability so that GTE/LTE can be used on other data types, then specify a translator override for CompareCriteriaOrdered. Here is how you define an override in a dynamic VDB:
 
<translator name="infinispan-cache-dsl1" type="infinispan-cache-dsl">
  <property name="supportsCompareCriteriaOrdered" value="true"/>
</translator>
		

Important

Note that char types are not supported when accessing a JBoss Data Grid Remote Cache and using Google Protobufs for serialization. To see which data types are supported, see this table: https://developers.google.com/protocol-buffers/docs/proto#scalar
To work around the current limitation on the Char type, use the String data type or use the marshaller to handle the conversion.