JBoss Data Grid (JDG) Library Mode Data Sources

JDG Libary Mode data sources use a Teiid specific JCA connector that is deployed into WildFly 10.0.0 during installation. This connector has the following options that can be configured to access an JDG cache running in library mode:

  • Using JNDI

  • Using configuration file

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

Configuration

Accessing Cache in Library Mode

One of the following properties is required for defining how the cache will be accessed via the CacheManager:

Property Name

Description

CacheJndiName

JNDI name used to find the CacheContainer

ConfigurationFileNameForLocalCache

The JDG Configuration xml file will be used to create and configure the CacheManager as a local 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

The following configures the module that contains the pojo stored in the cache:

Property Name

Req.

Description

module

N

Specify the WildFly module that contains the cache classes that were defined in CacheTypeMap

Pojo Jar

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

  • To take advantage of the cache being indexed enabled, should annotate the class. See [JDG documentation|https://access.redhat.com/documentation/en-US/Red_Hat_JBoss_Data_Grid/6.6/html-single/Infinispan_Query_Guide/index.html#chap-Annotating_Objects_and_Querying]

  • The class should be packaged into a jar so that it can be deployed as a module

To configure the use of the pojo, do the following:

  • Deploy the pojo jar as a module in the jboss-as server. Then define the "lib" property in the -vdb.xml and assign the correct module name. This can be done using the following template:

      <property name ="lib" value ="{pojo_module_name}"></property>
  • The JDG commons module, org.infinispan.commons, slot="jdg-6.x" or slot for version installed, needs to have the pojo dependency added:

      <module name="{pojo_module_name}"   export="true" />

Using 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

Server Configuration

There are many ways to create the data source; using CLI, AdminShell, admin-console etc. The example shown below uses the CLI tool, as this works in both Standalone and Domain modes.

Execute following command using CLI once you connected to the Server. Make sure you provide the correct directory name and other properties below. Add any additional properties required by the connector by duplicating the "connection-definitions" command below. Edit the JNDI name to match the JNDI name you used in VDB.

batch
/subsystem=resource-adapters/resource-adapter=infinispan/connection-definitions=infinispanDS:add(jndi-name=java:/infinispanDS, class-name=org.teiid.resource.adapter.infinispan.libmode.InfinispanManagedConnectionFactory, enabled=true, use-java-context=true)
/subsystem=resource-adapters/resource-adapter=infinispan/connection-definitions=infinispanDS/config-properties=CacheTypeMap:add(value=trades:org.somewhere.Trade;tradeId)
/subsystem=resource-adapters/resource-adapter=infinispan/connection-definitions=infinispanDS/config-properties=Module:add(value=org.somewhere)
/subsystem=resource-adapters/resource-adapter=infinispan/connection-definitions=infinispanDS/config-properties=CacheJndiName:add(value=java:/myCache)
runbatch

To find out all the properties that are supported by this Infinispan Connector execute the following command in the CLI.

/subsystem=teiid:read-rar-description(rar-name=infinispan)
Tip
Developer’s Tip - If WildFly 10.0.0 is running in standalone mode, you can also manually edit the "<jboss-install>/standalone/configuration/standalone-teiid.xml" file and add the XML configuration defined in *"<jboss-install>/docs/teiid/datasources/infinispan" directory under "resource-adapters" subsystem. Shutdown the server before you edit this file, and restart after the modifications are done.
Note
Avoid Classloading Issues: If you are using a servlet or other type of web application to create the DefaultCacheManager for the cache, be sure not to include the Infinispan jar dependencies in the application, but add their module dependencies.

results matching ""

    No results matching ""