2.7. Data Grid Connection Settings
OPENMARU Cluster reads the hotrod.properties file to connect to the data grid (Infinispan) servers. HotRod is the name of the protocol used to connect to Infinispan servers. This chapter explains what goes in this file.
File Location
The file name given in the configFile setting is looked up in the following order, and the first one found is used. Write only the file name, without a path. Absolute paths (/opt/...) cannot be used.
- Tomcat's
confdirectory ($CATALINA_BASE/conf/hotrod.properties) - The application classpath (
WEB-INF/classes/hotrod.properties; for Spring Boot,src/main/resources/hotrod.properties)
Example
The example below uses two servers with account authentication. Start with this content and change only what you need.
# Data grid server addresses (separate multiple servers with ;)
infinispan.client.hotrod.server_list = 192.168.0.11:11222;192.168.0.12:11222
# When the servers require user authentication
infinispan.client.hotrod.auth_username = appuser
infinispan.client.hotrod.auth_password = changeme
# How session objects are converted to bytes (use as is)
infinispan.client.hotrod.marshaller = org.infinispan.commons.marshall.JavaSerializationMarshaller
# Classes that may be read back from the data grid
infinispan.client.hotrod.java_serial_allowlist = java.lang.*,java.util.*,io.openmaru.cluster.KhanSessionMetadata,^com.mycompany.app.
# Connection and response timeouts (milliseconds)
infinispan.client.hotrod.connect_timeout = 5000
infinispan.client.hotrod.socket_timeout = 5000
# Connection pool
infinispan.client.hotrod.connection_pool.max_active = 250
infinispan.client.hotrod.connection_pool.max_wait = 5000
| Setting | What it decides |
|---|---|
server_list | IP and HotRod port (11222 by default) of the data grid servers. Separate multiple servers with ; |
auth_username, auth_password | Account for the data grid servers. Omit if the servers have no authentication |
marshaller | How session objects are converted to bytes. Use the value above as is |
java_serial_allowlist | Classes that may be read back from the data grid. See "Writing the Allow List" below |
connect_timeout, socket_timeout | Maximum time to wait for a server connection and for a response |
connection_pool.* | Number of connections kept open to the servers and how long to wait for one |
The defaults are sufficient for everything else. If tuning is needed, contact your engineer.
To change only the server addresses in a container environment, use the KSM_SERVER_LIST environment variable. When it has a value, it is used instead of server_list in the file.
export KSM_SERVER_LIST="192.168.0.21:11222;192.168.0.22:11222"
Writing the Allow List
java_serial_allowlist lists the classes that may be read back from the data grid and turned into objects again. Classes not on the list are not read, and an ISPN000936 error is raised. The wider the list, the more unintended classes can be read, so list only the classes actually placed in the session.
Entries are separated by commas, and each is compared as a regular expression. An entry is allowed if it matches only part of a class name. So when you write a package, put ^ in front to anchor it to the start of the class name.
| How it is written | Result |
|---|---|
^com.mycompany.app. | Only classes starting with the com.mycompany.app package are allowed (recommended) |
com.mycompany.app. | Other classes whose names contain com.mycompany.app. somewhere are also allowed |
io.openmaru.*, com.opennaru.* | Too wide. Warning KSM-SJ-005 is logged at startup |
Build the list in this order.
-
Add the basic entries:
java.lang.*,java.util.*,io.openmaru.cluster.KhanSessionMetadata -
Add the packages of the classes your application puts in the session, anchored with
^. Example:^com.mycompany.app. -
If you use Spring Security, add
org.springframework.security.*. -
If you use Spring Security OIDC login (
oauth2Login, Keycloak, and so on), add the following as well. When login fails, error information is placed in the session and must also be readable.,org.springframework.web.client.*,org.springframework.http.*,org.springframework.core.NestedRuntimeException,org.springframework.util.LinkedCaseInsensitiveMap,org.springframework.util.MultiValueMapAdapterIf you put OIDC user information (token contents) in the session, also add
java.time.*,java.net.URL, andnet.minidev.json.*. -
Run the application and check whether
ISPN000936appears in the log. If it does, add the class named in the message to the list.
Example list for an application that uses Spring Security with OIDC login:
infinispan.client.hotrod.java_serial_allowlist = java.lang.*,java.util.*,java.time.*,java.net.URL,io.openmaru.cluster.KhanSessionMetadata,^com.mycompany.app.,org.springframework.security.*,org.springframework.web.client.*,org.springframework.http.*,org.springframework.core.NestedRuntimeException,org.springframework.util.LinkedCaseInsensitiveMap,org.springframework.util.MultiValueMapAdapter,net.minidev.json.*
When the Firewall Opens Only the Front Address (VIP)
In some environments an L4 switch's representative address (VIP, virtual IP) sits in front of the data grid servers, and the firewall is open only to that VIP.
With the default settings, after the first connection through the VIP the client uses the server list it receives and connects directly to each data grid server. If the firewall opens only the VIP, these direct connections are blocked.
In that case, add the following line so that the client connects only through the VIP.
infinispan.client.hotrod.server_list = 10.0.0.100:11222
infinispan.client.hotrod.client_intelligence = BASIC
Put the VIP address in server_list. If the firewall is open to each server, do not add this line. The default settings connect straight to the server that holds the session, which is more efficient.
Adjusting Log Levels
The installation file contains the Infinispan client and Netty (a network library). Their log names are prefixed with io.openmaru.shaded.. OPENMARU Cluster's own log name (io.openmaru) is unchanged.
Example for Tomcat's $CATALINA_BASE/conf/logging.properties:
io.openmaru.level = WARNING
io.openmaru.shaded.org.infinispan.level = WARNING
io.openmaru.shaded.io.netty.level = WARNING
For Spring Boot, write the following in application.properties.
logging.level.io.openmaru.shaded.org.infinispan=WARN
logging.level.io.openmaru.shaded.io.netty=WARN
Lines written as org.infinispan or io.netty do not apply to the Infinispan and Netty inside the installation file. They apply only to any Infinispan or Netty the application uses on its own.
If io.openmaru.level is WARNING, the startup log (INFO) checked in step 4 of 2.1 does not appear. Set it to INFO temporarily while confirming the installation.
Netty System Properties
If your WAS startup options include Netty or jboss-logging system properties (-Dio.netty.*, -Dorg.jboss.logging.*), prefix the names with io.openmaru.shaded. to apply them to the Netty inside the installation file.
| Option you use now | To apply it to the libraries inside the installation file |
|---|---|
-Dio.netty.leakDetection.level=… | -Dio.openmaru.shaded.io.netty.leakDetection.level=… |
-Dio.netty.allocator.type=… | -Dio.openmaru.shaded.io.netty.allocator.type=… |
-Dio.netty.eventLoopThreads=… | -Dio.openmaru.shaded.io.netty.eventLoopThreads=… |
-Dio.netty.<other> | -Dio.openmaru.shaded.io.netty.<other> |
-Dorg.jboss.logging.provider=… | -Dio.openmaru.shaded.org.jboss.logging.provider=… |
If an option with the original name exists, one warning line is logged at startup. Options with the original name still apply to any Netty the application uses on its own.
Settings That Take Infinispan Class Names
For settings whose value is an Infinispan class name, such as marshaller, write the name shown in the Infinispan documentation (org.infinispan.…) as is. At startup it is translated to the name that matches the installation file.
Some settings are not translated automatically. If warning KSM-SJ-003 or error KSM-SJ-004 appears in the startup log, prefix the value of the setting named in the log with io.openmaru.shaded..
HotRod Client MBean
If you turn on the HotRod client's own MBean with infinispan.client.hotrod.jmx = true in hotrod.properties, the MBean name is as follows.
io.openmaru.shaded.org.infinispan:type=HotRodClient,name=Default
To choose the name yourself, set infinispan.client.hotrod.jmx_domain. The name of the session metrics MBean (com.opennaru.khan.session:type=SessionMonitor,…) does not depend on this setting (see 3.1).