Infinispan HotRod Data Sources

Infinispan caches running in client/server mode can use a Teiid specific JCA connector for accessing as a data source, which is deployed into WildFly 10.0.0 during installation. This connector can be configured to support the accessing of a remote Infinispan cache using the the Hot Rod client.

Each Infinispan cache that has a referenced pojo object by doing a "get(key)" on the cache, for which you want to access, will require a different configured resource-adapter.

There are two options for how the Infinispan schema can be configured in the connector; protobuf annotations or protobuf (.proto) file with marshaller(s). The following are the requirements.

Requirement

  • (option 1) Minimum, JDG 6.2 - this requires you provide a protobuf definition file and pojo marshaller(s) for the pojo to configure the JDG schema

  • (option 2) Minimum, JDG 6.6 - this can be used when the pojo has defined protobuf annotations which are used to configure the JDG schema.

See Infinispan HotRod Translator for details on how the the metadata will be exposed or can be manually configured based on the schema that’s defined for this data source.

Configuration

The following property is required as it provides the mapping to the Infinispan cache and pojo that will be accessed.

Property Name Property Template Description

CacheTypeMap

cacheName:className[;pkFieldName[:cacheKeyJavaType]]

For the indicated cacheName, map the root Java Object (pojo) class name. Optionally, but required for updates, identify which class attribute is the primary key to the cache. Optionally, identify primary key java type when different than class attribute type

Protobuf Definition and Marshaller(s)

The following properties are required when the protobuf definition file (.proto) and the pojo marshaller(s) are being used to configure the JDG schema:

Property Name Req. Property Template Description

ProtobufDefinitionFile

Y

Path to the Google Protobuf file that’s packaged in a jar (ex: /quickstart/addressbook.proto)

MessageMarshallers

Y

marshaller \[,marshaller,..\]

Contains Class names mapped its respective message marshaller, (class:marshaller,\[class:marshaller,..\]), that are to be registered for serialization

MessageDescriptor

Y

Message descriptor class name for the root object in cache

Pojo Class/Jar

The pojo class is the object that is used to store the data in the cache. It should be built accordingly:

Sample Pojo with Annotations
public class Person {

   @ProtoField(number = 2, required = true)
   public String name;
   @ProtoField(number = 1, required = true)
   public int id;
   @ProtoField(number = 3)
   public String email;
   private List<PhoneNumber> phones;

   public String getName() {
      return name;
   }

   public void setName(String name) {
      this.name = name;
   }

   public int getId() {
      return id;
   }

   public void setId(int id) {
      this.id = id;
   }

   public String getEmail() {
      return email;
   }

   public void setEmail(String email) {
      this.email = email;
   }

   public List<PhoneNumber> getPhones() {
      return phones;
   }

   public void setPhones(List<PhoneNumber> phones) {
      this.phones = phones;
   }
}

To configure the resource-adapter to use the pojo, do the following:

  • Deploy the pojo jar as a module in the jboss-as server.

Reading and Writing to the Cache

One of the following properties is required for defining how the RemoteCacheManager will be created/accessed:

Property Name Req. Property Template Description

CacheJndiName

N

JNDI name to find the CacheContainer

RemoteServerList

N

host:port\[;host:port….\]

Specify the host and ports that will be clustered together to access the caches

HotRodClientPropertiesFile

N

The HotRod properties file for configuring a connection to a remote cache

The following property should be defined when using protobuf definition file and marshallers:

Property Name Req. Property Template Description

module

N

Specify the WildFly module that contains the cache classes that need to be loaded

Using Remote Cache for External Materialization

The following are the additional properties that need to be configured if using the Remote Cache for external materialization:

Property Name Req. Description

StagingCacheName

Y

Cache name for the staging cache used in materialization

AliasCacheName

Y

Cache name for the alias cache used in tracking aliasing of the caches used in materialization. This cache can be shared with other configured materializations.

Examples

