JBoss Data Grid (JDG) HotRod Data Sources

JDG 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 JDG cache using the the Hot Rod client.

It is assumed that you will be installing the JDG Hotrod Client EAP Modules Kit, which can be obtained on the Red Hat’s Customer Portal at https://access.redhat.com/jbossnetwork/restricted/listSoftware.html.

To handle pojo types in the same cache, where each pojo object can be accessed by performing a "get(key)" on the cache, will require a different configured resource-adapter for each pojo type.

There are two options for how the JDG 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

There are many different ways to configure this resource-adapter based on different usage scenarios:

  • complexity of the pojo (i.e, pojo contains other pojo’s).

  • using either pojo protobuf annotations or protobuf definition files, to configure the JDG schema

  • wanting the enable HotRod client to use SSL

  • utilizing the JDG cache for materialization

Accessing HotRod Remote 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

Configuring Which Cache and Pojo

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

Property Name Property Template Description

CacheTypeMap

cacheName:className[:pkFieldName[:cacheKeyJavaType]]

Defines the cache name and pojo components for accessing the cache

Where
  • cacheName - Name of the cache to access

  • className - Class name of the pojo that is used to store the data in the cache

  • pkFieldName - [Optional] identifies the pojo class attribute that is used as the primary key. It is required for updates or if the pojo contains complex objects used in relationships (1-to-1 or 1-to-many). The pkFieldName MUST match a corresponding getter/setter method in the pojo

  • cacheKeyJavaType - [Optional] identify primary key java type when different than class attribute type

JDG Schema using 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 descriptor file that’s packaged in a jar (ex: /quickstart/addressbook.proto)

MessageMarshallers

Y

className:marshallerClassName \[,className:marshallerClassName,..\]

Contains Class name(s) mapped to its respective message marshaller(s) that is to be registered for serialization

MessageDescriptor

Y

Message descriptor package name in the protobuf descriptor file

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

JDG Schema using Pojo Annotations

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

Property Name Property Template Description

ChildClasses

className[,className,..]]

comma separated list of class names that indicate the child classes to register in the JDG schema

Enable Hotrod Client SSL

To enable the Hotrod client in the resource-adapter to communicate using SSL, configure the following properties on the resource adapter:

Property Name Description

TrustStoreFileName

File name of the truststore

TrustStorePassword

TrustStore Password

KeyStoreFileName

File name of the keystore

KeyStorePassword

KeyStore Password

SNIHostName

[optional] SNI Host Name

Using 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.

1st Example

The 1st example is an xml snippet of a resource-adapter that is using probufs and marshallers to configure the JDG schema:

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>

2nd Example

The 2nd example showing a pojo example with annotations and the xml snippet of the resource-adapter:

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;
   }
}
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>
                            <config-property name="ChildClasses">
                               org.jboss.as.quickstarts.datagrid.hotrod.query.domain.PhoneNumber
                            </config-property>
                        </connection-definition>
                    </connection-definitions>
                </resource-adapter>

3rd Example

The 3rd example is using the JDG data source for materialization.

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 ""