There are many ways to create the data source, using CLI, AdminShell, admin-console etc. The first example is an xml snippet of a resource-adapter that is used to connect to the JDG remote-query quick start:me

Sample Resource Adapter defining Protobuf Definition and Marshaller
               <resource-adapter id="infinispanRemQS">
                    <module slot="main" id="org.jboss.teiid.resource-adapter.infinispan.hotrod"/>
                    <connection-definitions>
                        <connection-definition class-name="org.teiid.resource.adapter.infinispan.hotrod.InfinispanManagedConnectionFactory" jndi-name="java:/infinispanRemote" enabled="true" use-java-context="true" pool-name="infinispanDS">
                            <config-property name="CacheTypeMap">
                                addressbook:org.jboss.as.quickstarts.datagrid.hotrod.query.domain.Person;id
                            </config-property>
                            <config-property name="ProtobufDefinitionFile">
                                 /quickstart/addressbook.proto
                            </config-property>
                            <config-property name="MessageDescriptor">
                                quickstart.Person
                            </config-property>
                            <config-property name="Module">
                                com.client.quickstart.pojos
                            </config-property>
                            <config-property name="MessageMarshallers">                              org.jboss.as.quickstarts.datagrid.hotrod.query.domain.Person:org.jboss.as.quickstarts.datagrid.hotrod.query.marshallers.PersonMarshaller,org.jboss.as.quickstarts.datagrid.hotrod.query.domain.PhoneNumber:org.jboss.as.quickstarts.datagrid.hotrod.query.marshallers.PhoneNumberMarshaller,org.jboss.as.quickstarts.datagrid.hotrod.query.domain.PhoneType:org.jboss.as.quickstarts.datagrid.hotrod.query.marshallers.PhoneTypeMarshaller
                            </config-property>
                            <config-property name="RemoteServerList">
                                127.0.0.1:11322
                            </config-property>
                        </connection-definition>
                    </connection-definitions>
                </resource-adapter>
Sample Resource Adapter using Pojo with annotations
               <resource-adapter id="infinispanRemQSDSL">
                    <module slot="main" id="org.jboss.teiid.resource-adapter.infinispan.dsl"/>
                    <connection-definitions>
                        <connection-definition class-name="org.teiid.resource.adapter.infinispan.dsl.InfinispanManagedConnectionFactory" jndi-name="java:/infinispanRemoteDSL" enabled="true" use-java-context="true" pool-name="infinispanRemoteDSL">
                            <config-property name="RemoteServerList">
                                127.0.0.1:11322
                            </config-property>
                            <config-property name="CacheTypeMap">
                                addressbook_indexed:org.jboss.as.quickstarts.datagrid.hotrod.query.domain.Person;id
                            </config-property>
                        </connection-definition>
                    </connection-definitions>
                </resource-adapter>
Sample Resource Adapter for external materialization
                <resource-adapter id="infinispanRemQSDSL">
                    <module slot="main" id="org.jboss.teiid.resource-adapter.infinispan.hotrod"/>
                    <connection-definitions>
                        <connection-definition class-name="org.teiid.resource.adapter.infinispan.hotrod.InfinispanManagedConnectionFactory" jndi-name="java:/infinispanRemoteDSL" enabled="true" use-java-context="true" pool-name="infinispanRemoteDSL">
                            <config-property name="CacheTypeMap">
                                addressbook_indexed:org.jboss.as.quickstarts.datagrid.hotrod.query.domain.Person;id
                            </config-property>
                            <config-property name="StagingCacheName">
                                addressbook_indexed_mat
                            </config-property>
                            <config-property name="AliasCacheName">
                                aliasCache
                            </config-property>
                            <config-property name="Module">
                                com.client.quickstart.addressbook.pojos
                            </config-property>
                            <config-property name="RemoteServerList">
                                127.0.0.1:11322
                            </config-property>
                        </connection-definition>
                    </connection-definitions>
                </resource-adapter>

results matching ""

    No results matching ""