Administration and Configuration Guide
For use with Red Hat JBoss Data Grid 6.2.1
Abstract
Chapter 1. Setting up Red Hat JBoss Data Grid Copy linkLink copied to clipboard!
1.1. Prerequisites Copy linkLink copied to clipboard!
1.2. Steps to Set up Red Hat JBoss Data Grid Copy linkLink copied to clipboard!
Procedure 1.1. Set Up JBoss Data Grid
Set Up the Cache Manager
The first step in a JBoss Data Grid configuration is a cache manager. Cache managers can retrieve cache instances and create cache instances quickly and easily using previously specified configuration templates. For details about setting up a cache manager, see Part I, “Set Up a Cache Manager”Set Up JVM Memory Management
An important step in configuring your JBoss Data Grid is to set up memory management for your Java Virtual Machine (JVM). JBoss Data Grid offers features such as eviction and expiration to help manage the JVM memory.Set Up Eviction
Use eviction to specify the logic used to remove entries from the in-memory cache implementation based on how often they are used. JBoss Data Grid offers different eviction strategies for finer control over entry eviction in your data grid. Eviction strategies and instructions to configure them are available in Chapter 3, Set Up Eviction.Set Up Expiration
To set upper limits to an entry's time in the cache, attach expiration information to each entry. Use expiration to set up the maximum period an entry is allowed to remain in the cache and how long the retrieved entry can remain idle before being removed from the cache. For details, see Chapter 4, Set Up Expiration
Monitor Your Cache
JBoss Data Grid uses logging via JBoss Logging to help users monitor their caches.Set Up Logging
It is not mandatory to set up logging for your JBoss Data Grid, but it is highly recommended. JBoss Data Grid uses JBoss Logging, which allows the user to easily set up automated logging for operations in the data grid. Logs can subsequently be used to troubleshoot errors and identify the cause of an unexpected failure. For details, see Chapter 5, Set Up Logging
Set Up Cache Modes
Cache modes are used to specify whether a cache is local (simple, in-memory cache) or a clustered cache (replicates state changes over a small subset of nodes). Additionally, if a cache is clustered, either replication, distribution or invalidation mode must be applied to determine how the changes propagate across the subset of nodes. For details, see Part IV, “Set Up Cache Modes”Set Up Locking for the Cache
When replication or distribution is in effect, copies of entries are accessible across multiple nodes. As a result, copies of the data can be accessed or modified concurrently by different threads. To maintain consistency for all copies across nodes, configure locking. For details, see Part V, “Set Up Locking for the Cache” and Chapter 12, Set Up Isolation LevelsSet Up and Configure a Cache Store
JBoss Data Grid offers the passivation feature (or cache writing strategies if passivation is turned off) to temporarily store entries removed from memory in a persistent, external cache store. To set up passivation or a cache writing strategy, you must first set up a cache store.Set Up a Cache Store
The cache store serves as a connection to the persistent store. Cache stores are primarily used to fetch entries from the persistent store and to push changes back to the persistent store. For details, see Part VI, “Set Up and Configure a Cache Store”Set Up Passivation
Passivation stores entries evicted from memory in a cache store. This feature allows entries to remain available despite not being present in memory and prevents potentially expensive write operations to the persistent cache. For details, see Part VII, “Set Up Passivation”Set Up a Cache Writing Strategy
If passivation is disabled, every attempt to write to the cache results in writing to the cache store. This is the default Write-Through cache writing strategy. Set the cache writing strategy to determine whether these cache store writes occur synchronously or asynchronously. For details, see Part VIII, “Set Up Cache Writing”
Monitor Caches and Cache Managers
JBoss Data Grid includes two primary tools to monitor the cache and cache managers once the data grid is up and running.Set Up JMX
JMX is the standard statistics and management tool used for JBoss Data Grid. Depending on the use case, JMX can be configured at a cache level or a cache manager level or both. For details, see Chapter 19, Set Up Java Management Extensions (JMX)Set Up Red Hat JBoss Operations Network (JON)
Red Hat JBoss Operations Network (JON) is the second monitoring solution available for JBoss Data Grid. JBoss Operations Network (JON) offers a graphical interface to monitor runtime parameters and statistics for caches and cache managers. For details, see Chapter 20, Set Up JBoss Operations Network (JON)
Introduce Topology Information
Optionally, introduce topology information to your data grid to specify where specific types of information or objects in your data grid are located. Server hinting is one of the ways to introduce topology information in JBoss Data Grid.Set Up Server Hinting
When set up, server hinting provides high availability by ensuring that the original and backup copies of data are not stored on the same physical server, rack or data center. This is optional in cases such as a replicated cache, where all data is backed up on all servers, racks and data centers. For details, see Chapter 26, High Availability Using Server Hinting
Part I. Set Up a Cache Manager Copy linkLink copied to clipboard!
Chapter 2. Cache Managers Copy linkLink copied to clipboard!
- it creates multiple cache instances on demand using a provided standard.
- it retrieves existing cache instanced (i.e. caches that have already been created).
2.1. Types of Cache Managers Copy linkLink copied to clipboard!
EmbeddedCacheManageris a cache manager that runs within the Java Virtual Machine (JVM) used by the client. Currently, JBoss Data Grid offers only theDefaultCacheManagerimplementation of theEmbeddedCacheManagerinterface.RemoteCacheManageris used to access remote caches. When started, theRemoteCacheManagerinstantiates connections to the Hot Rod server (or multiple Hot Rod servers). It then manages the persistentTCPconnections while it runs. As a result,RemoteCacheManageris resource-intensive. The recommended approach is to have a singleRemoteCacheManagerinstance for each Java Virtual Machine (JVM).
2.2. Creating CacheManagers Copy linkLink copied to clipboard!
2.2.1. Create a New RemoteCacheManager Copy linkLink copied to clipboard!
RemoteCacheManager:
An explanation of each line of the provided configuration is as follows:
- Use the
ConfigurationBuilder()method to configure a new builder. The.addServer()property adds a remote server, specified via the.host(<hostname|ip>)and.port(<port>)properties.Configuration conf = new ConfigurationBuilder().addServer().host(<hostname|ip>).port(<port>).build();
Configuration conf = new ConfigurationBuilder().addServer().host(<hostname|ip>).port(<port>).build();Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a new
RemoteCacheManagerusing the supplied configuration.RemoteCacheManager manager = new RemoteCacheManager(conf);
RemoteCacheManager manager = new RemoteCacheManager(conf);Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Retrieve the default cache from the remote server.
RemoteCache defaultCache = manager.getCache();
RemoteCache defaultCache = manager.getCache();Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2.2. Create a New Embedded Cache Manager Copy linkLink copied to clipboard!
Procedure 2.1. Create a New Embedded Cache Manager
- Create a configuration XML file. For example, create the
my-config.file.xmlfile on the classpath (in theresources/folder) and add the configuration information in this file. - Use the following programmatic configuration to create a cache manager using the configuration file:
EmbeddedCacheManager manager = new DefaultCacheManager("my-config-file.xml"); Cache defaultCache = manager.getCache();EmbeddedCacheManager manager = new DefaultCacheManager("my-config-file.xml"); Cache defaultCache = manager.getCache();Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.2.3. Create a New Embedded Cache Manager Using CDI Copy linkLink copied to clipboard!
Procedure 2.2. Use CDI to Create a New EmbeddedCacheManager
- Specify a default configuration:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a clustered or a non-clustered cache.
- Invoke the method to create an EmbeddedCacheManager.
... @Inject EmbeddedCacheManager cacheManager; ...
... @Inject EmbeddedCacheManager cacheManager; ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.3. Multiple Cache Managers Copy linkLink copied to clipboard!
2.3.1. Create Multiple Caches with a Single Cache Manager Copy linkLink copied to clipboard!
2.3.2. Using Multiple Cache Managers Copy linkLink copied to clipboard!
TCP protocol and the other uses the UDP protocol, multiple cache managers must be used.
2.3.3. Create Multiple Cache Managers Copy linkLink copied to clipboard!
infinispan.xml file to a new configuration file. Edit the new file for the desired configuration and then use the new file for a new cache manager.
Part II. Set Up JVM Memory Management Copy linkLink copied to clipboard!
Chapter 3. Set Up Eviction Copy linkLink copied to clipboard!
3.1. About Eviction Copy linkLink copied to clipboard!
3.2. Eviction Strategies Copy linkLink copied to clipboard!
| Strategy Name | Operations | Details |
|---|---|---|
EvictionStrategy.NONE | No eviction occurs. | - |
EvictionStrategy.LRU | Least Recently Used eviction strategy. This strategy evicts entries that have not been used for the longest period. This ensures that entries that are reused periodically remain in memory. | |
EvictionStrategy.UNORDERED | Unordered eviction strategy. This strategy evicts entries without any ordered algorithm and may therefore evict entries that are required later. However, this strategy saves resources because no algorithm related calculations are required before eviction. | This strategy is recommended for testing purposes and not for a real work implementation. |
EvictionStrategy.LIRS | Low Inter-Reference Recency Set eviction strategy. | LIRS is Red Hat JBoss Data Grid's default eviction algorithm because it suits a large variety of production use cases. |
3.2.1. LRU Eviction Algorithm Limitations Copy linkLink copied to clipboard!
- Single use access entries are not replaced in time.
- Entries that are accessed first are unnecessarily replaced.
3.3. Using Eviction Copy linkLink copied to clipboard!
eviction /> element is used to enable eviction without any strategy or maximum entries settings, the following default values are automatically implemented:
- Strategy: If no eviction strategy is specified,
EvictionStrategy.NONEis assumed as a default. - max-entries/maxEntries: If no value is specified, the
max-entries/maxEntries value is set to-1, which allows unlimited entries.
3.3.1. Initialize Eviction Copy linkLink copied to clipboard!
max-entries attributes value to a number greater than zero. Adjust the value set for max-entries to discover the optimal value for your configuration. It is important to remember that if too large a value is set for max-entries, Red Hat JBoss Data Grid runs out of memory.
Procedure 3.1. Initialize Eviction
Add the Eviction Tag
Add the <eviction> tag to your project's <cache> tags as follows:<eviction />
<eviction />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Eviction Strategy
Set thestrategyvalue to set the eviction strategy employed. Possible values areLRU,UNORDEREDandLIRS(orNONEif no eviction is required). The following is an example of this step:<eviction strategy="LRU" />
<eviction strategy="LRU" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Maximum Entries
Set the maximum number of entries allowed in memory. The default value is-1for unlimited entries.- In Library mode, set the
maxEntriesparameter as follows:<eviction strategy="LRU" maxEntries="200" />
<eviction strategy="LRU" maxEntries="200" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow - In Remote Client Server mode, set the
max-entriesas follows:<eviction strategy="LRU" max-entries="200" />
<eviction strategy="LRU" max-entries="200" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Eviction is configured for the target cache.
3.3.2. Eviction Configuration Examples Copy linkLink copied to clipboard!
- A sample XML configuration for Library mode is as follows:
<eviction strategy="LRU" maxEntries="2000"/>
<eviction strategy="LRU" maxEntries="2000"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - A sample XML configuration for Remote Client Server Mode is as follows:
<eviction strategy="LRU" max-entries="20"/>
<eviction strategy="LRU" max-entries="20"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow - A sample programmatic configuration for Library Mode is as follows:
Configuration c = new ConfigurationBuilder().eviction().strategy(EvictionStrategy.LRU) .maxEntries(2000) .build();Configuration c = new ConfigurationBuilder().eviction().strategy(EvictionStrategy.LRU) .maxEntries(2000) .build();Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
maxEntries parameter while Remote Client-Server mode uses the max-entries parameter to configure eviction.
3.3.3. Eviction Configuration Troubleshooting Copy linkLink copied to clipboard!
max-entries parameter of the configuration element. This is because although the max-entries value can be configured to a value that is not a power of two, the underlying algorithm will alter the value to V, where V is the closest power of two value that is larger than the max-entries value. Eviction algorithms are in place to ensure that the size of the cache container will never exceed the value V.
3.3.4. Eviction and Passivation Copy linkLink copied to clipboard!
Chapter 4. Set Up Expiration Copy linkLink copied to clipboard!
4.1. About Expiration Copy linkLink copied to clipboard!
- A lifespan value.
- A maximum idle time value.
lifespan or maxIdle value.
- expiration removes entries based on the period they have been in memory. Expiration only removes entries when the life span period concludes or when an entry has been idle longer than the specified idle time.
- eviction removes entries based on how recently (and often) they are used. Eviction only removes entries when too many entries are present in the memory. If a cache store has been configured, evicted entries are persisted in the cache store.
4.2. Expiration Operations Copy linkLink copied to clipboard!
lifespan) or maximum idle time (maxIdle in Library Mode and max-idle in Remote Client-Server Mode) defined for an individual key/value pair overrides the cache-wide default for the entry in question.
4.3. Eviction and Expiration Comparison Copy linkLink copied to clipboard!
lifespan) and idle time (maxIdle in Library Mode and max-idle in Remote Client-Server Mode) values are replicated alongside each cache entry.
4.4. Cache Entry Expiration Notifications Copy linkLink copied to clipboard!
- A user thread requests an entry and discovers that the entry has expired.
- An entry is passivated/overflowed to disk and is discovered to have expired.
- The eviction maintenance thread discovers that an entry it has found is expired.
4.5. Configure Expiration Copy linkLink copied to clipboard!
Procedure 4.1. Configure Expiration
Add the Expiration Tag
Add the <expiration> tag to your project's <cache> tags as follows:<expiration />
<expiration />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Expiration Lifespan
Set thelifespanvalue to set the period of time (in milliseconds) an entry can remain in memory. The following is an example of this step:<expiration lifespan="1000" />
<expiration lifespan="1000" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Maximum Idle Time
Set the time that entries are allowed to remain idle (unused) after which they are removed (in milliseconds). The default value is-1for unlimited time.- In Library mode, set the
maxIdleparameter as follows:<expiration lifespan="1000" maxIdle="1000" />
<expiration lifespan="1000" maxIdle="1000" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow - In Remote Client Server mode, set the
max-idleas follows:<expiration lifespan="1000" max-idle="1000" />
<expiration lifespan="1000" max-idle="1000" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Expiration is now configured for the cache implementation.
4.6. Mortal and Immortal Data Copy linkLink copied to clipboard!
put(key, value) creates an entry that will never expire, called an immortal entry. Alternatively, an entry created using put(key, value, lifespan, timeunit) is a mortal entry that has a specified fixed life span, after which it expires.
lifespan parameter, JBoss Data Grid also provides a maxIdle parameter used to determine expiration. The maxIdle and lifespan parameters can be used in various combinations to set the life span of an entry.
4.7. Troubleshooting Expiration Copy linkLink copied to clipboard!
put() are passed a life span value as a parameter. This value defines the interval after which the entry must expire. In cases where eviction is not configured and the life span interval expires, it can appear as if Red Hat JBoss Data Grid has not removed the entry. For example, when viewing JMX statistics, such as the number of entries, you may see an out of date count, or the persistent store associated with JBoss Data Grid may still contain this entry. Behind the scenes, JBoss Data Grid has marked it as an expired entry, but has not removed it. Removal of such entries happens in one of two ways:
- Any attempt to use
get()orcontainsKey()for the expired entry, causes JBoss Data Grid to detect the entry as an expired one and remove it. - Enabling the eviction feature causes the eviction thread to periodically detect and purge expired entries.
Part III. Monitor Your Cache Copy linkLink copied to clipboard!
Chapter 5. Set Up Logging Copy linkLink copied to clipboard!
5.1. About Logging Copy linkLink copied to clipboard!
5.2. Supported Application Logging Frameworks Copy linkLink copied to clipboard!
- JBoss Logging, which is included with Red Hat JBoss Data Grid 6.
5.2.1. About JBoss Logging Copy linkLink copied to clipboard!
5.2.2. JBoss Logging Features Copy linkLink copied to clipboard!
- Provides an innovative, easy to use typed logger.
- Full support for internationalization and localization. Translators work with message bundles in properties files while developers can work with interfaces and annotations.
- Build-time tooling to generate typed loggers for production, and runtime generation of typed loggers for development.
5.3. Boot Logging Copy linkLink copied to clipboard!
5.3.1. Configure Boot Logging Copy linkLink copied to clipboard!
logging.properties file to configure the boot log. This file is a standard Java properties file and can be edited in a text editor. Each line in the file has the format of property=value.
logging.properties file is available in the $JDG_HOME/standalone/configuration folder.
5.3.2. Default Log File Locations Copy linkLink copied to clipboard!
| Log File | Location | Description |
|---|---|---|
boot.log | $JDG_HOME/standalone/log/ | The Server Boot Log. Contains log messages related to the start up of the server. |
server.log | $JDG_HOME/standalone/log/ | The Server Log. Contains all log messages once the server has launched. |
5.4. Logging Attributes Copy linkLink copied to clipboard!
5.4.1. About Log Levels Copy linkLink copied to clipboard!
TRACEDEBUGINFOWARNERRORFATAL
WARN will only record messages of the levels WARN, ERROR and FATAL.
5.4.2. Supported Log Levels Copy linkLink copied to clipboard!
| Log Level | Value | Description |
|---|---|---|
| FINEST | 300 | - |
| FINER | 400 | - |
| TRACE | 400 | Used for messages that provide detailed information about the running state of an application. TRACE level log messages are captured when the server runs with the TRACE level enabled. |
| DEBUG | 500 | Used for messages that indicate the progress of individual requests or activities of an application. DEBUG level log messages are captured when the server runs with the DEBUG level enabled. |
| FINE | 500 | - |
| CONFIG | 700 | - |
| INFO | 800 | Used for messages that indicate the overall progress of the application. Used for application start up, shut down and other major lifecycle events. |
| WARN | 900 | Used to indicate a situation that is not in error but is not considered ideal. Indicates circumstances that can lead to errors in the future. |
| WARNING | 900 | - |
| ERROR | 1000 | Used to indicate an error that has occurred that could prevent the current activity or request from completing but will not prevent the application from running. |
| SEVERE | 1000 | - |
| FATAL | 1100 | Used to indicate events that could cause critical service failure and application shutdown and possibly cause JBoss Data Grid to shut down. |
5.4.3. About Log Categories Copy linkLink copied to clipboard!
WARNING log level results in log values of 900, 1000 and 1100 are captured.
5.4.4. About the Root Logger Copy linkLink copied to clipboard!
server.log. This file is sometimes referred to as the server log.
5.4.5. About Log Handlers Copy linkLink copied to clipboard!
ConsoleFilePeriodicSizeAsyncCustom
5.4.6. Log Handler Types Copy linkLink copied to clipboard!
| Log Handler Type | Description | Use Case |
|---|---|---|
| Console | Console log handlers write log messages to either the host operating system’s standard out (stdout) or standard error (stderr) stream. These messages are displayed when JBoss Data Grid is run from a command line prompt. | The Console log handler is preferred when JBoss Data Grid is administered using the command line. In such a case, the messages from a Console log handler are not saved unless the operating system is configured to capture the standard out or standard error stream. |
| File | File log handlers are the simplest log handlers. Their primary use is to write log messages to a specified file. | File log handlers are most useful if the requirement is to store all log entries according to the time in one place. |
| Periodic | Periodic file handlers write log messages to a named file until a specified period of time has elapsed. Once the time period has elapsed, the specified time stamp is appended to the file name. The handler then continues to write into the newly created log file with the original name. | The Periodic file handler can be used to accumulate log messages on a weekly, daily, hourly or other basis depending on the requirements of the environment. |
| Size | Size log handlers write log messages to a named file until the file reaches a specified size. When the file reaches a specified size, it is renamed with a numeric prefix and the handler continues to write into a newly created log file with the original name. Each size log handler must specify the maximum number of files to be kept in this fashion. | The Size handler is best suited to an environment where the log file size must be consistent. |
| Async | Async log handlers are wrapper log handlers that provide asynchronous behavior for one or more other log handlers. These are useful for log handlers that have high latency or other performance problems such as writing a log file to a network file system. | The Async log handlers are best suited to an environment where high latency is a problem or when writing to a network file system. |
| Custom | Custom log handlers enable to you to configure new types of log handlers that have been implemented. A custom handler must be implemented as a Java class that extends java.util.logging.Handler and be contained in a module. | Custom log handlers create customized log handler types and are recommended for advanced users. |
5.4.7. Selecting Log Handlers Copy linkLink copied to clipboard!
- The
Consolelog handler is preferred when JBoss Data Grid is administered using the command line. In such a case, errors and log messages appear on the console window and are not saved unless separately configured to do so. - The
Filelog handler is used to direct log entries into a specified file. This simplicity is useful if the requirement is to store all log entries according to the time in one place. - The
Periodiclog handler is similar to theFilehandler but creates files according to the specified period. As an example, this handler can be used to accumulate log messages on a weekly, daily, hourly or other basis depending on the requirements of the environment. - The
Sizelog handler also writes log messages to a specified file, but only while the log file size is within a specified limit. Once the file size reaches the specified limit, log files are written to a new log file. This handler is best suited to an environment where the log file size must be consistent. - The
Asynclog handler is a wrapper that forces other log handlers to operate asynchronously. This is best suited to an environment where high latency is a problem or when writing to a network file system. - The
Customlog handler creates new, customized types of log handlers. This is an advanced log handler.
5.4.8. About Log Formatters Copy linkLink copied to clipboard!
java.util.Formatter class.
5.5. Logging Sample Configurations Copy linkLink copied to clipboard!
5.5.1. Sample XML Configuration for the Root Logger Copy linkLink copied to clipboard!
Procedure 5.1. Configure the Root Logger
Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <root-logger> <level name="INFO"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <root-logger> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow List
handlershandlersis a list of log handlers that are used by the root logger.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.2. Sample XML Configuration for a Log Category Copy linkLink copied to clipboard!
Procedure 5.2. Configure a Log Category
Define the Category
Use thecategoryproperty to specify the log category from which log messages will be captured.Theuse-parent-handlersis set to"true"by default. When set to"true", this category will use the log handlers of the root logger in addition to any other assigned handlers.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <logger category="com.company.accounts.rec" use-parent-handlers="true">
<subsystem xmlns="urn:jboss:domain:logging:1.2"> <logger category="com.company.accounts.rec" use-parent-handlers="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelpropertyUse thelevelproperty to set the maximum level of log message that the log category records.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <logger category="com.company.accounts.rec" use-parent-handlers="true"> <level name="WARN"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <logger category="com.company.accounts.rec" use-parent-handlers="true"> <level name="WARN"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow List
handlershandlersis a list of log handlers.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.3. Sample XML Configuration for a Console Log Handler Copy linkLink copied to clipboard!
Procedure 5.3. Configure the Console Log Handler
Add the Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.Whenautoflushis set to"true"the log messages will be sent to the handler's target immediately upon request.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true">
<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log messages recorded.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
encodingOutputUseencodingto set the character encoding scheme to be used for the output.<subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/><subsystem xmlns="urn:jboss:domain:logging:1.2"> <console-handler name="CONSOLE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
targetValueThetargetproperty defines the system output stream where the output of the log handler goes. This can beSystem.errfor the system error stream, orSystem.outfor the standard out stream.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
filter-specPropertyThefilter-specproperty is an expression value that defines a filter. The example provided defines a filter that does not match a pattern:not(match("JBAS.*")).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
formatterUseformatterto list the log formatter used by the log handler.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.4. Sample XML Configuration for a File Log Handler Copy linkLink copied to clipboard!
Procedure 5.4. Configure the File Log Handler
Add the File Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.Whenautoflushis set to"true"the log messages will be sent to the handler's target immediately upon request.<file-handler name="accounts-rec-trail" autoflush="true">
<file-handler name="accounts-rec-trail" autoflush="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/><file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
encodingOutputUseencodingto set the character encoding scheme to be used for the output.<file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/><file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
fileObjectThefileobject represents the file where the output of this log handler is written to. It has two configuration properties:relative-toandpath.Therelative-toproperty is the directory where the log file is written to. JBoss Enterprise Application Platform 6 file path variables can be specified here. Thejboss.server.log.dirvariable points to thelog/directory of the server.Thepathproperty is the name of the file where the log messages will be written. It is a relative path name that is appended to the value of therelative-toproperty to determine the complete path.<file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/> <file relative-to="jboss.server.log.dir" path="accounts-rec-trail.log"/><file-handler name="accounts-rec-trail" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/> <file relative-to="jboss.server.log.dir" path="accounts-rec-trail.log"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
formatterUseformatterto list the log formatter used by the log handler.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
appendPropertyWhen theappendproperty is set to"true", all messages written by this handler will be appended to an existing file. If set to"false"a new file will be created each time the application server launches. Changes toappendrequire a server reboot to take effect.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.5. Sample XML Configuration for a Periodic Log Handler Copy linkLink copied to clipboard!
Procedure 5.5. Configure the Periodic Log Handler
Add the Periodic Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.Whenautoflushis set to"true"the log messages will be sent to the handler's target immediately upon request.<periodic-rotating-file-handler name="FILE" autoflush="true">
<periodic-rotating-file-handler name="FILE" autoflush="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<periodic-rotating-file-handler name="FILE" autoflush="true"> <level name="INFO"/>
<periodic-rotating-file-handler name="FILE" autoflush="true"> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
encodingOutputUseencodingto set the character encoding scheme to be used for the output.<periodic-rotating-file-handler name="FILE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/>
<periodic-rotating-file-handler name="FILE" autoflush="true"> <level name="INFO"/> <encoding value="UTF-8"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
formatterUseformatterto list the log formatter used by the log handler.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
fileObjectThefileobject represents the file where the output of this log handler is written to. It has two configuration properties:relative-toandpath.Therelative-toproperty is the directory where the log file is written to. JBoss Enterprise Application Platform 6 file path variables can be specified here. Thejboss.server.log.dirvariable points to thelog/directory of the server.Thepathproperty is the name of the file where the log messages will be written. It is a relative path name that is appended to the value of therelative-toproperty to determine the complete path.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
suffixValueThesuffixis appended to the filename of the rotated logs and is used to determine the frequency of rotation. The format of thesuffixis a dot (.) followed by a date string, which is parsable by thejava.text.SimpleDateFormatclass. The log is rotated on the basis of the smallest time unit defined by thesuffix. For example,yyyy-MM-ddwill result in daily log rotation. See http://docs.oracle.com/javase/6/docs/api/index.html?java/text/SimpleDateFormat.htmlCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
appendPropertyWhen theappendproperty is set to"true", all messages written by this handler will be appended to an existing file. If set to"false"a new file will be created each time the application server launches. Changes toappendrequire a server reboot to take effect.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.6. Sample XML Configuration for a Size Log Handler Copy linkLink copied to clipboard!
Procedure 5.6. Configure the Size Log Handler
Add the Size Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.Whenautoflushis set to"true"the log messages will be sent to the handler's target immediately upon request.<size-rotating-file-handler name="accounts_debug" autoflush="false">
<size-rotating-file-handler name="accounts_debug" autoflush="false">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/>
<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
encodingOutputUseencodingto set the character encoding scheme to be used for the output.<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/> <encoding value="UTF-8"/>
<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/> <encoding value="UTF-8"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
fileObjectThefileobject represents the file where the output of this log handler is written to. It has two configuration properties:relative-toandpath.Therelative-toproperty is the directory where the log file is written to. JBoss Enterprise Application Platform 6 file path variables can be specified here. Thejboss.server.log.dirvariable points to thelog/directory of the server.Thepathproperty is the name of the file where the log messages will be written. It is a relative path name that is appended to the value of therelative-toproperty to determine the complete path.<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/> <encoding value="UTF-8"/> <file relative-to="jboss.server.log.dir" path="accounts-debug.log"/>
<size-rotating-file-handler name="accounts_debug" autoflush="false"> <level name="DEBUG"/> <encoding value="UTF-8"/> <file relative-to="jboss.server.log.dir" path="accounts-debug.log"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
rotate-sizeValueThe maximum size that the log file can reach before it is rotated. A single character appended to the number indicates the size units:bfor bytes,kfor kilobytes,mfor megabytes,gfor gigabytes. For example:50mfor 50 megabytes.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
max-backup-indexNumberThe maximum number of rotated logs that are kept. When this number is reached, the oldest log is reused.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the
formatterUseformatterto list the log formatter used by the log handler.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
appendPropertyWhen theappendproperty is set to"true", all messages written by this handler will be appended to an existing file. If set to"false"a new file will be created each time the application server launches. Changes toappendrequire a server reboot to take effect.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.5.7. Sample XML Configuration for a Async Log Handler Copy linkLink copied to clipboard!
Procedure 5.7. Configure the Async Log Handler
Add the Async Log Handler Identifier Information
Thenameproperty sets the unique identifier for this log handler.<async-handler name="Async_NFS_handlers">
<async-handler name="Async_NFS_handlers">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
levelPropertyThelevelproperty sets the maximum level of log message that the root logger records.<async-handler name="Async_NFS_handlers"> <level name="INFO"/>
<async-handler name="Async_NFS_handlers"> <level name="INFO"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
queue-lengthThequeue-lengthdefines the maximum number of log messages that will be held by this handler while waiting for sub-handlers to respond.<async-handler name="Async_NFS_handlers"> <level name="INFO"/> <queue-length value="512"/>
<async-handler name="Async_NFS_handlers"> <level name="INFO"/> <queue-length value="512"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Overflow Response
Theoverflow-actiondefines how this handler responds when its queue length is exceeded. This can be set toBLOCKorDISCARD.BLOCKmakes the logging application wait until there is available space in the queue. This is the same behavior as an non-async log handler.DISCARDallows the logging application to continue but the log message is deleted.<async-handler name="Async_NFS_handlers"> <level name="INFO"/> <queue-length value="512"/> <overflow-action value="block"/>
<async-handler name="Async_NFS_handlers"> <level name="INFO"/> <queue-length value="512"/> <overflow-action value="block"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow List
subhandlersThesubhandlerslist is the list of log handlers to which this async handler passes its log messages.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Part IV. Set Up Cache Modes Copy linkLink copied to clipboard!
Chapter 6. Cache Modes Copy linkLink copied to clipboard!
- Local mode is the only non-clustered cache mode offered in JBoss Data Grid. In local mode, JBoss Data Grid operates as a simple single-node in-memory data cache. Local mode is most effective when scalability and failover are not required and provides high performance in comparison with clustered modes.
- Clustered mode replicates state changes to a small subset of nodes. The subset size is sufficient for fault tolerance purposes but not large enough to hinder scalability. Before attempting to use clustered mode, it is important to first configure JGroups for a clustered configuration. For details about configuring JGroups, see Section 24.3, “Configure JGroups (Library Mode)”
6.1. About Cache Containers Copy linkLink copied to clipboard!
cache-container element acts as a parent of one or more (local or clustered) caches. To add clustered caches to the container, transport must be defined.
Procedure 6.1. How to Configure the Cache Container
Specify the Cache Container
Thecache-containerelement specifies information about the cache container using the following parameters:<subsystem xmlns="urn:infinispan:server:core:6.0" default-cache-container="default">
<subsystem xmlns="urn:infinispan:server:core:6.0" default-cache-container="default">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Cache Container Name
Thenameparameter defines the name of the cache container.<subsystem xmlns="urn:infinispan:server:core:6.0" default-cache-container="default"> <cache-container name="default" />
<subsystem xmlns="urn:infinispan:server:core:6.0" default-cache-container="default"> <cache-container name="default" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the Default Cache
Thedefault-cacheparameter defines the name of the default cache used with the cache container.<subsystem xmlns="urn:infinispan:server:core:6.0" default-cache-container="default"> <cache-container name="default" default-cache="default" />
<subsystem xmlns="urn:infinispan:server:core:6.0" default-cache-container="default"> <cache-container name="default" default-cache="default" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enable/Disable Statistics
Thestatisticsattribute is optional and istrueby default. Statistics are useful in monitoring JBoss Data Grid via JMX or JBoss Operations Network, however they adversely affect performance. Disable this attribute by setting it tofalseif it is not required.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the Listener Executor
Thelistener-executordefines the executor used for asynchronous cache listener notifications.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Cache Container Start Mode
Thestartparameter indicates when the cache container starts, i.e. whether it will start lazily when requested or "eagerly" when the server starts up. Valid values for this parameter areEAGERandLAZY.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Per-cache Statistics
Ifstatisticsare enabled at the container level, per-cache statistics can be selectively disabled for caches that do not require monitoring by setting thestatisticsattribute tofalse.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
6.2. Local Mode Copy linkLink copied to clipboard!
- Write-through and write-behind caching to persist data.
- Entry eviction to prevent the Java Virtual Machine (JVM) running out of memory.
- Support for entries that expire after a defined period.
ConcurrentMap, resulting in a simple migration process from a map to JBoss Data Grid.
6.2.1. Configure Local Mode (Remote Client-Server Mode) Copy linkLink copied to clipboard!
local-cache element.
Procedure 6.2. The local-cache Element
local-cache element specifies information about the local cache used with the cache container using the following parameters:
Add the Local Cache Name
Thenameparameter specifies the name of the local cache to use.<cache-container name="local" default-cache="default" statistics="true"> <local-cache name="default" ><cache-container name="local" default-cache="default" statistics="true"> <local-cache name="default" >Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Cache Container Start Mode
Thestartparameter indicates when the cache container starts, i.e. whether it will start lazily when requested or "eagerly" when the server starts up. Valid values for this parameter areEAGERandLAZY.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Batching
Thebatchingparameter specifies whether batching is enabled for the local cache.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Per-cache Statistics
Ifstatisticsare enabled at the container level, per-cache statistics can be selectively disabled for caches that do not require monitoring by setting thestatisticsattribute tofalse.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify Indexing Type
Theindexingparameter specifies the type of indexing used for the local cache. Valid values for this parameter areNONE,LOCALandALL.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
DefaultCacheManager with the "no-argument" constructor. Both of these methods create a local default cache.
<transport/> it can only contain local caches. The container used in the example can only contain local caches as it does not have a <transport/>.
ConcurrentMap and is compatible with multiple cache systems.
6.2.2. Configure Local Mode (Library Mode) Copy linkLink copied to clipboard!
mode parameter to local equals not specifying a clustering mode at all. In the case of the latter, the cache defaults to local mode, even if its cache manager defines a transport.
<clustering mode="local" />
<clustering mode="local" />
6.3. Clustered Modes Copy linkLink copied to clipboard!
- Replication Mode replicates any entry that is added across all cache instances in the cluster.
- Invalidation Mode does not share any data, but signals remote caches to initiate the removal of invalid entries.
- Distribution Mode stores each entry on a subset of nodes instead of on all nodes in the cluster.
6.3.1. Asynchronous and Synchronous Operations Copy linkLink copied to clipboard!
6.3.2. Cache Mode Troubleshooting Copy linkLink copied to clipboard!
6.3.2.1. Invalid Data in ReadExternal Copy linkLink copied to clipboard!
readExternal, it can be because when using Cache.putAsync(), starting serialization can cause your object to be modified, causing the datastream passed to readExternal to be corrupted. This can be resolved if access to the object is synchronized.
6.3.2.2. About Asynchronous Communications Copy linkLink copied to clipboard!
local-cache, distributed-cache and replicated-cache elements respectively. Each of these elements contains a mode property, the value of which can be set to SYNC for synchronous or ASYNC for asynchronous communications.
Note
6.3.2.3. Cluster Physical Address Retrieval Copy linkLink copied to clipboard!
The physical address can be retrieved using an instance method call. For example: AdvancedCache.getRpcManager().getTransport().getPhysicalAddresses().
6.4. State Transfer Copy linkLink copied to clipboard!
- In replication mode, the node joining the cluster receives a copy of the data currently on the other nodes in the cache. This occurs when the existing nodes push a part of the current cache state.
- In distribution mode, each node contains a slice of the entire key space, which is determined through consistent hashing. When a new node joins the cluster it receives a slice of the key space that has been taken from each of the existing nodes. State transfer results in the new node receiving a slice of the key space and the existing nodes shedding a portion of the data they were previously responsible for.
6.4.1. Non-Blocking State Transfer Copy linkLink copied to clipboard!
- allows state transfer to occur without a drop in the performance of the cluster. However, if a drop in performance does occur during the state transfer it will not throw an exception, and will allow processes to continue.
- does not add a mechanism for resolving data conflicts after a merge, however it ensures it is feasible to add one in the future.
6.4.2. Suppress State Transfer via JMX Copy linkLink copied to clipboard!
getCache() call will timeout after stateTransfer.timeout expires unless rebalancing is re-enabled or stateTransfer.awaitInitialTransferis set to false.
6.4.3. The rebalancingEnabled Attribute Copy linkLink copied to clipboard!
rebalancingEnabled JMX attribute, and requires no specific configuration.
rebalancingEnabled attribute can be modified for the entire cluster from the LocalTopologyManager JMX Mbean on any node. This attribute is true by default, and is configurable programmatically.
<await-initial-transfer="false"/>
<await-initial-transfer="false"/>
Chapter 7. Set Up Distribution Mode Copy linkLink copied to clipboard!
7.1. About Distribution Mode Copy linkLink copied to clipboard!
7.2. Distribution Mode's Consistent Hash Algorithm Copy linkLink copied to clipboard!
7.3. Locating Entries in Distribution Mode Copy linkLink copied to clipboard!
PUT operation can result in as many remote calls as specified by the num_copies parameter, while a GET operation executed on any node in the cluster results in a single remote call. In the background, the GET operation results in the same number of remote calls as a PUT operation (specifically the value of the num_copies parameter), but these occur in parallel and the returned entry is passed to the caller as soon as one returns.
7.4. Return Values in Distribution Mode Copy linkLink copied to clipboard!
7.5. Configure Distribution Mode (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Procedure 7.1. The distributed-cache Element
distributed-cache element configures settings for the distributed cache using the following parameters:
Add the Cache Name
Thenameparameter provides a unique identifier for the cache.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Clustered Cache Start Mode
Themodeparameter sets the clustered cache mode. Valid values areSYNC(synchronous) andASYNC(asynchronous).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify Number of Segments
The (optional)segmentsparameter specifies the number of hash space segments per cluster. The recommended value for this parameter is ten multiplied by the cluster size and the default value is80.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Cache Start Mode
Thestartparameter specifies whether the cache starts when the server starts up or when it is requested or deployed.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Per-cache Statistics
Ifstatisticsare enabled at the container level, per-cache statistics can be selectively disabled for caches that do not require monitoring by setting thestatisticsattribute tofalse.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Important
cache-container, locking, and transaction elements, see the appropriate chapter.
7.6. Configure Distribution Mode (Library Mode) Copy linkLink copied to clipboard!
Procedure 7.2. Distributed Cache Configuration
Set the Clustered Mode
Theclusteringelement'smodeparameter's value determines the clustering mode selected for the cache.<clustering mode="dist">
<clustering mode="dist">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the Remote Call Timeout
Thesyncelement'sreplTimeoutparameter specifies the maximum time period in milliseconds for an acknowledgment after a remote call. If the time period ends without any acknowledgment, an exception is thrown.<clustering mode="dist"> <sync replTimeout="${TIME}" /><clustering mode="dist"> <sync replTimeout="${TIME}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define State Transfer Settings
ThestateTransferelement specifies how state is transferred when a node leaves or joins the cluster. It uses the following parameters:Specify State Transfer Batch Size
ThechunkSizeparameter specifies the size of cache entry state batches to be transferred. If this value is greater than0, the value set is the size of chunks sent. If the value is less than0, all states are transferred at the same time.<clustering mode="dist"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" /><clustering mode="dist"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set
fetchInMemoryStateParameterThefetchInMemoryStateparameter when set totrue, requests state information from neighboring caches on start up. This impacts the start up time for the cache.<clustering mode="dist"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" fetchInMemoryState="{true/false}" /><clustering mode="dist"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" fetchInMemoryState="{true/false}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
awaitInitialTransferParameterTheawaitInitialTransferparameter causes the first call to methodCacheManager.getCache()on the joiner node to block and wait until the joining is complete and the cache has finished receiving state from neighboring caches (iffetchInMemoryStateis enabled). This option applies to distributed and replicated caches only and is enabled by default.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set
timeoutValueThetimeoutparameter specifies the maximum time (in milliseconds) the cache waits for responses from neighboring caches with the requested states. If no response is received within the thetimeoutperiod, the start up process aborts and an exception is thrown.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Specify Transport Configuration
Thetransportelement defines the transport configuration for the cache as follows:Specify the Cluster Name
TheclusterNameparameter specifies the name of the cluster. Nodes can only connect to clusters that share the same name.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
distributedSyncTimeoutValueThedistributedSyncTimeoutparameter specifies the time to wait to acquire a lock on the distributed lock. This distributed lock ensures that a single cache can transfer state or rehash state at a time.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Network Transport
ThetransportClassparameter specifies a class that represents a network transport for the cache.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.7. Synchronous and Asynchronous Distribution Copy linkLink copied to clipboard!
Example 7.1. Communication Mode example
A, B and C, and a key K that maps cache A to B. Perform an operation on cluster C that requires a return value, for example Cache.remove(K). To execute successfully, the operation must first synchronously forward the call to both cache A and B, and then wait for a result returned from either cache A or B. If asynchronous communication was used, the usefulness of the returned values cannot be guaranteed, despite the operation behaving as expected.
7.8. GET and PUT Usage in Distribution Mode Copy linkLink copied to clipboard!
GET command before a write command. This occurs because certain methods (for example, Cache.put()) return the previous value associated with the specified key according to the java.util.Map contract. When this is performed on an instance that does not own the key and the entry is not found in the L1 cache, the only reliable way to elicit this return value is to perform a remote GET before the PUT.
GET operation that occurs before the PUT operation is always synchronous, whether the cache is synchronous or asynchronous, because Red Hat JBoss Data Grid must wait for the return value.
7.8.1. Distributed GET and PUT Operation Resource Usage Copy linkLink copied to clipboard!
GET operation before executing the desired PUT operation.
GET operation does not wait for all responses, which would result in wasted resources. The GET process accepts the first valid response received, which allows its performance to be unrelated to cluster size.
Flag.SKIP_REMOTE_LOOKUP flag for a per-invocation setting if return values are not required for your implementation.
java.util.Map interface contract. The contract breaks because unreliable and inaccurate return values are provided to certain methods. As a result, ensure that these return values are not used for any important purpose on your configuration.
Chapter 8. Set Up Replication Mode Copy linkLink copied to clipboard!
8.1. About Replication Mode Copy linkLink copied to clipboard!
8.2. Optimized Replication Mode Usage Copy linkLink copied to clipboard!
8.3. Configure Replication Mode (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Procedure 8.1. The replicated-cache Element
replicated-cache element configures settings for the distributed cache using the following parameters:
Add the Cache Name
Thenameparameter provides a unique identifier for the cache.<cache-container name="local" default-cache="default" statistics="true"> <replicated-cache name="default">
<cache-container name="local" default-cache="default" statistics="true"> <replicated-cache name="default">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Clustered Cache Start Mode
Themodeparameter sets the clustered cache mode. Valid values areSYNC(synchronous) andASYNC(asynchronous).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Cache Start Mode
Thestartparameter specifies whether the cache starts when the server starts up or when it is requested or deployed.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Per-cache Statistics
Ifstatisticsare enabled at the container level, per-cache statistics can be selectively disabled for caches that do not require monitoring by setting thestatisticsattribute tofalse.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Transactions
Thetransactionelement sets up the transaction mode for the replicated cache.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Important
cache-container, locking, and transaction elements, see the appropriate chapter.
8.4. Configure Replication Mode (Library Mode) Copy linkLink copied to clipboard!
Procedure 8.2. Replication Mode Configuration
Set the Clustered Mode
Theclusteringelement'smodeparameter's value determines the clustering mode selected for the cache.<clustering mode="repl">
<clustering mode="repl">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the Remote Call Timeout
Thesyncelement'sreplTimeoutparameter specifies the maximum time period in milliseconds for an acknowledgment after a remote call. If the time period ends without any acknowledgment, an exception is thrown.<clustering mode="repl"> <sync replTimeout="${TIME}" /><clustering mode="repl"> <sync replTimeout="${TIME}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define State Transfer Settings
ThestateTransferelement specifies how state is transferred when a node leaves or joins the cluster. It uses the following parameters:Specify State Transfer Batch Size
ThechunkSizeparameter specifies the size of cache entry state batches to be transferred. If this value is greater than0, the value set is the size of chunks sent. If the value is less than0, all states are transferred at the same time.<clustering mode="repl"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" /><clustering mode="repl"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set
fetchInMemoryStateParameterThefetchInMemoryStateparameter when set totrue, requests state information from neighboring caches on start up. This impacts the start up time for the cache.<clustering mode="repl"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" fetchInMemoryState="{true/false}" /><clustering mode="repl"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" fetchInMemoryState="{true/false}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
awaitInitialTransferParameterTheawaitInitialTransferparameter causes the first call to methodCacheManager.getCache()on the joiner node to block and wait until the joining is complete and the cache has finished receiving state from neighboring caches (iffetchInMemoryStateis enabled). This option applies to distributed and replicated caches only and is enabled by default.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
timeoutValueThetimeoutparameter specifies the maximum time (in milliseconds) the cache waits for responses from neighboring caches with the requested states. If no response is received within the thetimeoutperiod, the start up process aborts and an exception is thrown.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Specify Transport Configuration
Thetransportelement defines the transport configuration for the cache as follows:Specify the Cluster Name
TheclusterNameparameter specifies the name of the cluster. Nodes can only connect to clusters that share the same name.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
distributedSyncTimeoutValueThedistributedSyncTimeoutparameter specifies the time to wait to acquire a lock on the distributed lock. This distributed lock ensures that a single cache can transfer state or rehash state at a time.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Network Transport
ThetransportClassparameter specifies a class that represents a network transport for the cache.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
8.5. Synchronous and Asynchronous Replication Copy linkLink copied to clipboard!
- Synchronous replication blocks a thread or caller (for example on a
put()operation) until the modifications are replicated across all nodes in the cluster. By waiting for acknowledgments, synchronous replication ensures that all replications are successfully applied before the operation is concluded. - Asynchronous replication operates significantly faster than synchronous replication because it does not need to wait for responses from nodes. Asynchronous replication performs the replication in the background and the call returns immediately. Errors that occur during asynchronous replication are written to a log. As a result, a transaction can be successfully completed despite the fact that replication of the transaction may not have succeeded on all the cache instances in the cluster.
8.5.1. Troubleshooting Asynchronous Replication Behavior Copy linkLink copied to clipboard!
- Disable state transfer and use a
ClusteredCacheLoaderto lazily look up remote state as and when needed. - Enable state transfer and
REPL_SYNC. Use the Asynchronous API (for example, thecache.putAsync(k, v)) to activate 'fire-and-forget' capabilities. - Enable state transfer and
REPL_ASYNC. All RPCs end up becoming synchronous, but client threads will not be held up if a replication queue is enabled (which is recommended for asynchronous mode).
8.6. The Replication Queue Copy linkLink copied to clipboard!
- Previously set intervals.
- The queue size exceeding the number of elements.
- A combination of previously set intervals and the queue size exceeding the number of elements.
8.6.1. Replication Queue Usage Copy linkLink copied to clipboard!
- Disable asynchronous marshalling; or
- Set the
max-threadscount value to1for thetransport executor. Thetransport executoris defined instandalone.xmlas follows:<transport executor="infinispan-transport"/>
<transport executor="infinispan-transport"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
queue-flush-interval, value is in milliseconds) and queue size (queue-size) as follows:
8.7. About Replication Guarantees Copy linkLink copied to clipboard!
8.8. Replication Traffic on Internal Networks Copy linkLink copied to clipboard!
IP addresses than for traffic over public IP addresses, or do not charge at all for internal network traffic (for example, GoGrid). To take advantage of lower rates, you can configure Red Hat JBoss Data Grid to transfer replication traffic using the internal network. With such a configuration, it is difficult to know the internal IP address you are assigned. JBoss Data Grid uses JGroups interfaces to solve this problem.
Chapter 9. Set Up Invalidation Mode Copy linkLink copied to clipboard!
9.1. About Invalidation Mode Copy linkLink copied to clipboard!
9.2. Configure Invalidation Mode (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Procedure 9.1. The invalidation-cache Element
invalidation-cache element configures settings for the distributed cache using the following parameters:
Add the Cache Name
Thenameparameter provides a unique identifier for the cache.<cache-container name="local" default-cache="default" statistics="true"> <invalidation-cache name="default"><cache-container name="local" default-cache="default" statistics="true"> <invalidation-cache name="default">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Clustered Cache Start Mode
Themodeparameter sets the clustered cache mode. Valid values areSYNC(synchronous) andASYNC(asynchronous).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Cache Start Mode
Thestartparameter specifies whether the cache starts when the server starts up or when it is requested or deployed.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Per-cache Statistics
Ifstatisticsare enabled at the container level, per-cache statistics can be selectively disabled for caches that do not require monitoring by setting thestatisticsattribute tofalse.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Important
cache-container, locking, and transaction elements, see the appropriate chapter.
9.3. Configure Invalidation Mode (Library Mode) Copy linkLink copied to clipboard!
Procedure 9.2. Invalidation Mode Configuration
Set the Clustered Mode
Theclusteringelement'smodeparameter's value determines the clustering mode selected for the cache.<clustering mode="inv">
<clustering mode="inv">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the Remote Call Timeout
Thesyncelement'sreplTimeoutparameter specifies the maximum time period in milliseconds for an acknowledgment after a remote call. If the time period ends without any acknowledgment, an exception is thrown.<clustering mode="inv"> <sync replTimeout="${TIME}" /><clustering mode="inv"> <sync replTimeout="${TIME}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define State Transfer Settings
ThestateTransferelement specifies how state is transferred when a node leaves or joins the cluster. It uses the following parameters:Specify State Transfer Batch Size
ThechunkSizeparameter specifies the size of cache entry state batches to be transferred. If this value is greater than0, the value set is the size of chunks sent. If the value is less than0, all states are transferred at the same time.<clustering mode="inv"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" /><clustering mode="inv"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set
fetchInMemoryStateParameterThefetchInMemoryStateparameter when set totrue, requests state information from neighboring caches on start up. This impacts the start up time for the cache.<clustering mode="inv"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" fetchInMemoryState="{true/false}" /><clustering mode="inv"> <sync replTimeout="${TIME}" /> <stateTransfer chunkSize="${SIZE}" fetchInMemoryState="{true/false}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define the
awaitInitialTransferParameterTheawaitInitialTransferparameter causes the first call to methodCacheManager.getCache()on the joiner node to block and wait until the joining is complete and the cache has finished receiving state from neighboring caches (iffetchInMemoryStateis enabled). This option applies to distributed and replicated caches only and is enabled by default.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set
timeoutValueThetimeoutparameter specifies the maximum time (in milliseconds) the cache waits for responses from neighboring caches with the requested states. If no response is received within the thetimeoutperiod, the start up process aborts and an exception is thrown.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Specify Transport Configuration
Thetransportelement defines the transport configuration for the cache as follows:Specify the Cluster Name
TheclusterNameparameter specifies the name of the cluster. Nodes can only connect to clusters that share the same name.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
distributedSyncTimeoutValueThedistributedSyncTimeoutparameter specifies the time to wait to acquire a lock on the distributed lock. This distributed lock ensures that a single cache can transfer state or rehash state at a time.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Network Transport
ThetransportClassparameter specifies a class that represents a network transport for the cache.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9.4. Synchronous/Asynchronous Invalidation Copy linkLink copied to clipboard!
- Synchronous invalidation blocks the thread until all caches in the cluster have received invalidation messages and evicted the obsolete data.
- Asynchronous invalidation operates in a fire-and-forget mode that allows invalidation messages to be broadcast without blocking a thread to wait for responses.
9.5. The L1 Cache and Invalidation Copy linkLink copied to clipboard!
Part V. Set Up Locking for the Cache Copy linkLink copied to clipboard!
Chapter 10. Locking Copy linkLink copied to clipboard!
10.1. Configure Locking (Remote Client-Server Mode) Copy linkLink copied to clipboard!
locking element within the cache tags (for example, invalidation-cache, distributed-cache, replicated-cache or local-cache).
Procedure 10.1. Configure Locking (Remote Client-Server Mode)
Define the Isolation Level
Theisolationparameter defines the isolation level used for the local cache. Valid values for this parameter areREPEATABLE_READandREAD_COMMITTED.<distributed-cache> <locking isolation="REPEATABLE_READ" />
<distributed-cache> <locking isolation="REPEATABLE_READ" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
acquire-timeoutParameterTheacquire-timeoutparameter specifies the number of milliseconds after which lock acquisition will time out.<distributed-cache> <locking isolation="REPEATABLE_READ" acquire-timeout="30000" />
<distributed-cache> <locking isolation="REPEATABLE_READ" acquire-timeout="30000" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Number of Lock Stripes
Theconcurrency-levelparameter defines the number of lock stripes used by the LockManager.<distributed-cache> <locking isolation="REPEATABLE_READ" acquire-timeout="30000" concurrency-level="1000" />
<distributed-cache> <locking isolation="REPEATABLE_READ" acquire-timeout="30000" concurrency-level="1000" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Lock Striping
Thestripingparameter specifies whether lock striping will be used for the local cache.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.2. Configure Locking (Library Mode) Copy linkLink copied to clipboard!
locking element and its parameters are set within the optional configuration element on a per cache basis. For example, for the default cache, the configuration element occurs within the default element and for each named cache, it occurs within the namedCache element. The following is an example of this configuration:
Procedure 10.2. Configure Locking (Library Mode)
Set the Concurrency Level
TheconcurrencyLevelparameter specifies the concurrency level for the lock container. Set this value according to the number of concurrent threads interacting with the data grid.<infinispan> ... <default> <locking concurrencyLevel="${VALUE}" /><infinispan> ... <default> <locking concurrencyLevel="${VALUE}" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the Cache Isolation Level
TheisolationLevelparameter specifies the cache's isolation level. Valid isolation levels areREAD_COMMITTEDandREPEATABLE_READ. For details about isolation levels, see Section 12.1, “About Isolation Levels”Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Lock Acquisition Timeout
ThelockAcquisitionTimeoutparameter specifies time (in milliseconds) after which a lock acquisition attempt times out.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Lock Striping
TheuseLockStripingparameter specifies whether a pool of shared locks are maintained for all entries that require locks. If set toFALSE, locks are created for each entry in the cache. For details, see Section 11.1, “About Lock Striping”Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set
writeSkewCheckParameterThewriteSkewCheckparameter is only valid if theisolationLevelis set toREPEATABLE_READ. If this parameter is set toFALSE, a disparity between a working entry and the underlying entry at write time results in the working entry overwriting the underlying entry. If the parameter is set toTRUE, such conflicts (namely write skews) throw an exception.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.3. Locking Types Copy linkLink copied to clipboard!
10.3.1. About Optimistic Locking Copy linkLink copied to clipboard!
writeSkewCheck enabled, transactions in optimistic locking mode roll back if one or more conflicting modifications are made to the data before the transaction completes.
10.3.2. About Pessimistic Locking Copy linkLink copied to clipboard!
10.3.3. Pessimistic Locking Types Copy linkLink copied to clipboard!
- Explicit Pessimistic Locking, which uses the JBoss Data Grid Lock API to allow cache users to explicitly lock cache keys for the duration of a transaction. The Lock call attempts to obtain locks on specified cache keys across all nodes in a cluster. This attempt either fails or succeeds for all specified cache keys. All locks are released during the commit or rollback phase.
- Implicit Pessimistic Locking ensures that cache keys are locked in the background as they are accessed for modification operations. Using Implicit Pessimistic Locking causes JBoss Data Grid to check and ensure that cache keys are locked locally for each modification operation. Discovering unlocked cache keys causes JBoss Data Grid to request a cluster-wide lock to acquire a lock on the unlocked cache key.
10.3.4. Explicit Pessimistic Locking Example Copy linkLink copied to clipboard!
Procedure 10.3. Transaction with Explicit Pessimistic Locking
- When the line
cache.lock(K)executes, a cluster-wide lock is acquired onK.tx.begin() cache.lock(K)
tx.begin() cache.lock(K)Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the line
cache.put(K,V5)executes, it guarantees success.tx.begin() cache.lock(K) cache.put(K,V5)
tx.begin() cache.lock(K) cache.put(K,V5)Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the line
tx.commit()executes, the locks held for this process are released.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.3.5. Implicit Pessimistic Locking Example Copy linkLink copied to clipboard!
Procedure 10.4. Transaction with Implicit Pessimistic locking
- When the line
cache.put(K,V)executes, a cluster-wide lock is acquired onK.tx.begin() cache.put(K,V)
tx.begin() cache.put(K,V)Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the line
cache.put(K2,V2)executes, a cluster-wide lock is acquired onK2.tx.begin() cache.put(K,V) cache.put(K2,V2)
tx.begin() cache.put(K,V) cache.put(K2,V2)Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the line
cache.put(K,V5)executes, the lock acquisition is non operational because a cluster-wide lock forKhas been previously acquired. Theputoperation will still occur.tx.begin() cache.put(K,V) cache.put(K2,V2) cache.put(K,V5)
tx.begin() cache.put(K,V) cache.put(K2,V2) cache.put(K,V5)Copy to Clipboard Copied! Toggle word wrap Toggle overflow - When the line
tx.commit()executes, all locks held for this transaction are released.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
10.3.6. Configure Locking Mode (Remote Client-Server Mode) Copy linkLink copied to clipboard!
locking parameter within the transaction element as follows:
<transaction locking="OPTIMISTIC/PESSIMISTIC" />
<transaction locking="OPTIMISTIC/PESSIMISTIC" />
10.3.7. Configure Locking Mode (Library Mode) Copy linkLink copied to clipboard!
transaction element as follows:
lockingMode value to OPTIMISTIC or PESSIMISTIC to configure the locking mode used for the transactional cache.
10.4. Locking Operations Copy linkLink copied to clipboard!
10.4.1. About the LockManager Copy linkLink copied to clipboard!
LockManager component is responsible for locking an entry before a write process initiates. The LockManager uses a LockContainer to locate, hold and create locks. The two types of LockContainers generally used in such implementations are available. The first type offers support for lock striping while the second type supports one lock per entry.
See Also:
10.4.2. About Lock Acquisition Copy linkLink copied to clipboard!
10.4.3. About Concurrency Levels Copy linkLink copied to clipboard!
ConcurrentHashMap based collections, such as those internal to DataContainers.
Chapter 11. Set Up Lock Striping Copy linkLink copied to clipboard!
11.1. About Lock Striping Copy linkLink copied to clipboard!
11.2. Configure Lock Striping (Remote Client-Server Mode) Copy linkLink copied to clipboard!
striping element to true.
<locking isolation="REPEATABLE_READ" acquire-timeout="20000" concurrency-level="500" striping="true" />
<locking isolation="REPEATABLE_READ"
acquire-timeout="20000"
concurrency-level="500"
striping="true" />
11.3. Configure Lock Striping (Library Mode) Copy linkLink copied to clipboard!
useLockStriping parameter as follows:
useLockStriping parameter specifies whether a pool of shared locks are maintained for all entries that require locks. If set to FALSE, locks are created for each entry in the cache. If set to TRUE, lock striping is enabled and shared locks are used as required from the pool.
concurrencyLevel is used to specify the size of the shared lock collection use when lock striping is enabled.
isolationLevel parameter specifies the cache's isolation level. Valid isolation levels are READ_COMMITTED and REPEATABLE_READ.
lockAcquisitionTimeout parameter specifies time (in milliseconds) after which a lock acquisition attempt times out.
writeSkewCheck check determines if a modification to the entry from a different transaction should roll back the transaction. Write skew set to true requires isolation_level set to REPEATABLE_READ. The default value for writeSkewCheck and isolation_level are FALSE and READ_COMMITTED respectively.
Chapter 12. Set Up Isolation Levels Copy linkLink copied to clipboard!
12.1. About Isolation Levels Copy linkLink copied to clipboard!
READ_COMMITTED and REPEATABLE_READ are the two isolation modes offered in Red Hat JBoss Data Grid.
READ_COMMITTED. This is the default isolation level because it is applicable to a wide variety of requirements.REPEATABLE_READ. This can be configured using thelockingconfiguration element.
- See Section 11.2, “Configure Lock Striping (Remote Client-Server Mode)” for a Remote Client-Server mode configuration sample.
- See Section 11.3, “Configure Lock Striping (Library Mode)” for a Library mode configuration sample.
12.2. About READ_COMMITTED Copy linkLink copied to clipboard!
READ_COMMITTED is one of two isolation modes available in Red Hat JBoss Data Grid.
READ_COMMITTED mode, write operations are made to copies of data rather than the data itself. A write operation blocks other data from being written, however writes do not block read operations. As a result, both READ_COMMITTED and REPEATABLE_READ modes permit read operations at any time, regardless of when write operations occur.
READ_COMMITTED mode multiple reads of the same key within a transaction can return different results due to write operations modifying data between reads. This phenomenon is known as non-repeatable reads and is avoided in REPEATABLE_READ mode.
12.3. About REPEATABLE_READ Copy linkLink copied to clipboard!
REPEATABLE_READ is one of two isolation modes available in Red Hat JBoss Data Grid.
REPEATABLE_READ does not allow write operations while read operations are in progress, nor does it allow read operations when write operations occur. This prevents the "non-repeatable read" phenomenon, which occurs when a single transaction has two read operations on the same row but the retrieved values differ (possibly due to a write operating modifying the value between the two read operations).
REPEATABLE_READ isolation mode preserves the value of a row before a modification occurs. As a result, the "non-repeatable read" phenomenon is avoided because a second read operation on the same row retrieves the preserved value rather than the new modified value. As a result, the two values retrieved by the two read operations will always match, even if a write operation occurs between the two reads.
Part VI. Set Up and Configure a Cache Store Copy linkLink copied to clipboard!
Chapter 13. Cache Stores Copy linkLink copied to clipboard!
- fetch data from the data store when a copy is not in the cache.
- push modifications made to the data in cache back to the data store.
13.1. File System Based Cache Stores Copy linkLink copied to clipboard!
SingleFileCacheStore.
SingleFileCacheStore is a simple, file system based implementation and a replacement to the older file system based cache store: the FileCacheStore.
SingleFileCacheStore stores all key/value pairs and their corresponding metadata information in a single file. To speed up data location, it also keeps all keys and the positions of their values and metadata in memory. Hence, using the single file cache store slightly increases the memory required, depending on the key size and the amount of keys stored. Hence SingleFileCacheStore is not recommended for use cases where the keys are too big.
SingleFileCacheStore can be used in a limited capacity in production environments. It can not be used on shared file system (such as NFS and Windows shares) due to a lack of proper file locking, resulting in data corruption. Furthermore, file systems are not inherently transactional, resulting in file writing failures during the commit phase if the cache is used in a transactional context.
13.1.1. Single File Store Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Procedure 13.1. Configure the Single File Store
Add the Cache Name
Thenameparameter of thelocal-cacheattribute is used to specify a name for the cache.<local-cache name="default">
<local-cache name="default">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Per-cache Statistics
Ifstatisticsare enabled at the container level, per-cache statistics can be selectively disabled for caches that do not require monitoring by setting thestatisticsattribute tofalse.<local-cache name="default" statistics="true">
<local-cache name="default" statistics="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the
file-storeElementThefile-storeelement specifies configuration information for the single file store.Thenameparameter of thefile-storeelement is used to specify a name for the file store.<local-cache name="default" statistics="true"> <file-store name="myFileStore" /><local-cache name="default" statistics="true"> <file-store name="myFileStore" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the passivation Parameter
Thepassivationparameter determines whether entries in the cache are passivated (true) or if the cache store retains a copy of the contents in memory (false).<local-cache name="default" statistics="true"> <file-store name="myFileStore" passivation="true" /><local-cache name="default" statistics="true"> <file-store name="myFileStore" passivation="true" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
purgeParameterThepurgeparameter specifies whether or not the cache store is purged when it is started. Valid values for this parameter aretrueandfalse.<local-cache name="default" statistics="true"> <file-store name="myFileStore" passivation="true" purge="true" /><local-cache name="default" statistics="true"> <file-store name="myFileStore" passivation="true" purge="true" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
sharedParameterThesharedparameter is used when multiple cache instances share a cache store. This parameter can be set to prevent multiple cache instances writing the same modification multiple times. Valid values for this parameter aretrueandfalse. However, thesharedparameter is not recommended forfile-store.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the Directory Path Within the
relative-toParameterTherelative-toproperty is the directory where thefile-storestores the data. It is used to define a named path.Thepathproperty is the name of the file where the data is stored. It is a relative path name that is appended to the value of therelative-toproperty to determine the complete path.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the maximum number of entries
ThemaxEntriesparameter provides maximum number of entries allowed. The default value is -1 for unlimited entries.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the fetch-state Parameter
Thefetch-stateparameter when set to true fetches the persistent state when joining a cluster. If multiple cache stores are chained, only one of them can have this property enabled. Persistent state transfer with a shared cache store does not make sense, as the same persistent store that provides the data will just end up receiving it. Therefore, if a shared cache store is used, the cache does not allow a persistent state transfer even if a cache store has this property set to true. It is recommended to set this property to true only in a clustered environment. The default value for this parameter is false.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the preload Parameter
Thepreloadparameter when set to true, loads the data stored in the cache store into memory when the cache starts. However, setting this parameter to true affects the performance as the startup time is increased. The default value for this parameter is false.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the singleton Parameter
Thesingletonparameter enables a singleton store cache store. SingletonStore is a delegating cache store used when only one instance in a cluster can interact with the underlying store. However,singletonparameter is not recommended forfile-store.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.1.2. Single File Store Configuration (Library Mode) Copy linkLink copied to clipboard!
Procedure 13.2. Configuring the Single File Store in Library Mode
infinispan.xml.
- Add the name value to the
namedCacheelement. The following is an example of this step:<namedCache name="writeThroughToFile">
<namedCache name="writeThroughToFile">Copy to Clipboard Copied! Toggle word wrap Toggle overflow - In the
persistenceelement, set thepassivationparameter tofalse. Possible values are true and false.<namedCache name="writeThroughToFile"> <persistence passivation="false" /><namedCache name="writeThroughToFile"> <persistence passivation="false" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Set up a single file configuration using the
singleFileelement:fetchPersistentState- If set totrue, the persistent state is fetched when joining a cluster. If multiple cache stores are chained, only one cache store can have this property set totrue. The default for this value isfalse.- The
ignoreModificationsparameter determines whether operations that modify the cache (e.g. put, remove, clear, store, etc.) do not affect the cache store. As a result, the cache store can become out of sync with the cache. - The
purgeOnStartupparameter specifies whether the cache store is purged when initially started. - The
sharedparameter is set totruewhen multiple cache instances share a cache store, which prevents multiple cache instances writing the same modification individually. The default for this attribute isfalse. However, thesharedparameter is not recommended forfile-store. - The
preloadparameter sets whether the cache store data is pre-loaded into memory and becomes immediately accessible after starting up. The disadvantage of setting this to true is that the start up time increases. The default value for this attribute isfalse. - The
locationparameter points to the location of file store. - The
maxEntriesparameter provides maximum number of entries allowed. The default value is -1 for unlimited entries. - The
maxKeysInMemoryparameter is used to speed up data lookup. The single file store keeps an index of keys and their positions in the file using themaxKeysInMemoryparameter. The default value for this parameter is -1.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the
asyncelement to configure the asynchronous settings:- The
enabledparameter determines whether the file store is asynchronous. - The
threadPoolSizeparameter specifies the number of threads that concurrently apply modifications to the store. The default value for this parameter is5. - The
flushLockTimeoutparameter specifies the time to acquire the lock which guards the state to be flushed to the cache store periodically. The default value for this parameter is1. - The
modificationQueueSizeparameter specifies the size of the modification queue for the asynchronous store. If updates are made at a rate that is faster than the underlying cache store can process this queue, then the asynchronous store behaves like a synchronous store for that period, blocking until the queue can accept more elements. The default value for this parameter is1024elements. - The
shutdownTimeoutparameter specifies the time to stop the cache store. Default value for this parameter is25seconds.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.1.3. Migrating data from FileCacheStore to SingleFileCacheStore Copy linkLink copied to clipboard!
13.2. Remote Cache Stores Copy linkLink copied to clipboard!
RemoteCacheStore is an implementation of the cache loader that stores data in a remote Red Hat JBoss Data Grid cluster. The RemoteCacheStore uses the Hot Rod client-server architecture to communicate with the remote cluster.
RemoteCacheStore and the cluster.
13.2.1. Remote Cache Store Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Procedure 13.3. Configure the Remote Cache Store
remote-store element define the following information:
- The
cacheparameter defines the name for the remote cache. If left undefined, the default cache is used instead.<remote-store cache="default">
<remote-store cache="default">Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
socket-timeoutparameter sets whether the value defined inSO_TIMEOUT(in milliseconds) applies to remote Hot Rod servers on the specified timeout. A timeout value of0indicates an infinite timeout.<remote-store cache="default" socket-timeout="60000"><remote-store cache="default" socket-timeout="60000">Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
tcp-no-delaysets whetherTCP_NODELAYapplies on socket connections to remote Hot Rod servers.<remote-store cache="default" socket-timeout="60000" tcp-no-delay="true"><remote-store cache="default" socket-timeout="60000" tcp-no-delay="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
hotrod-wrappingsets whether a wrapper is required for Hot Rod on the remote store.<remote-store cache="default" socket-timeout="60000" tcp-no-delay="true" hotrod-wrapping="true"><remote-store cache="default" socket-timeout="60000" tcp-no-delay="true" hotrod-wrapping="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The single parameter for the
remote-serverelement is as follows:- The
outbound-socket-bindingparameter sets the outbound socket binding for the remote server.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
13.2.2. Remote Cache Store Configuration (Library Mode) Copy linkLink copied to clipboard!
Procedure 13.4. Remote Cache Store Configuration
Configure the Persistence Element
Create apersistenceelement, with thepassivationset tofalse.<persistence passivation="false" />
<persistence passivation="false" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create a
remoteStoreelement within thepersistenceelement to configure the attributes for the Remote Cache Store.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the
fetchPersistentStateattribute. If set totrue, the persistent state is fetched when the remote cache joins the cluster. If multiple cache stores are chained, only one cache store can have this property set totrue. The default for this value isfalse. - Add the
sharedattribute. This is set totruewhen multiple cache instances share a cache store, which prevents multiple cache instances writing the same modification individually. The default for this attribute isfalse. - Add the
preloadattribute. When set totrue, the cache store data is pre-loaded into memory and becomes immediately accessible after starting up. The disadvantage of setting this totrueis that the start up time increases. The default value for this attribute isfalse. - Add the
ignoreModificationsattribute. When set to true, this attribute prevents cache modification operations such as put, remove, clear, store, etc. from affecting the cache store. As a result, the cache store can become out of sync with the cache. The default value for this attribute isfalse. - Add the
purgeOnStartupattribute. If set totrue, the cache store is purged during the start up process. The default value for this attribute isfalse. - Add the
tcpNoDelayattribute. If set totrue, this triggers theTCPNODELAYstack. The default value for this attribute istrue. - Add the
pingOnStartupattribute. If set totrue, a ping request is sent to a back end server to fetch the cluster topology. The default value for this attribute istrue. - Add the
keySizeEstimateattribute. This value is the class name of the driver user to connect to the database. The default value for this attribute is64. - Add the
valueSizeEstimateattribute. This value is the size of the byte buffers when serializing and deserializing values. The default value for this attribute is512. - Add the
forceReturnValuesattribute. This attribute sets whetherFORCE_RETURN_VALUEis enabled for all calls. The default value for this attribute isfalse.
- Create a
serverselement within theremoteStoreelement to set up the server information. Add aserverelement within the generalserverselement to add the information for a single server.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the
hostattribute to configure the host address. - Add the
portattribute to configure the port used by the Remote Cache Store.
- Create a
connectionPoolelement to theremoteStoreelement.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add a
maxActiveattribute. This indicates the maximum number of active connections for each server at a time. The default value for this attribute is-1which indicates an infinite number of active connections. - Add a
maxIdleattribute. This indicates the maximum number of idle connections for each server at a time. The default value for this attribute is-1which indicates an infinite number of idle connections. - Add a
maxTotalattribute. This indicates the maximum number of persistent connections within the combined set of servers. The default setting for this attribute is-1which indicates an infinite number of connections.
13.2.3. Define the Outbound Socket for the Remote Cache Store Copy linkLink copied to clipboard!
outbound-socket-binding element in a standalone.xml file.
standalone.xml file is as follows:
13.3. Custom Cache Stores Copy linkLink copied to clipboard!
Important
13.3.1. Custom Cache Store Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Important
org.jboss.as.clustering.infinispan module dependencies.
Important
13.3.2. Custom Cache Store Configuration (Library Mode) Copy linkLink copied to clipboard!
Important
13.4. About Asynchronous Cache Store Modifications Copy linkLink copied to clipboard!
13.5. LevelDB Cache Store Copy linkLink copied to clipboard!
13.5.1. Configuring LevelDB Cache Store Copy linkLink copied to clipboard!
Procedure 13.5. To configure LevelDB Cache Store:
- Obtain the
leveldbjni-all-1.7.jarfile from https://github.com/fusesource/leveldbjni and copy it to themodules/system/layers/base/org/fusesource/leveldbjni-all/maindirectory. - Modify the
module.xmlfile to include JAR files in the resources:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the following to a cache definition in
standalone.xmlto configure the database:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
leveldbjni-all-1.7.jar from https://github.com/fusesource/leveldbjni to your JBoss Data Grid deployment.
13.5.2. LevelDB Cache Store Programmatic Configuration Copy linkLink copied to clipboard!
Procedure 13.6. LevelDB Cache Store programmatic configuration
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.Configuration cacheConfig = new ConfigurationBuilder().persistence()
Configuration cacheConfig = new ConfigurationBuilder().persistence()Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the LevelDBStoreConfigurationBuilder Store
Add the store to theLevelDBCacheStoreConfigurationBuilderinstance to build its configuration.Configuration cacheConfig = new ConfigurationBuilder().persistence() .addStore(LevelDBStoreConfigurationBuilder.class)Configuration cacheConfig = new ConfigurationBuilder().persistence() .addStore(LevelDBStoreConfigurationBuilder.class)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Location
Set the LevelDB Cache Store location path. The specified path stores the primary cache store data. The directory is automatically created if it does not exist.Configuration cacheConfig = new ConfigurationBuilder().persistence() .addStore(LevelDBStoreConfigurationBuilder.class) .location("/tmp/leveldb/data")Configuration cacheConfig = new ConfigurationBuilder().persistence() .addStore(LevelDBStoreConfigurationBuilder.class) .location("/tmp/leveldb/data")Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Expired Location
Specify the location for expired data using theexpiredLocationparameter for the LevelDB Store. The specified path stores expired data before it is purged. The directory is automatically created if it does not exist.Configuration cacheConfig = new ConfigurationBuilder().persistence() .addStore(LevelDBStoreConfigurationBuilder.class) .location("/tmp/leveldb/data") .expiredLocation("/tmp/leveldb/expired").build();Configuration cacheConfig = new ConfigurationBuilder().persistence() .addStore(LevelDBStoreConfigurationBuilder.class) .location("/tmp/leveldb/data") .expiredLocation("/tmp/leveldb/expired").build();Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
13.5.3. LevelDB Cache Store Sample XML Configuration (Library Mode) Copy linkLink copied to clipboard!
Procedure 13.7. LevelDB Cache Store Sample XML Configuration
Add the namedCache Element
Specify the LevelDB Cache Store's name using thenameparameter in thenamedCacheelement as follows:<namedCache name="vehicleCache">
<namedCache name="vehicleCache">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the persistence Element
Specify the value forpassivationparameter in thepersistenceelement as follows. Possible values are true and false.<namedCache name="vehicleCache"> <persistence passivation="false"><namedCache name="vehicleCache"> <persistence passivation="false">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the leveldbStore Element
Specify the location to store the primary cache store date using thelocationparameter in theleveldbStoreelement as follows. The directory is automatically created if it does not exist. The following is an example of this step:<namedCache name="vehicleCache"> <persistence passivation="false"> <leveldbStore location="/path/to/leveldb/data" /><namedCache name="vehicleCache"> <persistence passivation="false"> <leveldbStore location="/path/to/leveldb/data" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Expired Value
Specify the location for expired data using theexpiredLocationparameter as follows. The directory stores expired data before it is purged. The directory is automatically created if it does not exist.<namedCache name="vehicleCache"> <persistence passivation="false"> <leveldbStore location="/path/to/leveldb/data" expiredLocation="/path/to/expired/data" /><namedCache name="vehicleCache"> <persistence passivation="false"> <leveldbStore location="/path/to/leveldb/data" expiredLocation="/path/to/expired/data" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Shared Parameter
Specify the value forsharedparameter in theleveldbStoreelement as follows. Possible values are true and false.<namedCache name="vehicleCache"> <persistence passivation="false"> <leveldbStore location="/path/to/leveldb/data" expiredLocation="/path/to/expired/data" shared="true" /><namedCache name="vehicleCache"> <persistence passivation="false"> <leveldbStore location="/path/to/leveldb/data" expiredLocation="/path/to/expired/data" shared="true" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Preload Parameter
Specify the value forpreloadparameter in theleveldbStoreelement as follows. Possible values are true and false.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 14. Datasource Management Copy linkLink copied to clipboard!
14.1. About JDBC Copy linkLink copied to clipboard!
14.2. Types of Datasources Copy linkLink copied to clipboard!
datasources and XA datasources.
14.3. Using JDBC Drivers Copy linkLink copied to clipboard!
14.3.1. Install a JDBC Driver as a Core Module Copy linkLink copied to clipboard!
Before performing this task, you need to meet the following prerequisites:
- Download the JDBC driver from your database vendor. JDBC driver download locations are listed here: Section 14.3.2, “JDBC Driver Download Locations”.
- Extract the archive.
Procedure 14.1. Install a JDBC Driver as a Core Module
- Create a file path structure under the
EAP_HOME/modules/directory. For example, for a MySQL JDBC driver, create a directory structure as follows:EAP_HOME/modules/com/mysql/main/. - Copy the JDBC driver JAR into the
main/subdirectory. - In the
main/subdirectory, create amodule.xmlfile. The following is an example of amodule.xmlfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Start the Server.
- Start the Management CLI.
- Run the following CLI command to add the JDBC driver module as a driver:
/subsystem=datasources/jdbc-driver=DRIVER_NAME:add(driver-name=DRIVER_NAME,driver-module-name=MODULE_NAME,driver-xa-datasource-class-name=XA_DATASOURCE_CLASS_NAME)
/subsystem=datasources/jdbc-driver=DRIVER_NAME:add(driver-name=DRIVER_NAME,driver-module-name=MODULE_NAME,driver-xa-datasource-class-name=XA_DATASOURCE_CLASS_NAME)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Example 14.1. Example CLI Command
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)
/subsystem=datasources/jdbc-driver=mysql:add(driver-name=mysql,driver-module-name=com.mysql,driver-xa-datasource-class-name=com.mysql.jdbc.jdbc2.optional.MysqlXADataSource)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
The JDBC driver is now installed and set up as a core module, and is available to be referenced by application datasources.
14.3.2. JDBC Driver Download Locations Copy linkLink copied to clipboard!
| Vendor | Download Location |
|---|---|
| MySQL | |
| PostgreSQL | |
| Oracle | |
| IBM | |
| Sybase | |
| Microsoft |
14.3.3. Access Vendor Specific Classes Copy linkLink copied to clipboard!
This topic covers the steps required to use the JDBC specific classes. This is necessary when an application uses a vendor specific functionality that is not part of the JDBC API.
Warning
Important
Important
Prerequisites
Procedure 14.2. Add a Dependency to the Application
Configure the
MANIFEST.MFfile- Open the application's
META-INF/MANIFEST.MFfile in a text editor. - Add a dependency for the JDBC module and save the file.
Dependencies: MODULE_NAME
Dependencies: MODULE_NAMECopy to Clipboard Copied! Toggle word wrap Toggle overflow Example 14.2. Example Dependency
Dependencies: com.mysql
Dependencies: com.mysqlCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Create a
jboss-deployment-structure.xmlfileCreate a file calledjboss-deployment-structure.xmlin theMETA-INF/orWEB-INFfolder of the application.Example 14.3. Example
jboss-deployment-structure.xmlfileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Example 14.4. Access the Vendor Specific API
14.4. Datasource Configuration Copy linkLink copied to clipboard!
14.4.1. Datasource Parameters Copy linkLink copied to clipboard!
| Parameter | Description |
|---|---|
| jndi-name | The unique JNDI name for the datasource. |
| pool-name | The name of the management pool for the datasource. |
| enabled | Whether or not the datasource is enabled. |
| use-java-context |
Whether to bind the datasource to global JNDI.
|
| spy |
Enable
spy functionality on the JDBC layer. This logs all JDBC traffic to the datasource. Note that the logging category jboss.jdbc.spy must also be set to the log level DEBUG in the logging subsystem.
|
| use-ccm | Enable the cached connection manager. |
| new-connection-sql | A SQL statement which executes when the connection is added to the connection pool. |
| transaction-isolation |
One of the following:
|
| url-delimiter | The delimiter for URLs in a connection-url for High Availability (HA) clustered databases. |
| url-selector-strategy-class-name | A class that implements interface org.jboss.jca.adapters.jdbc.URLSelectorStrategy. |
| security |
Contains child elements which are security settings. See Table 14.7, “Security parameters”.
|
| validation |
Contains child elements which are validation settings. See Table 14.8, “Validation parameters”.
|
| timeout |
Contains child elements which are timeout settings. See Table 14.9, “Timeout parameters”.
|
| statement |
Contains child elements which are statement settings. See Table 14.10, “Statement parameters”.
|
| Parameter | Description |
|---|---|
| jta | Enable JTA integration for non-XA datasources. Does not apply to XA datasources. |
| connection-url | The JDBC driver connection URL. |
| driver-class | The fully-qualified name of the JDBC driver class. |
| connection-property |
Arbitrary connection properties passed to the method
Driver.connect(url,props). Each connection-property specifies a string name/value pair. The property name comes from the name, and the value comes from the element content.
|
| pool |
Contains child elements which are pooling settings. See Table 14.5, “Pool parameters common to non-XA and XA datasources”.
|
| Parameter | Description |
|---|---|
| xa-datasource-property |
A property to assign to implementation class
XADataSource. Specified by name=value. If a setter method exists, in the format setName, the property is set by calling a setter method in the format of setName(value).
|
| xa-datasource-class |
The fully-qualified name of the implementation class
javax.sql.XADataSource.
|
| driver |
A unique reference to the classloader module which contains the JDBC driver. The accepted format is driverName#majorVersion.minorVersion.
|
| xa-pool |
Contains child elements which are pooling settings. See Table 14.5, “Pool parameters common to non-XA and XA datasources” and Table 14.6, “XA pool parameters”.
|
| recovery |
Contains child elements which are recovery settings. See Table 14.11, “Recovery parameters”.
|
| Parameter | Description |
|---|---|
| min-pool-size | The minimum number of connections a pool holds. |
| max-pool-size | The maximum number of connections a pool can hold. |
| prefill | Whether to try to prefill the connection pool. An empty element denotes a true value. The default is false. |
| use-strict-min | Whether the pool-size is strict. Defaults to false. |
| flush-strategy |
Whether the pool is flushed in the case of an error. Valid values are:
The default is
FailingConnectionOnly.
|
| allow-multiple-users | Specifies if multiple users will access the datasource through the getConnection(user, password) method, and whether the internal pool type accounts for this behavior. |
| Parameter | Description |
|---|---|
| is-same-rm-override | Whether the javax.transaction.xa.XAResource.isSameRM(XAResource) class returns true or false. |
| interleaving | Whether to enable interleaving for XA connection factories. |
| no-tx-separate-pools |
Whether to create separate sub-pools for each context. This is required for Oracle datasources, which do not allow XA connections to be used both inside and outside of a JTA transaction.
Using this option will cause your total pool size to be twice
max-pool-size, because two actual pools will be created.
|
| pad-xid | Whether to pad the Xid. |
| wrap-xa-resource |
Whether to wrap the XAResource in an
org.jboss.tm.XAResourceWrapper instance.
|
| Parameter | Description |
|---|---|
| user-name | The username to use to create a new connection. |
| password | The password to use to create a new connection. |
| security-domain | Contains the name of a JAAS security-manager which handles authentication. This name correlates to the application-policy/name attribute of the JAAS login configuration. |
| reauth-plugin | Defines a reauthentication plug-in to use to reauthenticate physical connections. |
| Parameter | Description |
|---|---|
| valid-connection-checker |
An implementation of interface
org.jboss.jca.adaptors.jdbc.ValidConnectionChecker which provides a SQLException.isValidConnection(Connection e) method to validate a connection. An exception means the connection is destroyed. This overrides the parameter check-valid-connection-sql if it is present.
|
| check-valid-connection-sql | An SQL statement to check validity of a pool connection. This may be called when a managed connection is taken from a pool for use. |
| validate-on-match |
Indicates whether connection level validation is performed when a connection factory attempts to match a managed connection for a given set.
Specifying "true" for
validate-on-match is typically not done in conjunction with specifying "true" for background-validation. Validate-on-match is needed when a client must have a connection validated prior to use. This parameter is false by default.
|
| background-validation |
Specifies that connections are validated on a background thread. Background validation is a performance optimization when not used with
validate-on-match. If validate-on-match is true, using background-validation could result in redundant checks. Background validation does leave open the opportunity for a bad connection to be given to the client for use (a connection goes bad between the time of the validation scan and prior to being handed to the client), so the client application must account for this possibility.
|
| background-validation-millis | The amount of time, in milliseconds, that background validation runs. |
| use-fast-fail |
If true, fail a connection allocation on the first attempt, if the connection is invalid. Defaults to
false.
|
| stale-connection-checker |
An instance of
org.jboss.jca.adapters.jdbc.StaleConnectionChecker which provides a Boolean isStaleConnection(SQLException e) method. If this method returns true, the exception is wrapped in an org.jboss.jca.adapters.jdbc.StaleConnectionException, which is a subclass of SQLException.
|
| exception-sorter |
An instance of
org.jboss.jca.adapters.jdbc.ExceptionSorter which provides a Boolean isExceptionFatal(SQLException e) method. This method validates whether an exception is broadcast to all instances of javax.resource.spi.ConnectionEventListener as a connectionErrorOccurred message.
|
| Parameter | Description |
|---|---|
| use-try-lock | Uses tryLock() instead of lock(). This attempts to obtain the lock for the configured number of seconds, before timing out, rather than failing immediately if the lock is unavailable. Defaults to 60 seconds. As an example, to set a timeout of 5 minutes, set <use-try-lock>300</use-try-lock>. |
| blocking-timeout-millis | The maximum time, in milliseconds, to block while waiting for a connection. After this time is exceeded, an exception is thrown. This blocks only while waiting for a permit for a connection, and does not throw an exception if creating a new connection takes a long time. Defaults to 30000, which is 30 seconds. |
| idle-timeout-minutes |
The maximum time, in minutes, before an idle connection is closed. The actual maximum time depends upon the idleRemover scan time, which is half of the smallest
idle-timeout-minutes of any pool.
|
| set-tx-query-timeout |
Whether to set the query timeout based on the time remaining until transaction timeout. Any configured query timeout is used if no transaction exists. Defaults to
false.
|
| query-timeout | Timeout for queries, in seconds. The default is no timeout. |
| allocation-retry | The number of times to retry allocating a connection before throwing an exception. The default is 0, so an exception is thrown upon the first failure. |
| allocation-retry-wait-millis |
How long, in milliseconds, to wait before retrying to allocate a connection. The default is 5000, which is 5 seconds.
|
| xa-resource-timeout |
If non-zero, this value is passed to method
XAResource.setTransactionTimeout.
|
| Parameter | Description |
|---|---|
| track-statements |
Whether to check for unclosed statements when a connection is returned to a pool and a statement is returned to the prepared statement cache. If false, statements are not tracked.
|
| prepared-statement-cache-size | The number of prepared statements per connection, in a Least Recently Used (LRU) cache. |
| share-prepared-statements |
Whether asking for the same statement twice without closing it uses the same underlying prepared statement. The default is
false.
|
| Parameter | Description |
|---|---|
| recover-credential | A username/password pair or security domain to use for recovery. |
| recover-plugin |
An implementation of the
org.jboss.jca.core.spi.recoveryRecoveryPlugin class, to be used for recovery.
|
14.4.2. Datasource Connection URLs Copy linkLink copied to clipboard!
| Datasource | Connection URL |
|---|---|
| PostgreSQL | jdbc:postgresql://SERVER_NAME:PORT/DATABASE_NAME |
| MySQL | jdbc:mysql://SERVER_NAME:PORT/DATABASE_NAME |
| Oracle | jdbc:oracle:thin:@ORACLE_HOST:PORT:ORACLE_SID |
| IBM DB2 | jdbc:db2://SERVER_NAME:PORT/DATABASE_NAME |
| Microsoft SQLServer | jdbc:microsoft:sqlserver://SERVER_NAME:PORT;DatabaseName=DATABASE_NAME |
14.4.3. Datasource Extensions Copy linkLink copied to clipboard!
| Datasource Extension | Configuration Parameter | Description |
|---|---|---|
| org.jboss.jca.adapters.jdbc.spi.ExceptionSorter | <exception-sorter> | Checks whether an SQLException is fatal for the connection on which it was thrown |
| org.jboss.jca.adapters.jdbc.spi.StaleConnection | <stale-connection-checker> | Wraps stale SQLExceptions in a org.jboss.jca.adapters.jdbc.StaleConnectionException |
| org.jboss.jca.adapters.jdbc.spi.ValidConnection | <valid-connection-checker> | Checks whether a connection is valid for use by the application |
Extension Implementations
- Generic
- org.jboss.jca.adapters.jdbc.extensions.novendor.NullExceptionSorter
- org.jboss.jca.adapters.jdbc.extensions.novendor.NullStaleConnectionChecker
- org.jboss.jca.adapters.jdbc.extensions.novendor.NullValidConnectionChecker
- org.jboss.jca.adapters.jdbc.extensions.novendor.JDBC4ValidConnectionChecker
- PostgreSQL
- org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLExceptionSorter
- org.jboss.jca.adapters.jdbc.extensions.postgres.PostgreSQLValidConnectionChecker
- MySQL
- org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLExceptionSorter
- org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLReplicationValidConnectionChecker
- org.jboss.jca.adapters.jdbc.extensions.mysql.MySQLValidConnectionChecker
- IBM DB2
- org.jboss.jca.adapters.jdbc.extensions.db2.DB2ExceptionSorter
- org.jboss.jca.adapters.jdbc.extensions.db2.DB2StaleConnectionChecker
- org.jboss.jca.adapters.jdbc.extensions.db2.DB2ValidConnectionChecker
- Sybase
- org.jboss.jca.adapters.jdbc.extensions.sybase.SybaseExceptionSorter
- org.jboss.jca.adapters.jdbc.extensions.sybase.SybaseValidConnectionChecker
- Microsoft SQLServer
- org.jboss.jca.adapters.jdbc.extensions.mssql.MSSQLValidConnectionChecker
- Oracle
- org.jboss.jca.adapters.jdbc.extensions.oracle.OracleExceptionSorter
- org.jboss.jca.adapters.jdbc.extensions.oracle.OracleStaleConnectionChecker
- org.jboss.jca.adapters.jdbc.extensions.oracle.OracleValidConnectionChecker
14.4.4. View Datasource Statistics Copy linkLink copied to clipboard!
jdbc and pool using appropriately modified versions of the commands below:
Procedure 14.3.
/subsystem=datasources/data-source=ExampleDS/statistics=jdbc:read-resource(include-runtime=true)
/subsystem=datasources/data-source=ExampleDS/statistics=jdbc:read-resource(include-runtime=true)Copy to Clipboard Copied! Toggle word wrap Toggle overflow /subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true)
/subsystem=datasources/data-source=ExampleDS/statistics=pool:read-resource(include-runtime=true)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
include-runtime=true argument, as all statistics are runtime only information and the default is false.
14.4.5. Datasource Statistics Copy linkLink copied to clipboard!
The following table contains a list of the supported datasource core statistics:
| Name | Description |
|---|---|
ActiveCount |
The number of active connections. Each of the connections is either in use by an application or available in the pool
|
AvailableCount |
The number of available connections in the pool.
|
AverageBlockingTime |
The average time spent blocking on obtaining an exclusive lock on the pool. The value is in milliseconds.
|
AverageCreationTime |
The average time spent creating a connection. The value is in milliseconds.
|
CreatedCount |
The number of connections created.
|
DestroyedCount |
The number of connections destroyed.
|
InUseCount |
The number of connections currently in use.
|
MaxCreationTime |
The maximum time it took to create a connection. The value is in milliseconds.
|
MaxUsedCount |
The maximum number of connections used.
|
MaxWaitCount |
The maximum number of requests waiting for a connection at the same time.
|
MaxWaitTime |
The maximum time spent waiting for an exclusive lock on the pool.
|
TimedOut |
The number of timed out connections.
|
TotalBlockingTime |
The total time spent waiting for an exclusive lock on the pool. The value is in milliseconds.
|
TotalCreationTime |
The total time spent creating connections. The value is in milliseconds.
|
WaitCount |
The number of requests that had to wait for a connection.
|
The following table contains a list of the supported datasource JDBC statistics:
| Name | Description |
|---|---|
PreparedStatementCacheAccessCount |
The number of times that the statement cache was accessed.
|
PreparedStatementCacheAddCount |
The number of statements added to the statement cache.
|
PreparedStatementCacheCurrentSize |
The number of prepared and callable statements currently cached in the statement cache.
|
PreparedStatementCacheDeleteCount |
The number of statements discarded from the cache.
|
PreparedStatementCacheHitCount |
The number of times that statements from the cache were used.
|
PreparedStatementCacheMissCount |
The number of times that a statement request could not be satisfied with a statement from the cache.
|
14.5. Example Datasources Copy linkLink copied to clipboard!
14.5.1. Example PostgreSQL Datasource Copy linkLink copied to clipboard!
Example 14.5.
module.xml file for the PostgreSQL datasource above.
14.5.2. Example PostgreSQL XA Datasource Copy linkLink copied to clipboard!
Example 14.6.
module.xml file for the PostgreSQL XA datasource above.
14.5.3. Example MySQL Datasource Copy linkLink copied to clipboard!
Example 14.7.
module.xml file for the MySQL datasource above.
14.5.4. Example MySQL XA Datasource Copy linkLink copied to clipboard!
Example 14.8.
module.xml file for the MySQL XA datasource above.
14.5.5. Example Oracle Datasource Copy linkLink copied to clipboard!
Note
Example 14.9.
module.xml file for the Oracle datasource above.
14.5.6. Example Oracle XA Datasource Copy linkLink copied to clipboard!
Note
Important
user is the user defined to connect from JBoss to Oracle:
- GRANT SELECT ON sys.dba_pending_transactions TO user;
- GRANT SELECT ON sys.pending_trans$ TO user;
- GRANT SELECT ON sys.dba_2pc_pending TO user;
- GRANT EXECUTE ON sys.dbms_xa TO user; (If using Oracle 10g R2 (patched) or Oracle 11g)ORGRANT EXECUTE ON sys.dbms_system TO user; (If using an unpatched Oracle version prior to 11g)
Example 14.10.
module.xml file for the Oracle XA datasource above.
14.5.7. Example Microsoft SQLServer Datasource Copy linkLink copied to clipboard!
Example 14.11.
module.xml file for the Microsoft SQLServer datasource above.
14.5.8. Example Microsoft SQLServer XA Datasource Copy linkLink copied to clipboard!
Example 14.12.
module.xml file for the Microsoft SQLServer XA datasource above.
14.5.9. Example IBM DB2 Datasource Copy linkLink copied to clipboard!
Example 14.13.
module.xml file for the IBM DB2 datasource above.
14.5.10. Example IBM DB2 XA Datasource Copy linkLink copied to clipboard!
Example 14.14.
module.xml file for the IBM DB2 XA datasource above.
14.5.11. Example Sybase Datasource Copy linkLink copied to clipboard!
Example 14.15.
module.xml file for the Sybase datasource above.
14.5.12. Example Sybase XA Datasource Copy linkLink copied to clipboard!
Example 14.16.
module.xml file for the Sybase XA datasource above.
Chapter 15. JDBC Based Cache Stores Copy linkLink copied to clipboard!
JdbcBinaryStore.JdbcStringBasedStore.JdbcMixedStore.
15.1. JdbcBinaryStores Copy linkLink copied to clipboard!
JdbcBinaryStore supports all key types. It stores all keys with the same hash value (hashCode method on the key) in the same table row/blob. The hash value common to the included keys is set as the primary key for the table row/blob. As a result of this hash value, JdbcBinaryStore offers excellent flexibility but at the cost of concurrency and throughput.
k1, k2 and k3) have the same hash code, they are stored in the same table row. If three different threads attempt to concurrently update k1, k2 and k3, they must do it sequentially because all three keys share the same row and therefore cannot be simultaneously updated.
15.1.1. JdbcBinaryStore Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
JdbcBinaryStore using Red Hat JBoss Data Grid's Remote Client-Server mode with Passivation enabled.
Procedure 15.1. Configure the JdbcBinaryStore for Remote Client-Server Mode
The binary-keyed-jdbc-store Element
Thebinary-keyed-jdbc-storeelement specifies the configuration for a binary keyed cache JDBC store.- The
datasourceparameter defines the name of a JNDI for the datasource. - The
passivationparameter determines whether entries in the cache are passivated (true) or if the cache store retains a copy of the contents in memory (false). - The
preloadparameter specifies whether to load entries into the cache during start up. Valid values for this parameter aretrueandfalse. - The
purgeparameter specifies whether or not the cache store is purged when it is started. Valid values for this parameter aretrueandfalse.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The binary-keyed-table Element
Thebinary-keyed-tableelement specifies information about the database table used to store binary cache entries.- The
prefixparameter specifies a prefix string for the database table name.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The id-column Element
Theid-columnelement specifies information about a database column that holds cache entry IDs.- The
nameparameter specifies the name of the database column. - The
typeparameter specifies the type of the database column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The data-column Element
Thedata-columnelement contains information about a database column that holds cache entry data.- The
nameparameter specifies the name of the database column. - The
typeparameter specifies the type of the database column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The timestamp-column Element
Thetimestamp-columnelement specifies information about the database column that holds cache entry timestamps.- The
nameparameter specifies the name of the database column. - The
typeparameter specifies the type of the database column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.1.2. JdbcBinaryStore Configuration (Library Mode) Copy linkLink copied to clipboard!
JdbcBinaryStore:
Procedure 15.2. Configure the JdbcBinaryStore for Library Mode
The binaryKeyedJdbcStore Element
ThebinaryKeyedJdbcStoreelement uses the following parameters to configure the cache store:- The
fetchPersistentStateparameter determines whether the persistent state is fetched when joining a cluster. Set this totrueif using a replication and invalidation in a clustered environment. Additionally, if multiple cache stores are chained, only one cache store can have this property enabled. If a shared cache store is used, the cache does not allow a persistent state transfer despite this property being set totrue. ThefetchPersistentStateparameter isfalseby default. - The
ignoreModificationsparameter determines whether operations that modify the cache (e.g. put, remove, clear, store, etc.) do not affect the cache store. As a result, the cache store can become out of sync with the cache. - The
purgeOnStartupparameter specifies whether the cache store is purged when initially started.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the username used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The binaryKeyedTable Element
ThebinaryKeyedTableelement defines the table that stores cache entries. It uses the following parameters to configure the cache store:- The
dropOnExitparameter specifies whether the database tables are dropped upon shutdown. - The
createOnStartparameter specifies whether the database tables are created by the store on startup. - The
prefixparameter defines the string prepended to name of the target cache when composing the name of the cache bucket table.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The idColumn Element
TheidColumnelement defines the column where the cache key or bucket ID is stored. It uses the following parameters:- Use the
nameparameter to specify the name of the column used. - Use the
typeparameter to specify the type of the column used.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The dataColumn Element
ThedataColumnelement specifies the column where the cache entry or bucket is stored.- Use the
nameparameter to specify the name of the column used. - Use the
typeparameter to specify the type of the column used.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The timestampColumn Element
ThetimestampColumnelement specifies the column where the time stamp of the cache entry or bucket is stored.- Use the
nameparameter to specify the name of the column used. - Use the
typeparameter to specify the type of the column used.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.1.3. JdbcBinaryStore Programmatic Configuration Copy linkLink copied to clipboard!
JdbcBinaryStore:
Procedure 15.3. JdbcBinaryStore Programmatic Configuration (Library Mode)
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence()
ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence()Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
JdbcBinaryStoreConfigurationBuilderAdd theJdbcBinaryStoreconfiguration builder to build a specific configuration related to this store.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .addStore(JdbcBinaryStoreConfigurationBuilder.class)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .addStore(JdbcBinaryStoreConfigurationBuilder.class)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Persistence
fetchPersistentStatedetermines whether or not to fetch the persistent state of a cache and apply it to the local cache store when joining the cluster. If the cache store is shared the fetch persistent state is ignored, as caches access the same cache store. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set totrue. ThefetchPersistentStateproperty isfalseby default.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .addStore(JdbcBinaryStoreConfigurationBuilder.class) .fetchPersistentState(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .addStore(JdbcBinaryStoreConfigurationBuilder.class) .fetchPersistentState(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Modifications
ignoreModificationsdetermines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network.ignoreModificationsisfalseby default.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Purging
purgeOnStartupspecifies whether the cache is purged when initially started.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Table
Set Drop Table On Exit Method
dropOnExitdetermines if the table will be created when the cache store is stopped. This is set tofalseby default.Set Create Table On Start Method
createOnStartcreates the table when starting the cache store if no table currently exists. This method istrueby default.Set the Table Name Prefix
tableNamePrefixsets the prefix for the name of the table in which the data will be stored.idColumnNameTheidColumnNameproperty defines the column where the cache key or bucket ID is stored.dataColumnNameThedataColumnNameproperty specifies the column where the cache entry or bucket is stored.timestampColumnNameThetimestampColumnNameelement specifies the column where the time stamp of the cache entry or bucket is stored.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the user name used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
15.2. JdbcStringBasedStores Copy linkLink copied to clipboard!
JdbcStringBasedStore stores each entry in its own row in the table, instead of grouping multiple entries into each row, resulting in increased throughput under a concurrent load. It also uses a (pluggable) bijection that maps each key to a String object. The Key2StringMapper interface defines the bijection.
DefaultTwoWayKey2StringMapper that handles primitive types.
15.2.1. JdbcStringBasedStore Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
JdbcStringBasedStore for Red Hat JBoss Data Grid's Remote Client-Server mode with Passivation enabled.
Procedure 15.4. Configure JdbcStringBasedStore in Remote Client-Server Mode
The string-keyed-jdbc-store Element
Thestring-keyed-jdbc-storeelement specifies the configuration for a string based keyed cache JDBC store.- The
datasourceparameter defines the name of a JNDI for the datasource. - The
passivationparameter determines whether entries in the cache are passivated (true) or if the cache store retains a copy of the contents in memory (false). - The
preloadparameter specifies whether to load entries into the cache during start up. Valid values for this parameter aretrueandfalse. - The
purgeparameter specifies whether or not the cache store is purged when it is started. Valid values for this parameter aretrueandfalse. - The
sharedparameter is used when multiple cache instances share a cache store. This parameter can be set to prevent multiple cache instances writing the same modification multiple times. Valid values for this parameter aretrueandfalse. - The
singletonparameter enables a singleton store cache store. SingletonStore is a delegating cache store used when only one instance in a cluster can interact with the underlying store.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The string-keyed-table Element
Thestring-keyed-tableelement specifies information about the database table used to store string based cache entries.- The
prefixparameter specifies a prefix string for the database table name.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The id-column Element
Theid-columnelement specifies information about a database column that holds cache entry IDs.- The
nameparameter specifies the name of the ID column. - The
typeparameter specifies the type of the ID column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The data-column Element
Thedata-columnelement contains information about a database column that holds cache entry data.- The
nameparameter specifies the name of the database column. - The
typeparameter specifies the type of the database column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The timestamp-column Element
Thetimestamp-columnelement specifies information about the database column that holds cache entry timestamps.- The
nameparameter specifies the name of the database column. - The
typeparameter specifies the type of the database column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.2.2. JdbcStringBasedStore Configuration (Library Mode) Copy linkLink copied to clipboard!
JdbcStringBasedStore:
Procedure 15.5. Configure JdbcStringBasedStore in Library Mode
The stringKeyedJdbcStore Element
ThestringKeyedJdbcStoreelement uses the following parameters to configure the cache store:- The
fetchPersistentStateparameter determines whether the persistent state is fetched when joining a cluster. Set this totrueif using a replication and invalidation in a clustered environment. Additionally, if multiple cache stores are chained, only one cache store can have this property enabled. If a shared cache store is used, the cache does not allow a persistent state transfer despite this property being set totrue. ThefetchPersistentStateparameter isfalseby default. - The
ignoreModificationsparameter determines whether operations that modify the cache (e.g. put, remove, clear, store, etc.) do not affect the cache store. As a result, the cache store can become out of sync with the cache. - The
purgeOnStartupparameter specifies whether the cache is purged when initially started. - The
key2StringMapperparameter specifies the class name of the Key2StringMapper used to map keys to strings for the database tables.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the user name used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The stringKeyedTable Element
Add thestringKeyedTableelement defines the table that stores cache entries. It uses the following parameters to configure the cache store:- The
dropOnExitparameter specifies whether the database tables are dropped upon shutdown. - The
createOnStartparameter specifies whether the database tables are created by the store on startup. - The
prefixparameter specifies a prefix string for the database table name.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The idColumn Element
TheidColumnelement defines the column where the cache key or bucket ID is stored. It uses the following parameters:- Use the
nameparameter to specify the name of the ID column. - Use the
typeparameter to specify the type of the ID column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The dataColumn Element
ThedataColumnelement specifies the column where the cache entry or bucket is stored.- Use the
nameparameter to specify the name of the database column. - Use the
typeparameter to specify the type of the database column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The timestampColumn Element
ThetimestampColumnelement specifies the column where the time stamp of the cache entry or bucket is stored.- Use the
nameparameter to specify the name of the column used. - Use the
typeparameter to specify the type of the column used.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.2.3. JdbcStringBasedStore Multiple Node Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
JdbcStringBasedStore in Red Hat JBoss Data Grid's Remote Client-Server mode. This configuration is used when multiple nodes must be used.
Procedure 15.6. JdbcStringBasedStore Multiple Node Configuration for Remote Client-Server Mode
The string-keyed-jdbc-store Element
Thestring-keyed-jdbc-storeelement specifies the configuration for a string based keyed cache JDBC store.- The
fetch-stateparameter determines whether or not to fetch the persistent state of a cache when joining a cluster. If multiple cache stores are chained, only one of them can have this property enabled. - The
datasourceparameter defines the name of a JNDI for the datasource. - The
passivationparameter determines whether entries in the cache are passivated (true) or if the cache store retains a copy of the contents in memory (false). - The
preloadparameter specifies whether to load entries into the cache during start up. Valid values for this parameter aretrueandfalse. - The
purgeparameter specifies whether or not the cache store is purged when it is started. Valid values for this parameter aretrueandfalse. - The
sharedparameter is used when multiple cache instances share a cache store. This parameter can be set to prevent multiple cache instances writing the same modification multiple times. Valid values for this parameter aretrueandfalse. - The
singletonparameter enables a singleton store cache store. SingletonStore is a delegating cache store used when only one instance in a cluster should interact with the underlying store.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The string-keyed-table Element
Thestring-keyed-tableelement specifies information about the database table used to store string based cache entries.- The
prefixparameter specifies a prefix string for the database table name.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The id-column Element
Theid-columnelement specifies information about a database column that holds cache entry IDs.- The
nameparameter specifies the name of the ID column. - The
typeparameter specifies the type of the ID column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The data-column Element
Thedata-columnelement contains information about a database column that holds cache entry data.- The
nameparameter specifies the name of the database column. - The
typeparameter specifies the type of the database column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The timestamp-column Element
Thetimestamp-columnelement specifies information about the database column that holds cache entry timestamps.- The
nameparameter specifies the name of the timestamp column. - The
typeparameter specifies the type of the timestamp column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.2.4. JdbcStringBasedStore Programmatic Configuration Copy linkLink copied to clipboard!
JdbcStringBasedStore:
Procedure 15.7. Configure the JdbcStringBasedStore Programmatically
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.ConfigurationBuilder builder = new ConfigurationBuilder();
ConfigurationBuilder builder = new ConfigurationBuilder();Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add
JdbcStringBasedStoreConfigurationBuilderAdd theJdbcStringBasedStoreconfiguration builder to build a specific configuration related to this store.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)
ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Persistence
fetchPersistentStatedetermines whether or not to fetch the persistent state of a cache and apply it to the local cache store when joining the cluster. If the cache store is shared the fetch persistent state is ignored, as caches access the same cache store. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set totrue. ThefetchPersistentStateproperty isfalseby default.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class) .fetchPersistentState(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class) .fetchPersistentState(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Modifications
ignoreModificationsdetermines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network.ignoreModificationsisfalseby default.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcStringBasedStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Purging
purgeOnStartupspecifies whether the cache is purged when initially started.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Table
Set Drop Table On Exit Method
dropOnExitdetermines if the table will be created when the cache store is stopped. This is set tofalseby default.Set Create Table On Start Method
createOnStartcreates the table when starting the cache store if no table currently exists. This method istrueby default.Set the Table Name Prefix
tableNamePrefixsets the prefix for the name of the table in which the data will be stored.idColumnNameTheidColumnNameproperty defines the column where the cache key or bucket ID is stored.dataColumnNameThedataColumnNameproperty specifies the column where the cache entry or bucket is stored.timestampColumnNameThetimestampColumnNameelement specifies the column where the time stamp of the cache entry or bucket is stored.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the username used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
15.3. JdbcMixedStores Copy linkLink copied to clipboard!
JdbcMixedStore is a hybrid implementation that delegates keys based on their type to either the JdbcBinaryStore or JdbcStringBasedStore.
15.3.1. JdbcMixedStore Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
JdbcMixedStore for Red Hat JBoss Data Grid's Remote Client-Server mode with Passivation enabled.
Procedure 15.8. Configure JdbcMixedStore in Remote Client-Server Mode
The mixed-keyed-jdbc-store Element
Themixed-keyed-jdbc-storeelement specifies the configuration for a mixed keyed cache JDBC store.- The
datasourceparameter defines the name of a JNDI for the datasource. - The
passivationparameter determines whether entries in the cache are passivated (true) or if the cache store retains a copy of the contents in memory (false). - The
preloadparameter specifies whether to load entries into the cache during start up. Valid values for this parameter aretrueandfalse. - The
purgeparameter specifies whether or not the cache store is purged when it is started. Valid values for this parameter aretrueandfalse.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The binary-keyed-table Element
Thebinary-keyed-tableelement specifies information about the database table used to store mixed cache entries.- The
prefixparameter specifies a prefix string for the database table name.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The string-keyed-table Element
Thestring-keyed-tableelement specifies information about the database table used to store string based cache entries.- The
prefixparameter specifies a prefix string for the database table name.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The id-column Element
Theid-columnelement specifies information about a database column that holds cache entry IDs.- The
nameparameter specifies the name of the ID column. - The
typeparameter specifies the type of the ID column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The data-column Element
Thedata-columnelement contains information about a database column that holds cache entry data.- The
nameparameter specifies the name of the database column. - The
typeparameter specifies the type of the database column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The timestamp-column Element
Thetimestamp-columnelement specifies information about the database column that holds cache entry timestamps.- The
nameparameter specifies the name of the timestamp column. - The
typeparameter specifies the type of the timestamp column.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.3.2. JdbcMixedStore Configuration (Library Mode) Copy linkLink copied to clipboard!
mixedKeyedJdbcStore:
Procedure 15.9. Configure JdbcMixedStore in Library Mode
The mixedKeyedJdbcStore Element
ThemixedKeyedJdbcStoreelement uses the following parameters to configure the cache store:- The
fetchPersistentStateparameter determines whether the persistent state is fetched when joining a cluster. Set this totrueif using a replication and invalidation in a clustered environment. Additionally, if multiple cache stores are chained, only one cache store can have this property enabled. If a shared cache store is used, the cache does not allow a persistent state transfer despite this property being set totrue. ThefetchPersistentStateparameter isfalseby default. - The
ignoreModificationsparameter determines whether operations that modify the cache (for example put, remove, clear, store, etc.) do not affect the cache store. As a result, the cache store can become out of sync with the cache. - The
purgeOnStartupparameter specifies whether the cache is purged when initially started. - The
key2StringMapperparameter specifies the class name of the Key2StringMapper used to map keys to strings for the database tables.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The binaryKeyedTable and stringKeyedTable Elements
ThebinaryKeyedTableand thestringKeyedTableelement defines the table that stores cache entries. Each uses the following parameters to configure the cache store:- The
dropOnExitparameter specifies whether the database tables are dropped upon shutdown. - The
createOnStartparameter specifies whether the database tables are created by the store on startup. - The
prefixparameter defines the string prepended to name of the target cache when composing the name of the cache bucket table.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The idColumn Element
TheidColumnelement defines the column where the cache key or bucket ID is stored. It uses the following parameters:- Use the
nameparameter to specify the name of the column used. - Use the
typeparameter to specify the type of the column used.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The dataColumn Element
ThedataColumnelement specifies the column where the cache entry or bucket is stored.- Use the
nameparameter to specify the name of the column used. - Use the
typeparameter to specify the type of the column used.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The timestampColumn Element
ThetimestampColumnelement specifies the column where the time stamp of the cache entry or bucket is stored.- Use the
nameparameter to specify the name of the column used. - Use the
typeparameter to specify the type of the column used.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The string-keyed-table Element
Thestring-keyed-tableelement specifies information about the database table used to store string based cache entries.- The
prefixparameter specifies a prefix string for the database table name.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
15.3.3. JdbcMixedStore Programmatic Configuration Copy linkLink copied to clipboard!
JdbcMixedStore:
Procedure 15.10. Configure JdbcMixedStore Programmatically
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.ConfigurationBuilder builder = new ConfigurationBuilder();
ConfigurationBuilder builder = new ConfigurationBuilder();Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add
JdbcMixedStoreConfigurationBuilderAdd theJdbcMixedStoreconfiguration builder to build a specific configuration related to this store.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcMixedStoreConfigurationBuilder.class)
ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcMixedStoreConfigurationBuilder.class)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Persistence
fetchPersistentStatedetermines whether or not to fetch the persistent state of a cache and apply it to the local cache store when joining the cluster. If the cache store is shared the state is ignored, as caches access the same cache store. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set totrue. ThefetchPersistentStateproperty isfalseby default.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcMixedStoreConfigurationBuilder.class) .fetchPersistentState(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcMixedStoreConfigurationBuilder.class) .fetchPersistentState(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Modifications
ignoreModificationsdetermines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network.ignoreModificationsisfalseby default.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcMixedStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence().addStore(JdbcMixedStoreConfigurationBuilder.class) .fetchPersistentState(false) .ignoreModifications(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Purging
purgeOnStartupspecifies whether the cache is purged when initially started.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Table
Set Drop Table On Exit Method
dropOnExitdetermines if the table will be created when the cache store is stopped. This is set tofalseby default.Set Create Table On Start Method
createOnStartcreates the table when starting the cache store if no table currently exists. This method istrueby default.Set the Table Name Prefix
tableNamePrefixsets the prefix for the name of the table in which the data will be stored.idColumnNameTheidColumnNameproperty defines the column where the cache key or bucket ID is stored.dataColumnNameThedataColumnNameproperty specifies the column where the cache entry or bucket is stored.timestampColumnNameThetimestampColumnNameelement specifies the column where the time stamp of the cache entry or bucket is stored.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow The connectionPool Element
TheconnectionPoolelement specifies a connection pool for the JDBC driver using the following parameters:- The
connectionUrlparameter specifies the JDBC driver-specific connection URL. - The
usernameparameter contains the username used to connect via theconnectionUrl. - The
driverClassparameter specifies the class name of the driver used to connect to the database.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
15.4. Cache Store Troubleshooting Copy linkLink copied to clipboard!
15.4.1. IOExceptions with JdbcStringBasedStore Copy linkLink copied to clipboard!
JdbcStringBasedStore indicates that your data column type is set to VARCHAR, CLOB or something similar instead of the correct type, BLOB or VARBINARY. Despite its name, JdbcStringBasedStore only requires that the keys are strings while the values can be any data type, so that they can be stored in a binary column.
Chapter 16. Cache Loaders Copy linkLink copied to clipboard!
16.1. Cache Loaders and Cache Stores Copy linkLink copied to clipboard!
CacheLoader interface and a number of implementations. Red Hat JBoss Data Grid has divided these into two distinct interfaces, a CacheLoader and a CacheStore. The CacheLoader loads a previously existing state from another location, while the CacheStore (which extends CacheLoader) exposes methods to store states as well as loading them. This division allows easier definition of read-only sources.
16.2. Cache Loader Configuration Copy linkLink copied to clipboard!
16.2.1. Configuring the Cache Loader Copy linkLink copied to clipboard!
ignoreModifications element has been set to "true" for a specific cache loader.
16.2.2. Configure the Cache Loader using XML Copy linkLink copied to clipboard!
Procedure 16.1. Configure the Cache Loader Using XML
Create a New Cache Loader
Create a new cache loader, specifyingpassivation,shared, andpreloadsettings.passivationaffects the way in which Red Hat JBoss Data Grid interacts with loaders. Passivation removes an object from in-memory cache and writes it to a secondary data store, such as a system or database. Passivation isfalseby default.sharedindicates that the cache loader is shared by different cache instances. For example, where all instances in a cluster use the same JDBC settings to talk to the same remote, shared database.sharedisfalseby default. When set totrue, it prevents duplicate data being written to the cache loader by different cache instances.preloadis set tofalseby default. When set totruethe data stored in the cache loader is preloaded into the memory when the cache starts. This allows data in the cache loader to be available immediately after startup and avoids cache operations delays as a result of loading data lazily. Preloaded data is only stored locally on the node, and there is no replication or distribution of the preloaded data. Red Hat JBoss Data Grid will only preload up to the maximum configured number of entries in eviction.
<persistence passivation="false" shared="false" preload="true">
<persistence passivation="false" shared="false" preload="true">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Persistence and Purging
fetchPersistentStatedetermines whether or not to fetch the persistent state of a cache and apply it to the local cache store when joining the cluster. If the cache store is shared the fetch persistent state is ignored, as caches access the same cache store. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set totrue. ThefetchPersistentStateproperty isfalseby default.purgeSynchronouslycontrols whether expiration occurs in the eviction thread. When set totrue, the eviction thread will block until the purge is finished, rather than bring returned immediately. ThepurgeSychronouslyproperty is set tofalseby default. If the cache loader supports multi-thread purge,purgeThreadsare used to purge expired entries.purgeThreadsis set to1by default. Check cache loader configuration to determine if multi-thread purge is supported.ignoreModificationsdetermines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network.ignoreModificationsisfalseby default.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Asynchronous Settings
These attributes configure aspects specific to each cache loader. For example, thelocationattribute points to where the SingleFileStore keeps files containing data. Other loaders may require more complex configuration.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Singletons and Push States
singletonStoreenables modifications to be stored by only one node in the cluster. This node is called the coordinator. The coordinator pushes the caches in-memory states to disk. This function is activated by setting theenabledattribute totruein all nodes. Thesharedparameter cannot be defined withsingletonStoreenabled at the same time. Theenabledattribute isfalseby default.pushStateWhenCoordinatoris set totrueby default. Iftrue, this property will cause a node that has become the coordinator to transfer in-memory state to the underlying cache loader. This parameter is useful where the coordinator has crashed and a new coordinator is elected.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.2.3. Configure the Cache Loader Programmatically Copy linkLink copied to clipboard!
Procedure 16.2. Configure the Cache Loader Programatically
Create a New Configuration Builder
Use theConfigurationBuilderto create a new configuration object.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence()
ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence()Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Passivation
passivationaffects the way Red Hat JBoss Data Grid interacts with loaders. Passivation removes an object from in-memory cache and writes it to a secondary data loader, such as a system or database. Passivation isfalseby default.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .passivation(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .passivation(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Sharing
sharedindicates that the cache loader is shared by different cache instances. For example, where all instances in a cluster use the same JDBC settings to talk to the same remote, shared database.sharedisfalseby default. When set totrue, it prevents duplicate data being written to the cache loader by different cache instances.ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .passivation(false) .shared(false)ConfigurationBuilder builder = new ConfigurationBuilder(); builder.persistence() .passivation(false) .shared(false)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Preloading
preloadis set tofalseby default. When set totruethe data stored in the cache loader is preloaded into the memory when the cache starts. This allows data in the cache loader to be available immediately after startup and avoids cache operations delays as a result of loading data lazily. Preloaded data is only stored locally on the node, and there is no replication or distribution of the preloaded data. JBoss Data Grid will only preload up to the maximum configured number of entries in eviction.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Cache Loader
addSingleFileStore()adds the SingleFileStore as the cache loader for this configuration. It is possible to create other stores, such as a JDBC Cache Store, which can be added using theaddLoadermethod.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Persistence
fetchPersistentStatedetermines whether or not to fetch the persistent state of a cache and apply it to the local cache loader when joining the cluster. If the cache loader is shared the fetch persistent state is ignored, as caches access the same cache loader. A configuration exception will be thrown when starting the cache service if more than one cache loader has this property set totrue. ThefetchPersistentStateproperty isfalseby default.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Purging
purgeSynchronouslycontrols whether expiration occurs in the eviction thread. When set totrue, the eviction thread will block until the purge is finished, rather than bring returned immediately. ThepurgeSychronouslyproperty is set tofalseby default. If the cache loader supports multi-thread purge,purgeThreadsare used to purge expired entries.purgeThreadsis set to1by default. Check cache loader configuration to determine if multi-thread purge is supported.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Modifications
ignoreModificationsdetermines whether write methods are pushed to the specific cache loader by allowing write operations to the local file cache loader, but not the shared cache loader. In some cases, transient application data should only reside in a file-based cache loader on the same server as the in-memory cache. For example, this would apply with a further JDBC based cache loader used by all servers in the network.ignoreModificationsisfalseby default.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Asynchronous Settings
These attributes configure aspects specific to each cache loader. For example, thelocationattribute points to where the SingleFileStore will keep files containing data. Other loaders may require more complex configuration.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Singletons
singletonStoreenables modifications to be stored by only one node in the cluster. This node is called the coordinator. The coordinator pushes the caches in-memory states to disk. This function is activated by setting theenabledattribute totruein all nodes. Thesharedparameter cannot be defined withsingletonStoreenabled at the same time. Theenabledattribute isfalseby default.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up Push States
pushStateWhenCoordinatoris set totrueby default. Iftrue, this property will cause a node that has become the coordinator to transfer in-memory state to the underlying cache loader. This parameter is useful where the coordinator has crashed and a new coordinator is elected.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
16.4. Connection Factories Copy linkLink copied to clipboard!
ConnectionFactory implementation to obtain a database connection. This process is also known as connection management or pooling.
ConnectionFactoryClass configuration attribute. JBoss Data Grid includes the following ConnectionFactory implementations:
- ManagedConnectionFactory
- SimpleConnectionFactory.
16.4.1. About ManagedConnectionFactory Copy linkLink copied to clipboard!
ManagedConnectionFactory is a connection factory that is ideal for use within managed environments such as application servers. This connection factory can explore a configured location in the JNDI tree and delegate connection management to the DataSource. ManagedConnectionFactory is used within a managed environment that contains a DataSource. This Datasource is delegated the connection pooling.
16.4.2. About SimpleConnectionFactory Copy linkLink copied to clipboard!
SimpleConnectionFactory is a connection factory that creates database connections on a per invocation basis. This connection factory is not designed for use in a production environment.
Part VII. Set Up Passivation Copy linkLink copied to clipboard!
Chapter 17. Activation and Passivation Modes Copy linkLink copied to clipboard!
17.1. Passivation Mode Benefits Copy linkLink copied to clipboard!
17.2. Configure Passivation Copy linkLink copied to clipboard!
passivation parameter to the cache store element to toggle passivation for it:
passivation parameter to the loaders element to toggle passivation:
<persistence passivation="true"
... />
...
</persistence>
<persistence passivation="true"
... />
...
</persistence>
17.3. Eviction and Passivation Copy linkLink copied to clipboard!
17.3.1. Eviction and Passivation Usage Copy linkLink copied to clipboard!
- A notification regarding the passivated entry is emitted to the cache listeners.
- The evicted entry is stored.
17.3.2. Eviction Example when Passivation is Disabled Copy linkLink copied to clipboard!
| Step | Key in Memory | Key on Disk |
|---|---|---|
Insert keyOne | Memory: keyOne | Disk: keyOne |
Insert keyTwo | Memory: keyOne, keyTwo | Disk: keyOne, keyTwo |
Eviction thread runs, evicts keyOne | Memory: keyTwo | Disk: keyOne, keyTwo |
Read keyOne | Memory: keyOne, keyTwo | Disk: keyOne, keyTwo |
Eviction thread runs, evicts keyTwo | Memory: keyOne | Disk: keyOne, keyTwo |
Remove keyTwo | Memory: keyOne | Disk: keyOne |
17.3.3. Eviction Example when Passivation is Enabled Copy linkLink copied to clipboard!
| Step | Key in Memory | Key on Disk |
|---|---|---|
Insert keyOne | Memory: keyOne | Disk: |
Insert keyTwo | Memory: keyOne, keyTwo | Disk: |
Eviction thread runs, evicts keyOne | Memory: keyTwo | Disk: keyOne |
Read keyOne | Memory: keyOne, keyTwo | Disk: |
Eviction thread runs, evicts keyTwo | Memory: keyOne | Disk: keyTwo |
Remove keyTwo | Memory: keyOne | Disk: |
Part VIII. Set Up Cache Writing Copy linkLink copied to clipboard!
Chapter 18. Cache Writing Modes Copy linkLink copied to clipboard!
- Write-Through (Synchronous)
- Write-Behind (Asynchronous)
18.1. Write-Through Caching Copy linkLink copied to clipboard!
Cache.put() invocation), the call does not return until JBoss Data Grid has located and updated the underlying cache store. This feature allows updates to the cache store to be concluded within the client thread boundaries.
18.1.1. Write-Through Caching Benefits Copy linkLink copied to clipboard!
18.1.2. Write-Through Caching Configuration (Library Mode) Copy linkLink copied to clipboard!
Procedure 18.1. Configure a Write-Through Local File Cache Store
Identify the
namedCacheThenameparameter specifies the name of thenamedCacheto use.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Cache Loader
Thesharedparameter is used when multiple cache instances share a cache store. This parameter can be set to prevent multiple cache instances writing the same modification multiple times. Valid values for this parameter aretrueandfalse.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the Loader Class
Theclassattribute defines the class of the cache loader implementation.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the
fetchPersistentStateParameterThefetchPersistentStateparameter determines whether the persistent state is fetched when joining a cluster. Set this totrueif using a replication and invalidation in a clustered environment. Additionally, if multiple cache stores are chained, only one cache store can have this property enabled. If a shared cache store is used, the cache does not allow a persistent state transfer despite this property being set totrue. ThefetchPersistentStateparameter isfalseby default.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the
ignoreModificationsParameterTheignoreModificationsparameter determines whether operations that modify the cache (e.g. put, remove, clear, store, etc.) do not affect the cache store. As a result, the cache store can become out of sync with the cache.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Purge On Startup
ThepurgeOnStartupparameter specifies whether the cache is purged when initially started.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
propertyElementThepropertyelement contains information about properties related to the cache store.- The
nameparameter specifies the name of the property.
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
18.2. Write-Behind Caching Copy linkLink copied to clipboard!
18.2.1. About Unscheduled Write-Behind Strategy Copy linkLink copied to clipboard!
18.2.2. Unscheduled Write-Behind Strategy Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
write-behind element to the target cache store configuration as follows:
Procedure 18.2. The write-behind Element
write-behind element uses the following configuration parameters:
The
modification-queue-sizeParameterThemodification-queue-sizeparameter sets the modification queue size for the asynchronous store. If updates occur faster than the cache store can process the queue, the asynchronous store behaves like a synchronous store. The store behavior remains synchronous and blocks elements until the queue is able to accept them, after which the store behavior becomes asynchronous again.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
shutdown-timeoutParameterTheshutdown-timeoutparameter specifies the time in milliseconds after which the cache store is shut down. When the store is stopped some modifications may still need to be applied. Setting a large timeout value will reduce the chance of data loss. The default value for this parameter is25000.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
flush-lock-timeoutParameterTheflush-lock-timeoutparameter specifies the time (in milliseconds) to acquire the lock that guards the state to be periodically flushed. The default value for this parameter is15000.Copy to Clipboard Copied! Toggle word wrap Toggle overflow The
thread-pool-sizeParameterThethread-pool-sizeparameter specifies the size of the thread pool. The threads in this thread pool apply modifications to the cache store. The default value for this parameter is5.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
18.2.3. Unscheduled Write-Behind Strategy Configuration (Library Mode) Copy linkLink copied to clipboard!
async element to the store configuration as follows:
Procedure 18.3. The async Element
async element uses the following configuration parameters:
- The
modificationQueueSizeparameter sets the modification queue size for the asynchronous store. If updates occur faster than the cache store can process the queue, the asynchronous store behaves like a synchronous store. The store behavior remains synchronous and blocks elements until the queue is able to accept them, after which the store behavior becomes asynchronous again.<persistence> <fileStore location="${LOCATION}"> <async enabled="true" modificationQueueSize="1024" /><persistence> <fileStore location="${LOCATION}"> <async enabled="true" modificationQueueSize="1024" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
shutdownTimeoutparameter specifies the time in milliseconds after which the cache store is shut down. This provides time for the asynchronous writer to flush data to the store when a cache is shut down. The default value for this parameter is25000.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
flushLockTimeoutparameter specifies the time (in milliseconds) to acquire the lock that guards the state to be periodically flushed. The default value for this parameter is15000.Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The
threadPoolSizeparameter specifies the number of threads that concurrently apply modifications to the store. The default value for this parameter is5.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Part IX. Monitor Caches and Cache Managers Copy linkLink copied to clipboard!
Chapter 19. Set Up Java Management Extensions (JMX) Copy linkLink copied to clipboard!
19.1. About Java Management Extensions (JMX) Copy linkLink copied to clipboard!
MBeans.
19.2. Using JMX with Red Hat JBoss Data Grid Copy linkLink copied to clipboard!
19.3. JMX Statistic Levels Copy linkLink copied to clipboard!
- At the cache level, where management information is generated by individual cache instances.
- At the
CacheManagerlevel, where theCacheManageris the entity that governs all cache instances created from it. As a result, the management information is generated for all these cache instances instead of individual caches.
Important
19.4. Enable JMX for Cache Instances Copy linkLink copied to clipboard!
Add the following snippet within either the <default> element for the default cache instance, or under the target <namedCache> element for a specific named cache:
<jmxStatistics enabled="true"/>
<jmxStatistics enabled="true"/>
Add the following code to programmatically enable JMX at the cache level:
Configuration configuration = ... configuration.setExposeJmxStatistics(true);
Configuration configuration = ...
configuration.setExposeJmxStatistics(true);
19.5. Enable JMX for CacheManagers Copy linkLink copied to clipboard!
CacheManager level, JMX statistics can be enabled either declaratively or programmatically, as follows.
Add the following in the <global> element to enable JMX declaratively at the CacheManager level:
<globalJmxStatistics enabled="true"/>
<globalJmxStatistics enabled="true"/>
Add the following code to programmatically enable JMX at the CacheManager level:
GlobalConfiguration globalConfiguration = ... globalConfiguration.setExposeGlobalJmxStatistics(true);
GlobalConfiguration globalConfiguration = ...
globalConfiguration.setExposeGlobalJmxStatistics(true);
19.6. Disabling the CacheStore via JMX Copy linkLink copied to clipboard!
disconnectSource operation on the RollingUpgradeManager MBean.
See Also:
19.7. Multiple JMX Domains Copy linkLink copied to clipboard!
CacheManager instances exist on a single virtual machine, or if the names of cache instances in different CacheManagers clash.
CacheManager in manner that allows it to be easily identified and used by monitoring tools such as JMX and JBoss Operations Network.
Add the following snippet to the relevant CacheManager configuration:
<globalJmxStatistics enabled="true" cacheManagerName="Hibernate2LC"/>
<globalJmxStatistics enabled="true" cacheManagerName="Hibernate2LC"/>
Add the following code to set the CacheManager name programmatically:
GlobalConfiguration globalConfiguration = ...
globalConfiguration.setExposeGlobalJmxStatistics(true);
globalConfiguration.setCacheManagerName("Hibernate2LC");
GlobalConfiguration globalConfiguration = ...
globalConfiguration.setExposeGlobalJmxStatistics(true);
globalConfiguration.setCacheManagerName("Hibernate2LC");
19.8. MBeans Copy linkLink copied to clipboard!
MBean represents a manageable resource such as a service, component, device or an application.
MBeans that monitor and manage multiple aspects. For example, MBeans that provide statistics on the transport layer are provided. If a JBoss Data Grid server is configured with JMX statistics, an MBean that provides information such as the hostname, port, bytes read, bytes written and the number of worker threads exists at the following location:
jboss.infinispan:type=Server,name=<Memcached|Hotrod>,component=Transport
jboss.infinispan:type=Server,name=<Memcached|Hotrod>,component=Transport
Note
19.8.1. Understanding MBeans Copy linkLink copied to clipboard!
MBeans are available:
- If Cache Manager-level JMX statistics are enabled, an
MBeannamedjboss.infinispan:type=CacheManager,name="DefaultCacheManager"exists, with properties specified by the Cache ManagerMBean. - If the cache-level JMX statistics are enabled, multiple
MBeansdisplay depending on the configuration in use. For example, if a write behind cache store is configured, anMBeanthat exposes properties that belong to the cache store component is displayed. All cache-levelMBeansuse the same format:jboss.infinispan:type=Cache,name="<name-of-cache>(<cache-mode>)",manager="<name-of-cache-manager>",component=<component-name>
jboss.infinispan:type=Cache,name="<name-of-cache>(<cache-mode>)",manager="<name-of-cache-manager>",component=<component-name>Copy to Clipboard Copied! Toggle word wrap Toggle overflow In this format:- Specify the default name for the cache using the
cache-containerelement'sdefault-cacheattribute. - The
cache-modeis replaced by the cache mode of the cache. The lower case version of the possible enumeration values represents the cache mode. - The
component-nameis replaced by one of the JMX component names from the JMX reference documentation.
MBean for a default cache configured for synchronous distribution would be named as follows:
jboss.infinispan:type=Cache,name="default(dist_sync)", manager="default",component=CacheStore
jboss.infinispan:type=Cache,name="default(dist_sync)", manager="default",component=CacheStore
19.8.2. Registering MBeans in Non-Default MBean Servers Copy linkLink copied to clipboard!
getMBeanServer() method returns the desired (non default) MBeanServer.
Add the following snippet:
<globalJmxStatistics enabled="true" mBeanServerLookup="com.acme.MyMBeanServerLookup"/>
<globalJmxStatistics enabled="true" mBeanServerLookup="com.acme.MyMBeanServerLookup"/>
Add the following code:
GlobalConfiguration globalConfiguration = ...
globalConfiguration.setExposeGlobalJmxStatistics(true);
globalConfiguration.setMBeanServerLookup("com.acme.MyMBeanServerLookup")
GlobalConfiguration globalConfiguration = ...
globalConfiguration.setExposeGlobalJmxStatistics(true);
globalConfiguration.setMBeanServerLookup("com.acme.MyMBeanServerLookup")
Chapter 20. Set Up JBoss Operations Network (JON) Copy linkLink copied to clipboard!
20.1. About JBoss Operations Network (JON) Copy linkLink copied to clipboard!
Important
20.2. Download JBoss Operations Network (JON) Copy linkLink copied to clipboard!
20.2.1. Prerequisites for Installing JBoss Operations Network (JON) Copy linkLink copied to clipboard!
- A Linux, Windows, or Mac OSX operating system, and an x86_64, i686, or ia64 processor.
- Java 6 or higher is required to run both the JBoss Operations Network Server and the JBoss Operations Network Agent.
- Synchronized clocks on JBoss Operations Network Servers and Agents.
- An external database must be installed.
20.2.2. Download JBoss Operations Network Copy linkLink copied to clipboard!
Procedure 20.1. Download JBoss Operations Network
Access the Customer Service Portal
Log in to the Customer Service Portal at https://access.redhat.comLocate the Product
Mouse over and navigate to .Select the Product
Select from the menu.Download JBoss Operations Network
- Select the latest version of JBoss Operations Network Base Distribution and click the link.
- Select the latest JBoss Data Grid Plugin Pack for JBoss Operations Network and click the link.
20.2.3. Remote JMX Port Values Copy linkLink copied to clipboard!
20.2.4. Download JBoss Operations Network (JON) Plugin Copy linkLink copied to clipboard!
Procedure 20.2. Download Installation Files
- Open http://access.redhat.com in a web browser.
- Click in the menu across the top of the page.
- Click in the list under JBoss Enterprise Middleware.
- Enter your login information.You are taken to the Software Downloads page.
Download the JBoss Operations Network Plugin
If you intend to use the JBoss Operations Network plugin for JBoss Data Grid, selectJBoss ON for JDGfrom either the Software Downloads drop-down box, or the menu on the left.- Click the
JBoss Operations Network VERSION Base Distributiondownload link. - Click the link to start the Base Distribution download.
- Repeat the steps to download the
JDG Plugin Pack for JBoss ON VERSION
20.3. JBoss Operations Network Server Installation Copy linkLink copied to clipboard!
Note
20.4. JBoss Operations Network Agent Copy linkLink copied to clipboard!
init.d script in a UNIX environment.
Note
20.5. JBoss Operations Network for Remote Client-Server Mode Copy linkLink copied to clipboard!
- initiate and perform installation and configuration operations.
- monitor resources and their metrics.
20.5.1. Installing the JBoss Operations Network Plug-in (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Install the plug-ins
- Copy the JBoss Data Grid server rhq plug-in to
$JON_SERVER_HOME/plugins. - Copy the Wildfly 7 plug-in to
$JON_SERVER_HOME/plugins.
The server will automatically discover plug-ins here and deploy them. The plug-ins will be removed from the plug-ins directory after successful deployment.Obtain plug-ins
Obtain all available plug-ins from the JBoss Operations Network server. To do this, type the following into the agent's console:plugins update
plugins updateCopy to Clipboard Copied! Toggle word wrap Toggle overflow List installed plug-ins
Ensure the Wildfly 7 plug-in and the JBoss Data Grid server rhq plug-in are installed correctly using the following:plugins info
plugins infoCopy to Clipboard Copied! Toggle word wrap Toggle overflow
20.6. JBoss Operations Network for Library Mode Copy linkLink copied to clipboard!
- initiate and perform installation and configuration operations.
- monitor resources and their metrics.
20.6.1. Installing the JBoss Operations Network Plug-in (Library Mode) Copy linkLink copied to clipboard!
Procedure 20.3. Install JBoss Operations Network Library Mode Plug-in
Open the JBoss Operations Network Console
- From the JBoss Operations Network console, select .
- Select from the options on the left side of the console.
Figure 20.1. JBoss Operations Network Console for JBoss Data Grid
Upload the Library Mode Plug-in
- Click , locate the
InfinispanPluginon your local file system. - Click to add the plug-in to the JBoss Operations Network Server.
Figure 20.2. Upload the
InfinispanPlugin.Scan for Updates
- Once the file has successfully uploaded, click at the bottom of the screen.
- The
InfinispanPluginwill now appear in the list of installed plug-ins.
Figure 20.3. Scan for Updated Plug-ins.
Import the Platform
- Navigate to the and select from the list on the left of the console.
- Select the platform on which the application is running and click at the bottom of the screen.
Figure 20.4. Import the Platform from the .
Access the Servers on the Platform
- The
jdgPlatform now appears in the Platforms list. - Click on the Platform to access the servers that are running on it.
Figure 20.5. Open the
jdgPlatform to view the list of servers.Import the JMX Server
- From the tab, select .
- Click the button at the bottom of the screen and select the option from the list.
Figure 20.6. Import the JMX Server
Enable JDK Connection Settings
- In the window, specify from the list of options.
Figure 20.7. Select the JDK 5 Template.
Modify the Connector Address
- In the menu, modify the supplied with the hostname and JMX port of the process containing the Infinispan Library.
- Specify the and information if required.
- Click .
Figure 20.8. Modify the values in the Deployment Options screen.
View Cache Statistics and Operations
- Click to refresh the list of servers.
- The tree in the panel on the left side of the screen contains the node, which contains the available cache managers. The available cache managers contain the available caches.
- Select a cache from the available caches to view metrics.
- Select the tab.
- The view shows statistics and metrics.
- The tab provides access to the various operations that can be performed on the services.
Figure 20.9. Metrics and operational data relayed through JMX is now available in the JBoss Operations Network console.
20.6.2. Manually Adding JBoss Data Grid Instances in Library Mode Copy linkLink copied to clipboard!
- Select > > > .
- At the bottom of the page, open the drop-down menu next to the section.
- Select and click .
- Select the
defaulttemplate on the next page. Manually add the JBoss Data Grid instance
- Enter both the JMX connector address of the new JBoss Data Grid instance you want to monitor, and the Cache Manager Mbean object name. For example:Connector Address:
service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:7997/jmxrmi
service:jmx:rmi://127.0.0.1/jndi/rmi://127.0.0.1:7997/jmxrmiCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Object Name:
org.infinispan:type=CacheManager,name="<name_of_cache_manager>
org.infinispan:type=CacheManager,name="<name_of_cache_manager>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
-Dcom.sun.management.jmxremote.port=7997 -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.authenticate=false
-Dcom.sun.management.jmxremote.port=7997 -Dcom.sun.management.jmxremote.ssl=false
-Dcom.sun.management.jmxremote.authenticate=false
20.7. JBoss Operations Network Remote-Client Server Plugin Copy linkLink copied to clipboard!
20.7.1. JBoss Operations Network Plugin Metrics Copy linkLink copied to clipboard!
| Metric Name | Display Name | Description |
|---|---|---|
| cache-manager-status | Cache Container Status | The current runtime status of a cache container. |
| cluster-name | Cluster Name | The name of the cluster. |
| coordinator-address | Coordinator Address | The coordinator node's address. |
| local-address | Local Address | The local node's address. |
| Metric Name | Display Name | Description |
|---|---|---|
| cache-status | Cache Status | The current runtime status of a cache. |
| number-of-locks-available | [LockManager] Number of locks available | The number of exclusive locks that are currently available. |
| concurrency-level | [LockManager] Concurrency level | The LockManager's configured concurrency level. |
| average-read-time | [Statistics] Average read time | Average number of milliseconds required for a read operation on the cache to complete. |
| hit-ratio | [Statistics] Hit ratio | The result (in percentage) when the number of hits (successful attempts) is divided by the total number of attempts. |
| elapsed-time | [Statistics] Seconds since cache started | The number of seconds since the cache started. |
| read-write-ratio | [Statistics] Read/write ratio | The read/write ratio (in percentage) for the cache. |
| average-write-time | [Statistics] Average write time | Average number of milliseconds a write operation on a cache requires to complete. |
| hits | [Statistics] Number of cache hits | Number of cache hits. |
| evictions | [Statistics] Number of cache evictions | Number of cache eviction operations. |
| remove-misses | [Statistics] Number of cache removal misses | Number of cache removals where the key was not found. |
| time-since-reset | [Statistics] Seconds since cache statistics were reset | Number of seconds since the last cache statistics reset. |
| number-of-entries | [Statistics] Number of current cache entries | Number of entries currently in the cache. |
| stores | [Statistics] Number of cache puts | Number of cache put operations |
| remove-hits | [Statistics] Number of cache removal hits | Number of cache removal operation hits. |
| misses | [Statistics] Number of cache misses | Number of cache misses. |
| success-ratio | [RpcManager] Successful replication ratio | Successful replications as a ratio of total replications in numeric double format. |
| replication-count | [RpcManager] Number of successful replications | Number of successful replications |
| replication-failures | [RpcManager] Number of failed replications | Number of failed replications |
| average-replication-time | [RpcManager] Average time spent in the transport layer | The average time (in milliseconds) spent in the transport layer. |
| commits | [Transactions] Commits | Number of transaction commits performed since the last reset. |
| prepares | [Transactions] Prepares | Number of transaction prepares performed since the last reset. |
| rollbacks | [Transactions] Rollbacks | Number of transaction rollbacks performed since the last reset. |
| invalidations | [Invalidation] Number of invalidations | Number of invalidations. |
| passivations | [Passivation] Number of cache passivations | Number of passivation events. |
| activations | [Activations] Number of cache entries activated | Number of activation events. |
| cache-loader-loads | [Activation] Number of cache store loads | Number of entries loaded from the cache store. |
| cache-loader-misses | [Activation] Number of cache store misses | Number of entries that did not exist in the cache store. |
| cache-loader-stores | [CacheStore] Number of cache store stores | Number of entries stored in the cache stores. |
Note
The metrics provided by the JBoss Operations Network (JON) plugin for Red Hat JBoss Data Grid are for REST and Hot Rod endpoints only. For the REST protocol, the data must be taken from the Web subsystem metrics. For details about each of these endpoints, see the Getting Started Guide.
| Metric Name | Display Name | Description |
|---|---|---|
| bytesRead | Bytes Read | Number of bytes read. |
| bytesWritten | Bytes Written | Number of bytes written. |
Note
20.7.2. JBoss Operations Network Plugin Operations Copy linkLink copied to clipboard!
| Operation Name | Description |
|---|---|
| Clear Cache | Clears the cache contents. |
| Reset Statistics | Resets statistics gathered by the cache. |
| Reset Activation Statistics | Resets activation statistics gathered by the cache. |
| Reset Invalidation Statistics | Resets invalidations statistics gathered by the cache. |
| Reset Passivation Statistics | Resets passivation statistics gathered by the cache. |
| Reset Rpc Statistics | Resets replication statistics gathered by the cache. |
| Remove Cache | Removes the given cache from the cache-container. |
The cache backups used for these operations are configured using cross-datacenter replication. In the JBoss Operations Network (JON) User Interface, each cache backup is the child of a cache. For more information about cross-datacenter replication, see Section 27.1, “About Cross-Datacenter Replication”
| Operation Name | Description |
|---|---|
| status | Display the site status. |
| bring-site-online | Brings the site online. |
| take-site-offline | Takes the site offline. |
Red Hat JBoss Data Grid does not support using Transactions in Remote Client-Server mode. As a result, none of the endpoints can use transactions.
20.7.3. JBoss Operations Network Plugin Attributes Copy linkLink copied to clipboard!
| Attribute Name | Type | Description |
|---|---|---|
| cluster | string | The name of the group communication cluster. |
| executor | string | The executor used for the transport. |
| lock-timeout | long | The timeout period for locks on the transport. The default value is 240000. |
| machine | string | A machine identifier for the transport. |
| rack | string | A rack identifier for the transport. |
| site | string | A site identifier for the transport. |
| stack | string | The JGroups stack used for the transport. |
20.8. Monitor JBoss Enterprise Application Platform 6 Applications Using Library Mode Copy linkLink copied to clipboard!
20.8.1. Prerequisites Copy linkLink copied to clipboard!
- A correctly configured instance of JBoss Operations Network (JON) 3.1.x or better.
- A running instance of JBoss Operations Network (JON) Agent on the server where the application will run. For more information, see Section 20.4, “JBoss Operations Network Agent”
- An operational instance of the RHQ agent with a full JDK. Ensure that the agent has access to the
tools.jarfile from the JDK in particular. In the JBoss Operations Network (JON) agent's environment file (bin/rhq-env.sh), set the value of theRHQ_AGENT_JAVA_HOMEproperty to a full JDK. - The RHQ agent must have been initiated using the same user as the JBoss Enterprise Application Platform instance. As an example, running the JBoss Operations Network (JON) agent as a user with root privileges and the JBoss Enterprise Application Platform process under a different user does not work as expected and must be avoided.
- An installed JBoss Operations Network (JON) plugin for Library Mode. For more information, see Section 20.6.1, “Installing the JBoss Operations Network Plug-in (Library Mode)”
- A custom application using Red Hat JBoss Data Grid's Library mode. This application must have
jmxStatisticsenabled (either declaratively or programmatically). For more information, see Section 19.4, “Enable JMX for Cache Instances” - The Java Virtual Machine (JVM) must be configured to expose the JMX MBean Server. For the Oracle/Sun JDK, see http://docs.oracle.com/javase/1.5.0/docs/guide/management/agent.html
- A correctly added and configured management user for JBoss Enterprise Application Platform.
20.8.2. Monitor an Application Deployed in Standalone Mode Copy linkLink copied to clipboard!
Procedure 20.4. Monitor an Application Deployed in Standalone Mode
Start the JBoss Enterprise Application Platform Instance
Start the JBoss Enterprise Application Platform instance as follows:- Enter the following command at the command line to add a new option to the standalone configuration file (
/bin/standalone.conf):JAVA_OPTS="$JAVA_OPTS -Dorg.rhq.resourceKey=MyEAP"
JAVA_OPTS="$JAVA_OPTS -Dorg.rhq.resourceKey=MyEAP"Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Start the JBoss Enterprise Application Platform instance in standalone mode as follows:
$JBOSS_HOME/bin/standalone.sh
$JBOSS_HOME/bin/standalone.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Run JBoss Operations Network (JON) Discovery
Run thediscovery --fullcommand in the JBoss Operations Network (JON) agent.Locate Application Server Process
In the JBoss Operations Network (JON) web interface, the JBoss Enterprise Application Platform 6 process is listed as a JMX server.Import the Process Into Inventory
Import the process into the JBoss Operations Network (JON) inventory.Deploy the Red Hat JBoss Data Grid Application
Deploy the WAR file that contains the JBoss Data Grid Library mode application withglobalJmxStatisticsandjmxStatisticsenabled.Optional: Run Discovery Again
If required, run thediscovery --fullcommand again to discover the new resources.
The JBoss Data Grid Library mode application is now deployed in JBoss Enterprise Application Platform's standalone mode and can be monitored using the JBoss Operations Network (JON).
20.8.3. Monitor an Application Deployed in Domain Mode Copy linkLink copied to clipboard!
Procedure 20.5. Monitor an Application Deployed in Domain Mode
Edit the Host Configuration
Edit thedomain/configuration/host.xmlfile to replace theserverelement with the following configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Start JBoss Enterprise Application Platform 6
Start JBoss Enterprise Application Platform 6 in domain mode:$JBOSS_HOME/bin/domain.sh
$JBOSS_HOME/bin/domain.shCopy to Clipboard Copied! Toggle word wrap Toggle overflow Deploy the Red Hat JBoss Data Grid Application
Deploy the WAR file that contains the JBoss Data Grid Library mode application withglobalJmxStatisticsandjmxStatisticsenabled.Run Discovery in JBoss Operations Network (JON)
If required, run thediscovery --fullcommand for the JBoss Operations Network (JON) agent to discover the new resources.
The JBoss Data Grid Library mode application is now deployed in JBoss Enterprise Application Platform's domain mode and can be monitored using the JBoss Operations Network (JON).
20.9. JBoss Operations Network Plug-in Quickstart Copy linkLink copied to clipboard!
20.10. Other Management Tools and Operations Copy linkLink copied to clipboard!
20.10.1. Accessing Data via URLs Copy linkLink copied to clipboard!
put() and post() methods place data in the cache, and the URL used determines the cache name and key(s) used. The data is the value placed into the cache, and is placed in the body of the request.
GET and HEAD methods are used for data retrieval while other headers control cache settings and behavior.
Note
20.10.2. Limitations of Map Methods Copy linkLink copied to clipboard!
Map methods, such as size(), values(), keySet() and entrySet(), can be used with certain limitations with Red Hat JBoss Data Grid as they are unreliable. These methods do not acquire locks (global or local) and concurrent modification, additions and removals are excluded from consideration in these calls. Furthermore, the listed methods are only operational on the local data container and do not provide a global view of state.
Part X. Command Line Tools Copy linkLink copied to clipboard!
Chapter 21. Red Hat JBoss Data Grid CLI Copy linkLink copied to clipboard!
infinispan-cli-server-$VERSION.jar) includes an interpreter for commands and must be included in the application.
21.1. Start the CLI (Server) Copy linkLink copied to clipboard!
standalone and cluster files. For Linux, use the standlaone.sh or clustered.sh script and for Windows, use the standalone.bat or clustered.bat file.
21.2. Start the CLI (Client) Copy linkLink copied to clipboard!
ispn-cli file at bin/. For Linux, run bin/ispn-cli.sh and for Windows, run bin/ispn-cli.bat.
21.3. CLI Client Switches for the Command Line Copy linkLink copied to clipboard!
| Short Option | Long Option | Description |
|---|---|---|
| -c | --connect=${URL} | Connects to a running Red Hat JBoss Data Grid instance. For example, for JMX over RMI use jmx://[username[:password]]@host:port[/container[/cache]] and for JMX over JBoss Remoting use remoting://[username[:password]]@host:port[/container[/cache]] |
| -f | --file=${FILE} | Read the input from the specified file rather than using interactive mode. If the value is set to - then the stdin is used as the input. |
| -h | --help | Displays the help information. |
| -v | --version | Displays the CLI version information. |
21.4. Connect to the Application Copy linkLink copied to clipboard!
[disconnected//]> connect jmx://localhost:12000 [jmx://localhost:12000/MyCacheManager/>
[disconnected//]> connect jmx://localhost:12000
[jmx://localhost:12000/MyCacheManager/>
Note
12000 depends on the value the JVM is started with. For example, starting the JVM with the -Dcom.sun.management.jmxremote.port=12000 command line parameter uses this port, but otherwise a random port is chosen. When the remoting protocol (remoting://localhost:9999) is used, the Red Hat JBoss Data Grid server administration port is used (the default is port 9999).
CacheManager.
cache command to select a cache before performing cache operations. The CLI supports tab completion, therefore using the cache and pressing the tab button displays a list of active caches:
[[jmx://localhost:12000/MyCacheManager/> cache ___defaultcache namedCache [jmx://localhost:12000/MyCacheManager/]> cache ___defaultcache [jmx://localhost:12000/MyCacheManager/___defaultcache]>
[[jmx://localhost:12000/MyCacheManager/> cache
___defaultcache namedCache
[jmx://localhost:12000/MyCacheManager/]> cache ___defaultcache
[jmx://localhost:12000/MyCacheManager/___defaultcache]>
21.5. Stopping a Red Hat JBoss Data Grid Instance with the CLI Copy linkLink copied to clipboard!
When running a Red Hat JBoss Data Grid instance in a container as a library mode deployment, the life cycle of JBoss Data Grid is bound to the life cycle of the user deployment.
A remote client-server JBoss Data Grid instance can be stopped using the following script:
jboss-datagrid-6.2.0-server/bin/init.d/jboss-datagrid.sh stop
jboss-datagrid-6.2.0-server/bin/init.d/jboss-datagrid.sh stop
kill commands directly:
kill -15 $pid # send the TERM signal
kill -15 $pid # send the TERM signal
PID is still there, use the following:
kill -9 $pid
kill -9 $pid
21.6. CLI Commands Copy linkLink copied to clipboard!
21.6.1. The abort Command Copy linkLink copied to clipboard!
abort command aborts a running batch initiated using the start command. Batching must be enabled for the specified cache. The following is a usage example:
[jmx://localhost:12000/MyCacheManager/namedCache]> start [jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> abort [jmx://localhost:12000/MyCacheManager/namedCache]> get a null
[jmx://localhost:12000/MyCacheManager/namedCache]> start
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> abort
[jmx://localhost:12000/MyCacheManager/namedCache]> get a
null
21.6.2. The begin Command Copy linkLink copied to clipboard!
begin command starts a transaction. This command requires transactions enabled for the cache it targets. An example of this command's usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> begin [jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> put b b [jmx://localhost:12000/MyCacheManager/namedCache]> commit
[jmx://localhost:12000/MyCacheManager/namedCache]> begin
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> put b b
[jmx://localhost:12000/MyCacheManager/namedCache]> commit
21.6.3. The cache Command Copy linkLink copied to clipboard!
cache command specifies the default cache used for all subsequent operations. If invoked without any parameters, it shows the currently selected cache. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> cache ___defaultcache [jmx://localhost:12000/MyCacheManager/___defaultcache]> cache ___defaultcache [jmx://localhost:12000/MyCacheManager/___defaultcache]>
[jmx://localhost:12000/MyCacheManager/namedCache]> cache ___defaultcache
[jmx://localhost:12000/MyCacheManager/___defaultcache]> cache
___defaultcache
[jmx://localhost:12000/MyCacheManager/___defaultcache]>
21.6.4. The clear Command Copy linkLink copied to clipboard!
clear command clears all content from the cache. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> clear [jmx://localhost:12000/MyCacheManager/namedCache]> get a null
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> clear
[jmx://localhost:12000/MyCacheManager/namedCache]> get a
null
21.6.5. The commit Command Copy linkLink copied to clipboard!
commit command commits changes to an ongoing transaction. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> begin [jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> put b b [jmx://localhost:12000/MyCacheManager/namedCache]> commit
[jmx://localhost:12000/MyCacheManager/namedCache]> begin
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> put b b
[jmx://localhost:12000/MyCacheManager/namedCache]> commit
21.6.6. The container Command Copy linkLink copied to clipboard!
container command selects the default cache container (cache manager). When invoked without any parameters, it lists all available containers. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> container MyCacheManager OtherCacheManager [jmx://localhost:12000/MyCacheManager/namedCache]> container OtherCacheManager [jmx://localhost:12000/OtherCacheManager/]>
[jmx://localhost:12000/MyCacheManager/namedCache]> container
MyCacheManager OtherCacheManager
[jmx://localhost:12000/MyCacheManager/namedCache]> container OtherCacheManager
[jmx://localhost:12000/OtherCacheManager/]>
21.6.7. The create Command Copy linkLink copied to clipboard!
create command creates a new cache based on the configuration of an existing cache definition. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> create newCache like namedCache [jmx://localhost:12000/MyCacheManager/namedCache]> cache newCache [jmx://localhost:12000/MyCacheManager/newCache]>
[jmx://localhost:12000/MyCacheManager/namedCache]> create newCache like namedCache
[jmx://localhost:12000/MyCacheManager/namedCache]> cache newCache
[jmx://localhost:12000/MyCacheManager/newCache]>
21.6.8. The disconnect Command Copy linkLink copied to clipboard!
disconnect command disconnects the currently active connection, which allows the CLI to connect to another instance. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> disconnect [disconnected//]
[jmx://localhost:12000/MyCacheManager/namedCache]> disconnect
[disconnected//]
21.6.9. The encoding Command Copy linkLink copied to clipboard!
encoding command sets a default codec to use when reading and writing entries to and from a cache. If invoked with no arguments, the currently selected codec is displayed. An example of its usage is as follows:
21.6.10. The end Command Copy linkLink copied to clipboard!
end command ends a running batch initiated using the start command. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> start [jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> end [jmx://localhost:12000/MyCacheManager/namedCache]> get a a
[jmx://localhost:12000/MyCacheManager/namedCache]> start
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> end
[jmx://localhost:12000/MyCacheManager/namedCache]> get a
a
21.6.11. The evict Command Copy linkLink copied to clipboard!
evict command evicts an entry associated with a specific key from the cache. An example of it usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> evict a
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> evict a
21.6.12. The get Command Copy linkLink copied to clipboard!
get command shows the value associated with a specified key. For primitive types and Strings, the get command prints the default representation. For other objects, a JSON representation of the object is printed. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> get a a
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> get a
a
21.6.13. The info Command Copy linkLink copied to clipboard!
info command displaysthe configuration of a selected cache or container. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> info
GlobalConfiguration{asyncListenerExecutor=ExecutorFactoryConfiguration{factory=org.infinispan.executors.DefaultExecutorFactory@98add58}, asyncTransportExecutor=ExecutorFactoryConfiguration{factory=org.infinispan.executors.DefaultExecutorFactory@7bc9c14c}, evictionScheduledExecutor=ScheduledExecutorFactoryConfiguration{factory=org.infinispan.executors.DefaultScheduledExecutorFactory@7ab1a411}, replicationQueueScheduledExecutor=ScheduledExecutorFactoryConfiguration{factory=org.infinispan.executors.DefaultScheduledExecutorFactory@248a9705}, globalJmxStatistics=GlobalJmxStatisticsConfiguration{allowDuplicateDomains=true, enabled=true, jmxDomain='jboss.infinispan', mBeanServerLookup=org.jboss.as.clustering.infinispan.MBeanServerProvider@6c0dc01, cacheManagerName='local', properties={}}, transport=TransportConfiguration{clusterName='ISPN', machineId='null', rackId='null', siteId='null', strictPeerToPeer=false, distributedSyncTimeout=240000, transport=null, nodeName='null', properties={}}, serialization=SerializationConfiguration{advancedExternalizers={1100=org.infinispan.server.core.CacheValue$Externalizer@5fabc91d, 1101=org.infinispan.server.memcached.MemcachedValue$Externalizer@720bffd, 1104=org.infinispan.server.hotrod.ServerAddress$Externalizer@771c7eb2}, marshaller=org.infinispan.marshall.VersionAwareMarshaller@6fc21535, version=52, classResolver=org.jboss.marshalling.ModularClassResolver@2efe83e5}, shutdown=ShutdownConfiguration{hookBehavior=DONT_REGISTER}, modules={}, site=SiteConfiguration{localSite='null'}}
[jmx://localhost:12000/MyCacheManager/namedCache]> info
GlobalConfiguration{asyncListenerExecutor=ExecutorFactoryConfiguration{factory=org.infinispan.executors.DefaultExecutorFactory@98add58}, asyncTransportExecutor=ExecutorFactoryConfiguration{factory=org.infinispan.executors.DefaultExecutorFactory@7bc9c14c}, evictionScheduledExecutor=ScheduledExecutorFactoryConfiguration{factory=org.infinispan.executors.DefaultScheduledExecutorFactory@7ab1a411}, replicationQueueScheduledExecutor=ScheduledExecutorFactoryConfiguration{factory=org.infinispan.executors.DefaultScheduledExecutorFactory@248a9705}, globalJmxStatistics=GlobalJmxStatisticsConfiguration{allowDuplicateDomains=true, enabled=true, jmxDomain='jboss.infinispan', mBeanServerLookup=org.jboss.as.clustering.infinispan.MBeanServerProvider@6c0dc01, cacheManagerName='local', properties={}}, transport=TransportConfiguration{clusterName='ISPN', machineId='null', rackId='null', siteId='null', strictPeerToPeer=false, distributedSyncTimeout=240000, transport=null, nodeName='null', properties={}}, serialization=SerializationConfiguration{advancedExternalizers={1100=org.infinispan.server.core.CacheValue$Externalizer@5fabc91d, 1101=org.infinispan.server.memcached.MemcachedValue$Externalizer@720bffd, 1104=org.infinispan.server.hotrod.ServerAddress$Externalizer@771c7eb2}, marshaller=org.infinispan.marshall.VersionAwareMarshaller@6fc21535, version=52, classResolver=org.jboss.marshalling.ModularClassResolver@2efe83e5}, shutdown=ShutdownConfiguration{hookBehavior=DONT_REGISTER}, modules={}, site=SiteConfiguration{localSite='null'}}
21.6.14. The locate Command Copy linkLink copied to clipboard!
locate command displays the physical location of a specified entry in a distributed cluster. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> locate a [host/node1,host/node2]
[jmx://localhost:12000/MyCacheManager/namedCache]> locate a
[host/node1,host/node2]
21.6.15. The put Command Copy linkLink copied to clipboard!
put command inserts an entry into the cache. If a mapping exists for a key, the put command overwrites the old value. The CLI allows control over the type of data used to store the key and value. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> put b 100
[jmx://localhost:12000/MyCacheManager/namedCache]> put c 4139l
[jmx://localhost:12000/MyCacheManager/namedCache]> put d true
[jmx://localhost:12000/MyCacheManager/namedCache]> put e { "package.MyClass": {"i": 5, "x": null, "b": true } }
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> put b 100
[jmx://localhost:12000/MyCacheManager/namedCache]> put c 4139l
[jmx://localhost:12000/MyCacheManager/namedCache]> put d true
[jmx://localhost:12000/MyCacheManager/namedCache]> put e { "package.MyClass": {"i": 5, "x": null, "b": true } }
put can specify a life span and maximum idle time value as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a expires 10s [jmx://localhost:12000/MyCacheManager/namedCache]> put a a expires 10m maxidle 1m
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a expires 10s
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a expires 10m maxidle 1m
21.6.16. The replace Command Copy linkLink copied to clipboard!
replace command replaces an existing entry in the cache with a specified new value. An example of its usage is as follows:
21.6.17. The rollback Command Copy linkLink copied to clipboard!
rollback command rolls back any changes made by an ongoing transaction. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> begin [jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> put b b [jmx://localhost:12000/MyCacheManager/namedCache]> rollback
[jmx://localhost:12000/MyCacheManager/namedCache]> begin
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> put b b
[jmx://localhost:12000/MyCacheManager/namedCache]> rollback
21.6.18. The site Command Copy linkLink copied to clipboard!
site command performs administration tasks related to cross-datacenter replication. This command also retrieves information about the status of a site and toggles the status of a site. An example of its usage is as follows:
21.6.19. The start Command Copy linkLink copied to clipboard!
start command initiates a batch of operations. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> start [jmx://localhost:12000/MyCacheManager/namedCache]> put a a [jmx://localhost:12000/MyCacheManager/namedCache]> put b b [jmx://localhost:12000/MyCacheManager/namedCache]> end
[jmx://localhost:12000/MyCacheManager/namedCache]> start
[jmx://localhost:12000/MyCacheManager/namedCache]> put a a
[jmx://localhost:12000/MyCacheManager/namedCache]> put b b
[jmx://localhost:12000/MyCacheManager/namedCache]> end
21.6.20. The stats Command Copy linkLink copied to clipboard!
stats command displays statistics for the cache. An example of its usage is as follows:
21.6.21. The upgrade Command Copy linkLink copied to clipboard!
upgrade command implements the rolling upgrade procedure. For details about rolling upgrades, see the Rolling Upgrades chapter in the Red Hat JBoss Data Grid Developer Guide.
upgrade command's use is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> upgrade --synchronize=hotrod --all [jmx://localhost:12000/MyCacheManager/namedCache]> upgrade --disconnectsource=hotrod --all
[jmx://localhost:12000/MyCacheManager/namedCache]> upgrade --synchronize=hotrod --all
[jmx://localhost:12000/MyCacheManager/namedCache]> upgrade --disconnectsource=hotrod --all
21.6.22. The version Command Copy linkLink copied to clipboard!
version command displays version information for the CLI client and server. An example of its usage is as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> version Client Version 5.2.1.Final Server Version 5.2.1.Final
[jmx://localhost:12000/MyCacheManager/namedCache]> version
Client Version 5.2.1.Final
Server Version 5.2.1.Final
Part XI. Other Red Hat JBoss Data Grid Functions Copy linkLink copied to clipboard!
Chapter 22. Set Up the L1 Cache Copy linkLink copied to clipboard!
22.1. About the L1 Cache Copy linkLink copied to clipboard!
22.2. L1 Cache Configuration Copy linkLink copied to clipboard!
22.2.1. L1 Cache Configuration (Library Mode) Copy linkLink copied to clipboard!
l1 element configures the cache behavior in distributed cache instances. If used with non-distributed caches, this element is ignored.
- The
enabledparameter enables the L1 cache. - The
lifespanparameter sets the maximum life span of an entry when it is placed in the L1 cache.
22.2.2. L1 Cache Configuration (Remote Client-Server Mode) Copy linkLink copied to clipboard!
<distributed-cache l1-lifespan="${VALUE}">
...
</distributed-cache>
<distributed-cache l1-lifespan="${VALUE}">
...
</distributed-cache>
l1-lifespan element is added to a distributed-cache element to enable L1 caching and to set the life span of the L1 cache entries for the cache. This element is only valid for distributed caches.
l1-lifespan is set to 0 or a negative number (-1), L1 caching is disabled. L1 caching is enabled when the l1-lifespan value is greater than 0.
Note
Chapter 23. Set Up Transactions Copy linkLink copied to clipboard!
23.1. About Transactions Copy linkLink copied to clipboard!
23.1.1. About the Transaction Manager Copy linkLink copied to clipboard!
- initiating and concluding transactions
- managing information about each transaction
- coordinating transactions as they operate over multiple resources
- recovering from a failed transaction by rolling back changes
23.1.2. XA Resources and Synchronizations Copy linkLink copied to clipboard!
OK or ABORT. If the Transaction Manager receives OK votes from all XA Resources, the transaction is committed, otherwise it is rolled back.
23.1.3. Optimistic and Pessimistic Transactions Copy linkLink copied to clipboard!
- less messages being sent during the transaction execution
- locks held for shorter periods
- improved throughput
Note
FORCE_WRITE_LOCK flag with the operation.
23.1.4. Write Skew Checks Copy linkLink copied to clipboard!
REPEATABLE_READ isolation level. Also, in clustered mode (distributed or replicated modes), set up entry versioning. For local mode, entry versioning is not required.
Important
23.1.5. Transactions Spanning Multiple Cache Instances Copy linkLink copied to clipboard!
23.2. Configure Transactions Copy linkLink copied to clipboard!
23.2.1. Configure Transactions (Library Mode) Copy linkLink copied to clipboard!
Procedure 23.1. Configure Transactions in Library Mode (XML Configuration)
Set the Transaction Mode
See the table below this procedure for a list of available lookup classes.<namedCache ...> <transaction transactionMode="{TRANSACTIONAL,NON_TRANSACTIONAL}"> ... </namedCache><namedCache ...> <transaction transactionMode="{TRANSACTIONAL,NON_TRANSACTIONAL}"> ... </namedCache>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Transaction Manager
ThetransactionModeelement configures whether or not the cache is transactional.<namedCache ...> <transaction transactionMode="TRANSACTIONAL" transactionManagerLookupClass="{TransactionManagerLookupClass}"> </namedCache><namedCache ...> <transaction transactionMode="TRANSACTIONAL" transactionManagerLookupClass="{TransactionManagerLookupClass}"> </namedCache>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Locking Mode
ThelockingModeparameter determines if the optimistic or pessimistic locking method is used. If the cache is non-transactional, the locking mode is ignored. The default value for this parameter isOPTIMISTIC.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify Synchronization
TheuseSynchronizationelement configures the cache to register a synchronization with the transaction manager, or register itself as an XA resource. The default value for this element istrue(use synchronization).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Recovery
Therecoveryelement enables recovery for the cache when set totrue.TherecoveryInfoCacheNameparameter sets the name of the cache where recovery information is held. The default name of the cache is__recoveryInfoCacheName__.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Write Skew Check
ThewriteSkewcheck determines if a modification to the entry from a different transaction should roll back the transaction. Write skew set totruerequiresisolation_levelset toREPEATABLE_READ. The default value forwriteSkewandisolation_levelarefalseandREAD_COMMITTEDrespectively.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Entry Versioning
For clustered caches, enable write skew check by enabling entry versioning and setting its value toSIMPLE.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Procedure 23.2. Configure Transactions in Library Mode (Programmatic Configuration)
Set the Transaction Mode
Set the transaction mode as follows:Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL);Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Transaction Manager
See the table below this procedure for a list of available lookup classes.Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new GenericTransactionManagerLookup());Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new GenericTransactionManagerLookup());Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Locking Mode
ThelockingModevalue determines whether optimistic or pessimistic locking is used. If the cache is non-transactional, the locking mode is ignored. The default value isOPTIMISTIC.Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new GenericTransactionManagerLookup()); .lockingMode(LockingMode.OPTIMISTIC);Configuration config = new ConfigurationBuilder()/* ... */.transaction() .transactionMode(TransactionMode.TRANSACTIONAL) .transactionManagerLookup(new GenericTransactionManagerLookup()); .lockingMode(LockingMode.OPTIMISTIC);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Specify Synchronization
TheuseSynchronizationvalue configures the cache to register a synchronization with the transaction manager, or register itself as an XA resource. The default value istrue(use synchronization).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Recovery
Therecoveryparameter enables recovery for the cache when set totrue.TherecoveryInfoCacheNamesets the name of the cache where recovery information is held. The default name of the cache is specified byRecoveryConfiguration.DEFAULT_RECOVERY_INFO_CACHE.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Write Skew Check
ThewriteSkewcheck determines if a modification to the entry from a different transaction should roll back the transaction. Write skew set totruerequiresisolation_levelset toREPEATABLE_READ. The default value forwriteSkewandisolation_levelarefalseandREAD_COMMITTEDrespectively.Configuration config = new ConfigurationBuilder()/* ... */.locking() .isolationLevel(IsolationLevel.REPEATABLE_READ).writeSkewCheck(true);Configuration config = new ConfigurationBuilder()/* ... */.locking() .isolationLevel(IsolationLevel.REPEATABLE_READ).writeSkewCheck(true);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Entry Versioning
For clustered caches, enable write skew check by enabling entry versioning and setting its value toSIMPLE.Configuration config = new ConfigurationBuilder()/* ... */.versioning() .enable() .scheme(VersioningScheme.SIMPLE);Configuration config = new ConfigurationBuilder()/* ... */.versioning() .enable() .scheme(VersioningScheme.SIMPLE);Copy to Clipboard Copied! Toggle word wrap Toggle overflow
| Class Name | Details |
|---|---|
| org.infinispan.transaction.lookup.DummyTransactionManagerLookup | Used primarily for testing environments. This testing transaction manager is not for use in a production environment and is severely limited in terms of functionality, specifically for concurrent transactions and recovery. |
| org.infinispan.transaction.lookup.JBossStandaloneJTAManagerLookup | The default transaction manager when Red Hat JBoss Data Grid runs in a standalone environment. It is a fully functional JBoss Transactions based transaction manager that overcomes the functionality limits of the DummyTransactionManager. |
| org.infinispan.transaction.lookup.GenericTransactionManagerLookup | GenericTransactionManagerLookup is used by default when no transaction lookup class is specified. This lookup class is recommended when using JBoss Data Grid with Java EE-compatible environment that provides a TransactionManager interface, and is capable of locating the Transaction Manager in most Java EE application servers. If no transaction manager is located, it defaults to DummyTransactionManager. |
| org.infinispan.transaction.lookup.JBossTransactionManagerLookup | The JbossTransactionManagerLookup finds the standard transaction manager running in the application server. This lookup class uses JNDI to look up the TransactionManager instance, and is recommended when custom caches are being used in JTA transactions. |
23.2.2. Configure Transactions (Remote Client-Server Mode) Copy linkLink copied to clipboard!
23.3. Transaction Recovery Copy linkLink copied to clipboard!
23.3.1. Transaction Recovery Process Copy linkLink copied to clipboard!
Procedure 23.3. The Transaction Recovery Process
- The Transaction Manager creates a list of transactions that require intervention.
- The system administrator, connected to JBoss Data Grid using JMX, is presented with the list of transactions (including transaction IDs) using email or logs. The status of each transaction is either
COMMITTEDorPREPARED. If some transactions are in bothCOMMITTEDandPREPAREDstates, it indicates that the transaction was committed on some nodes while in the preparation state on others. - The System Administrator visually maps the XID received from the Transaction Manager to a JBoss Data Grid internal ID. This step is necessary because the XID (a byte array) cannot be conveniently passed to the JMX tool and then reassembled by JBoss Data Grid without this mapping.
- The system administrator forces the commit or rollback process for a transaction based on the mapped internal ID.
23.3.2. Transaction Recovery Example Copy linkLink copied to clipboard!
Example 23.1. Money Transfer from an Account Stored in a Database to an Account in JBoss Data Grid
- The
TransactionManager.commit()method is invoked to run the two phase commit protocol between the source (the database) and the destination (JBoss Data Grid) resources. - The
TransactionManagertells the database and JBoss Data Grid to initiate the prepare phase (the first phase of a Two Phase Commit).
Note
23.4. Deadlock Detection Copy linkLink copied to clipboard!
disabled by default.
23.4.1. Enable Deadlock Detection Copy linkLink copied to clipboard!
disabled by default but can be enabled and configured for each cache using the namedCache configuration element by adding the following:
<deadlockDetection enabled="true" spinDuration="100"/>
<deadlockDetection enabled="true" spinDuration="100"/>
spinDuration attribute defines how often lock acquisition is attempted within the maximum time allowed to acquire a particular lock (in milliseconds).
Chapter 24. Configure JGroups Copy linkLink copied to clipboard!
24.1. About JGroups Copy linkLink copied to clipboard!
24.2. Configure Red Hat JBoss Data Grid Interface Binding (Remote Client-Server Mode) Copy linkLink copied to clipboard!
24.2.1. Interfaces Copy linkLink copied to clipboard!
link-local: Uses a169.x.x.xor254.x.x.xaddress. This suits the traffic within one box.Copy to Clipboard Copied! Toggle word wrap Toggle overflow site-local: Uses a private IP address, for example192.168.x.x. This prevents extra bandwidth charged from GoGrid, and similar providers.Copy to Clipboard Copied! Toggle word wrap Toggle overflow global: Picks a public IP address. This should be avoided for replication traffic.Copy to Clipboard Copied! Toggle word wrap Toggle overflow non-loopback: Uses the first address found on an active interface that is not a127.x.x.xaddress.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
24.2.2. Binding Sockets Copy linkLink copied to clipboard!
24.2.2.1. Binding a Single Socket Example Copy linkLink copied to clipboard!
socket-binding element.
<socket-binding name="jgroups-udp" ... interface="site-local"/>
<socket-binding name="jgroups-udp" ... interface="site-local"/>
24.2.2.2. Binding a Group of Sockets Example Copy linkLink copied to clipboard!
socket-binding-group element:
default-interface (global), therefore the interface attribute does not need to be specified.
24.2.3. Configure JGroups Socket Binding Copy linkLink copied to clipboard!
Important
24.3. Configure JGroups (Library Mode) Copy linkLink copied to clipboard!
jgroups.xml in the classpath before searching for an absolute path name if it is not found in the classpath.
24.3.1. JGroups Transport Protocols Copy linkLink copied to clipboard!
24.3.1.1. The UDP Transport Protocol Copy linkLink copied to clipboard!
- IP multicasting to send messages to all members of a cluster.
- UDP datagrams for unicast messages, which are sent to a single member.
24.3.1.2. The TCP Transport Protocol Copy linkLink copied to clipboard!
- When sending multicast messages, TCP sends multiple unicast messages.
- When using TCP, each message to all cluster members is sent as multiple unicast messages, or one to each member.
24.3.1.3. Using the TCPPing Protocol Copy linkLink copied to clipboard!
jgroups-tcp.xml includes the MPING protocol, which uses UDP multicast for discovery. When UDP multicast is not available, the MPING protocol, has to be replaced by a different mechanism. The recommended alternative is the TCPPING protocol. The TCPPING configuration contains a static list of IP addresses which are contacted for node discovery.
TCPPING.
24.3.2. Pre-Configured JGroups Files Copy linkLink copied to clipboard!
infinispan-core.jar, and are available on the classpath by default. In order to use one of these files, specify one of these file names instead of using jgroups.xml.
jgroups-udp.xmljgroups-tcp.xmljgroups-ec2.xml
24.3.2.1. jgroups-udp.xml Copy linkLink copied to clipboard!
jgroups-udp.xml is a pre-configured JGroups file in Red Hat JBoss Data Grid. The jgroups-udp.xml configuration
- uses UDP as a transport and UDP multicast for discovery.
- is suitable for large clusters (over 8 nodes).
- is suitable if using Invalidation or Replication modes.
| System Property | Description | Default | Required? |
|---|---|---|---|
| jgroups.udp.mcast_addr | IP address to use for multicast (both for communications and discovery). Must be a valid Class D IP address, suitable for IP multicast. | 228.6.7.8 | No |
| jgroups.udp.mcast_port | Port to use for multicast socket | 46655 | No |
| j jgroups.udp.ip_ttl | Specifies the time-to-live (TTL) for IP multicast packets. The value here refers to the number of network hops a packet is allowed to make before it is dropped | 2 | No |
24.3.2.2. jgroups-tcp.xml Copy linkLink copied to clipboard!
jgroups-tcp.xml is a pre-configured JGroups file in Red Hat JBoss Data Grid. The jgroups-tcp.xml configuration
- uses TCP as a transport and UDP multicast for discovery.
- is generally only used where multicast UDP is not an option.
- TCP does not perform as well as UDP for clusters of eight or more nodes. Clusters of four nodes or fewer result in roughly the same level of performance for both UDP and TCP.
| System Property | Description | Default | Required? |
|---|---|---|---|
| jgroups.tcp.address | IP address to use for the TCP transport. | 127.0.0.1 | No |
| jgroups.tcp.port | Port to use for TCP socket | 7800 | No |
| jgroups.udp.mcast_addr | IP address to use for multicast (for discovery). Must be a valid Class D IP address, suitable for IP multicast. | 228.6.7.8 | No |
| jgroups.udp.mcast_port | Port to use for multicast socket | 46655 | No |
| jgroups.udp.ip_ttl | Specifies the time-to-live (TTL) for IP multicast packets. The value here refers to the number of network hops a packet is allowed to make before it is dropped | 2 | No |
24.3.2.3. jgroups-ec2.xml Copy linkLink copied to clipboard!
jgroups-ec2.xml is a pre-configured JGroups file in Red Hat JBoss Data Grid. The jgroups-ec2.xml configuration
- uses TCP as a transport and S3_PING for discovery.
- is suitable on Amazon EC2 nodes where UDP multicast isn't available.
| System Property | Description | Default | Required? |
|---|---|---|---|
| jgroups.tcp.address | IP address to use for the TCP transport. | 127.0.0.1 | No |
| jgroups.tcp.port | Port to use for TCP socket | 7800 | No |
| jgroups.s3.access_key | The Amazon S3 access key used to access an S3 bucket | Yes | |
| jgroups.s3.secret_access_key | The Amazon S3 secret key used to access an S3 bucket | Yes | |
| jgroups.s3.bucket | Name of the Amazon S3 bucket to use. Must be unique and must already exist | Yes | |
| jgroups.s3.pre_signed_delete_url | The pre-signed URL to be used for the DELETE operation. | Yes | |
| jgroups.s3.pre_signed_put_url | The pre-signed URL to be used for the PUT operation. | Yes | |
| jgroups.s3.prefix | If set, S3_PING searches for a bucket with a name that starts with the prefix value. | No |
24.4. Test Multicast Using JGroups Copy linkLink copied to clipboard!
24.4.1. Testing With Different Red Hat JBoss Data Grid Versions Copy linkLink copied to clipboard!
| Version | Test Case | Details |
|---|---|---|
| JBoss Data Grid 6.0 | Not Available | This version of JBoss Data Grid is based on JBoss Enterprise Application Server 6.0, which does not include the test classes used for this test. |
| JBoss Data Grid 6.0.1 | Not Available | This version of JBoss Data Grid is based on JBoss Enterprise Application Platform 6.0, which does not include the test classes used for this test. |
| JBoss Data Grid 6.1 | Available | This version of JBoss Data Grid is based on JBoss Enterprise Application Platform 6.0.1, but contains a newer version of the JGroups JAR file than the JAR file included in JBoss Enterprise Application Platform. As a result, the test class required for this test is available in the $JBOSS_HOME/modules/org/jgroups/main directory for JBoss Data Grid 6.1. |
| JBoss Data Grid 6.2 | Available | This version of JBoss Data Grid is based on JBoss Enterprise Application Platform 6.1. The JAR file is named according to the version, for example jgroups-3.2.7.Final-redhat-1.jar and is available in the $JBOSS_HOME/modules/system/layers/base/org/jgroups/main directory. |
24.4.2. Testing Multicast Using JGroups Copy linkLink copied to clipboard!
Ensure that the following prerequisites are met before starting the testing procedure.
- Set the
bind_addrvalue to the appropriate IP address for the instance. - For added accuracy, set
mcast_addrandportvalues that are the same as the cluster communication values. - Start two command line terminal windows. Navigate to the location of the JGroups JAR file for one of the two nodes in the first terminal and the same location for the second node in the second terminal.
Procedure 24.1. Test Multicast Using JGroups
Run the Multicast Server on Node One
Run the following command on the command line terminal for the first node:java -cp jgroups.jar org.jgroups.tests.McastReceiverTest -mcast_addr 230.1.2.3 -port 5555 -bind_addr $YOUR_BIND_ADDRESS
java -cp jgroups.jar org.jgroups.tests.McastReceiverTest -mcast_addr 230.1.2.3 -port 5555 -bind_addr $YOUR_BIND_ADDRESSCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the Multicast Server on Node Two
Run the following command on the command line terminal for the second node:java -cp jgroups.jar org.jgroups.tests.McastSenderTest -mcast_addr 230.1.2.3 -port 5555 -bind_addr $YOUR_BIND_ADDRESS
java -cp jgroups.jar org.jgroups.tests.McastSenderTest -mcast_addr 230.1.2.3 -port 5555 -bind_addr $YOUR_BIND_ADDRESSCopy to Clipboard Copied! Toggle word wrap Toggle overflow Transmit Information Packets
Enter information on instance for node two (the node sending packets) and press enter to send the information.View Receives Information Packets
View the information received on the node one instance. The information entered in the previous step should appear here.Confirm Information Transfer
Repeat steps 3 and 4 to confirm all transmitted information is received without dropped packets.Repeat Test for Other Instances
Repeat steps 1 to 4 for each combination of sender and receiver. Repeating the test identifies other instances that are incorrectly configured.
All information packets transmitted from the sender node must appear on the receiver node. If the sent information does not appear as expected, multicast is incorrectly configured in the operating system or the network.
Chapter 25. Use Red Hat Data Grid with Amazon Web Services Copy linkLink copied to clipboard!
25.1. The S3_PING JGroups Discovery Protocol Copy linkLink copied to clipboard!
S3_PING is a discovery protocol that is ideal for use with Amazon's Elastic Compute Cloud (EC2) because EC2 does not allow multicast and therefore MPING is not allowed.
25.2. S3_PING Configuration Options Copy linkLink copied to clipboard!
- In Library mode, use JGroups'
jgroups-ec2.xmlfile (see Section 24.3.2.3, “jgroups-ec2.xml” for details) or use theS3_PINGprotocol. - In Remote Client-Server mode, use JGroups'
S3_PINGprotocol.
S3_PING protocol for clustering to work in Amazon AWS:
- Use Private S3 Buckets. These buckets use Amazon AWS credentials.
- Use Pre-Signed URLs. These pre-assigned URLs are assigned to buckets with private write and public read rights.
- Use Public S3 Buckets. These buckets do not have any credentials.
25.2.1. Using Private S3 Buckets Copy linkLink copied to clipboard!
- List
- Upload/Delete
- View Permissions
- Edit Permissions
S3_PING configuration includes the following properties:
- either the
locationor theprefixproperty to specify the bucket, but not both. If theprefixproperty is set,S3_PINGsearches for a bucket with a name that starts with the prefix value. If a bucket with the prefix at the beginning of the name is found,S3_PINGuses that bucket. If a bucket with the prefix is not found,S3_PINGcreates a bucket using the AWS credentials and names it based on the prefix and a UUID (the naming format is {prefix value}-{UUID}). - the
access_keyandsecret_access_keyproperties for the AWS user.
Note
403 error displays when using this configuration, verify that the properties have the correct values. If the problem persists, confirm that the system time in the EC2 node is correct. Amazon S3 rejects requests with a time stamp that is more than 15 minutes old compared to their server's times for security purposes.
Example 25.1. Start the Red Hat JBoss Data Grid Server with a Private Bucket
bin/clustered.sh -Djboss.bind.address={server_ip_address} -Djboss.bind.address.management={server_ip_address} -Djboss.default.jgroups.stack=s3 -Djgroups.s3.bucket={s3_bucket_name} -Djgroups.s3.access_key={access_key} -Djgroups.s3.secret_access_key={secret_access_key}
bin/clustered.sh -Djboss.bind.address={server_ip_address} -Djboss.bind.address.management={server_ip_address} -Djboss.default.jgroups.stack=s3 -Djgroups.s3.bucket={s3_bucket_name} -Djgroups.s3.access_key={access_key} -Djgroups.s3.secret_access_key={secret_access_key}
- Replace {server_ip_address} with the server's IP address.
- Replace {s3_bucket_name} with the appropriate bucket name.
- Replace {access_key} with the user's access key.
- Replace {secret_access_key} with the user's secret access key.
25.2.2. Using Pre-Signed URLs Copy linkLink copied to clipboard!
S3_PING protocol. This URL points to a unique file and can include a folder path within the bucket.
Note
S3_PING. For example, a path such as my_bucket/DemoCluster/node1 works while a longer path such as my_bucket/Demo/Cluster/node1 will not.
25.2.2.1. Generating Pre-Signed URLs Copy linkLink copied to clipboard!
S3_PING class includes a utility method to generate pre-signed URLs. The last argument for this method is the time when the URL expires expressed in the number of seconds since the Unix epoch (January 1, 1970).
String Url = S3_PING.generatePreSignedUrl("{access_key}", "{secret_access_key}", "{operation}", "{bucket_name}", "{path}", {seconds});
String Url = S3_PING.generatePreSignedUrl("{access_key}", "{secret_access_key}", "{operation}", "{bucket_name}", "{path}", {seconds});
- Replace {operation} with either
PUTorDELETE. - Replace {access_key} with the user's access key.
- Replace {secret_access_key} with the user's secret access key.
- Replace {bucket_name} with the name of the bucket.
- Replace {path} with the desired path to the file within the bucket.
- Replace {seconds} with the number of seconds since the Unix epoch (January 1, 1970) that the path remains valid.
Example 25.2. Generate a Pre-Signed URL
String putUrl = S3_PING.generatePreSignedUrl("access_key", "secret_access_key", "put", "my_bucket", "DemoCluster/node1", 1234567890);
String putUrl = S3_PING.generatePreSignedUrl("access_key", "secret_access_key", "put", "my_bucket", "DemoCluster/node1", 1234567890);
S3_PING configuration includes the pre_signed_put_url and pre_signed_delete_url properties generated by the call to S3_PING.generatePreSignedUrl(). This configuration is more secure than one using private S3 buckets, because the AWS credentials are not stored on each node in the cluster
Note
& characters in the URL must be replaced with its XML entity (&).
25.2.2.2. Set Pre-Signed URLs Using the Command Line Copy linkLink copied to clipboard!
- Enclose the URL in double quotation marks (
""). - In the URL, each occurrence of the ampersand (
&) character must be escaped with a backslash (\)
Example 25.3. Start a JBoss Data Grid Server with a Pre-Signed URL
bin/clustered.sh -Djboss.bind.address={server_ip_address} -Djboss.bind.address.management={server_ip_address} -Djboss.default.jgroups.stack=s3 -Djgroups.s3.pre_signed_put_url="http://{s3_bucket_name}.s3.amazonaws.com/ node1?AWSAccessKeyId={access_key}\&Expires={expiration_time}\&Signature={signature}"-Djgroups.s3.pre_signed_delete_url="http://{s3_bucket_name}.s3.amazonaws.com/ node1?AWSAccessKeyId={access_key}\&Expires={expiration_time}\&Signature={signature}"
bin/clustered.sh -Djboss.bind.address={server_ip_address} -Djboss.bind.address.management={server_ip_address} -Djboss.default.jgroups.stack=s3 -Djgroups.s3.pre_signed_put_url="http://{s3_bucket_name}.s3.amazonaws.com/ node1?AWSAccessKeyId={access_key}\&Expires={expiration_time}\&Signature={signature}"-Djgroups.s3.pre_signed_delete_url="http://{s3_bucket_name}.s3.amazonaws.com/ node1?AWSAccessKeyId={access_key}\&Expires={expiration_time}\&Signature={signature}"
{signatures} values are generated by the S3_PING.generatePreSignedUrl() method. Additionally, the {expiration_time} values are the expiration time for the URL that are passed into the S3_PING.generatePreSignedUrl() method.
25.2.3. Using Public S3 Buckets Copy linkLink copied to clipboard!
location property must be specified with the bucket name for this configuration. This configuration method is the least secure because any user who knows the name of the bucket can upload and store data in the bucket and the bucket creator's account is charged for this data.
bin/clustered.sh -Djboss.bind.address={server_ip_address} -Djboss.bind.address.management={server_ip_address} -Djboss.default.jgroups.stack=s3 -Djgroups.s3.bucket={s3_bucket_name}
bin/clustered.sh -Djboss.bind.address={server_ip_address} -Djboss.bind.address.management={server_ip_address} -Djboss.default.jgroups.stack=s3 -Djgroups.s3.bucket={s3_bucket_name}
25.2.4. Troubleshooting S3_PING Warnings Copy linkLink copied to clipboard!
S3_PING configuration type used, the following warnings may appear when starting the JBoss Data Grid Server:
15:46:03,468 WARN [org.jgroups.conf.ProtocolConfiguration] (MSC service thread 1-7) variable "${jgroups.s3.pre_signed_put_url}" in S3_PING could not be substituted; pre_signed_put_url is removed from properties
15:46:03,468 WARN [org.jgroups.conf.ProtocolConfiguration] (MSC service thread 1-7) variable "${jgroups.s3.pre_signed_put_url}" in S3_PING could not be substituted; pre_signed_put_url is removed from properties
15:46:03,469 WARN [org.jgroups.conf.ProtocolConfiguration] (MSC service thread 1-7) variable "${jgroups.s3.prefix}" in S3_PING could not be substituted; prefix is removed from properties
15:46:03,469 WARN [org.jgroups.conf.ProtocolConfiguration] (MSC service thread 1-7) variable "${jgroups.s3.prefix}" in S3_PING could not be substituted; prefix is removed from properties
15:46:03,469 WARN [org.jgroups.conf.ProtocolConfiguration] (MSC service thread 1-7) variable "${jgroups.s3.pre_signed_delete_url}" in S3_PING could not be substituted; pre_signed_delete_url is removed from properties
15:46:03,469 WARN [org.jgroups.conf.ProtocolConfiguration] (MSC service thread 1-7) variable "${jgroups.s3.pre_signed_delete_url}" in S3_PING could not be substituted; pre_signed_delete_url is removed from properties
S3_PING configuration.
Chapter 26. High Availability Using Server Hinting Copy linkLink copied to clipboard!
machineId, rackId, or siteId in the transport configuration will trigger the use of TopologyAwareConsistentHashFactory, which is the equivalent of the DefaultConsistentHashFactory with Server Hinting enabled.
26.1. Establishing Server Hinting with JGroups Copy linkLink copied to clipboard!
26.2. Configure Server Hinting (Remote Client-Server Mode) Copy linkLink copied to clipboard!
transport element for the default stack, as follows:
Procedure 26.1. Configure Server Hinting in Remote Client-Server Mode
Find the JGroups Subsystem Configuration
<subsystem xmlns="urn:jboss:domain:jgroups:1.1" default-stack="${jboss.default.jgroups.stack:udp}"> <stack name="udp"><subsystem xmlns="urn:jboss:domain:jgroups:1.1" default-stack="${jboss.default.jgroups.stack:udp}"> <stack name="udp">Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enable Server Hinting via the
transportElementSet the Site ID
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Rack ID
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set the Machine ID
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
26.3. Configure Server Hinting (Library Mode) Copy linkLink copied to clipboard!
Procedure 26.2. Configure Server Hinting for Library Mode
Set the
clusterNameAttributeTheclusterNameattribute specifies the name assigned to the cluster.<transport clusterName = "MyCluster" />
<transport clusterName = "MyCluster" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
machineIdThemachineIdattribute specifies the JVM instance that contains the original data. This is particularly useful for nodes with multiple JVMs and physical hosts with multiple virtual hosts.<transport clusterName = "MyCluster" machineId = "LinuxServer01" /><transport clusterName = "MyCluster" machineId = "LinuxServer01" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
rackIdTherackIdparameter specifies the rack that contains the original data, so that other racks are used for backups.<transport clusterName = "MyCluster" machineId = "LinuxServer01" rackId = "Rack01" /><transport clusterName = "MyCluster" machineId = "LinuxServer01" rackId = "Rack01" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the
siteIdThesiteIdparameter differentiates between nodes in different data centers replicating to each other.<transport clusterName = "MyCluster" machineId = "LinuxServer01" rackId = "Rack01" siteId = "US-WestCoast" /><transport clusterName = "MyCluster" machineId = "LinuxServer01" rackId = "Rack01" siteId = "US-WestCoast" />Copy to Clipboard Copied! Toggle word wrap Toggle overflow
machineId, rackId, or siteId are included in the configuration, TopologyAwareConsistentHashFactory is selected automatically, enabling Server Hinting. However, if Server Hinting is not configured, JBoss Data Grid's distribution algorithms are allowed to store replications in the same physical machine/rack/data center as the original data.
26.4. ConsistentHashFactories Copy linkLink copied to clipboard!
DefaultConsistentHashFactory- keeps segments balanced evenly across all the nodes, however the key mapping is not guaranteed to be same across caches,as this depends on the history of each cache.SyncConsistentHashFactory- guarantees that the key mapping is the same for each cache, provided the current membership is the same. This has a drawback in that a node joining the cache can cause the existing nodes to also exchange segments, resulting in either additional state transfer traffic, the distribution of the data becoming less even, or both.TopologyAwareConsistentHashFactory- equivalent ofDefaultConsistentHashFactory, but with server hinting enabled.TopologyAwareSyncConsistentHashFactory- equivalent ofSyncConsistentHashFactory, but with server hinting enabled.
<hash consistentHashFactory="org.infinispan.distribution.ch.TopologyAwareSyncConsistentHashFactory"/>
<hash consistentHashFactory="org.infinispan.distribution.ch.TopologyAwareSyncConsistentHashFactory"/>
machineId, rackId, or siteId attributes are specified in the transport configuration it also spreads backup copies across physical machines/racks/data centers.
26.4.1. Implementing a ConsistentHashFactory Copy linkLink copied to clipboard!
ConsistentHashFactory must implement the org.infinispan.distribution.ch.ConsistenHashFactory interface with the following methods (all of which return an implementation of org.infinispan.distribution.ch.ConsistentHash):
ConsistentHashFactory implementations.
Chapter 27. Set Up Cross-Datacenter Replication Copy linkLink copied to clipboard!
27.1. About Cross-Datacenter Replication Copy linkLink copied to clipboard!
RELAY2 protocol.
27.2. Cross-Datacenter Replication Operations Copy linkLink copied to clipboard!
Figure 27.1. Cross-Datacenter Replication Example
LON, NYC and SFO. Each site hosts a running JBoss Data Grid cluster made up of three to four physical nodes.
Users cache is active in all three sites. Changes to the Users cache at the LON site is replicated at the other two sites. The Orders cache, however, is only available locally at the LON site because it is not replicated to the other sites.
Users cache can use different replication mechanisms each site. For example, it can back up data synchronously to SFO and asynchronously to NYC and LON.
Users cache can also have a different configuration from one site to another. For example, it can be configured as a distributed cache with numOwners set to 2 in the LON site, as a replicated cache in the NYC site and as a distributed cache with numOwners set to 1 in the SFO site.
RELAY2 facilitates communication between sites. For more information, see Section B.4, “About RELAY2”
27.3. Configure Cross-Datacenter Replication Copy linkLink copied to clipboard!
27.3.1. Configure Cross-Datacenter Replication (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Procedure 27.1. Set Up Cross-Datacenter Replication
Set Up RELAY
Add the following configuration to thestandalone.xmlfile to set upRELAY:Copy to Clipboard Copied! Toggle word wrap Toggle overflow TheRELAYprotocol creates an additional stack (running parallel to the existingTCPstack) to communicate with the remote site. If aTCPbased stack is used for the local cluster, twoTCPbased stack configurations are required: one for local communication and one to connect to the remote site. For an illustration, see Section 27.2, “Cross-Datacenter Replication Operations”Set Up Sites
Use the following configuration in thestandalone.xmlfile to set up sites for each distributed cache in the cluster:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Local Site Transport
Add the name of the local site in thetransportelement to configure transport:<transport executor="infinispan-transport" lock-timeout="60000" cluster="LON" stack="udp"/><transport executor="infinispan-transport" lock-timeout="60000" cluster="LON" stack="udp"/>Copy to Clipboard Copied! Toggle word wrap Toggle overflow
27.3.2. Configure Cross-Data Replication (Library Mode) Copy linkLink copied to clipboard!
27.3.2.1. Configure Cross-Datacenter Replication Declaratively Copy linkLink copied to clipboard!
relay.RELAY2 protocol creates an additional stack (running parallel to the existing TCP stack) to communicate with the remote site. If a TCP-based stack is used for the local cluster, two TCP based stack configurations are required: one for local communication and one to connect to the remote site.
Procedure 27.2. Setting Up Cross-Datacenter Replication
Configure the Local Site
Add thesiteelement to theglobalelement to add the local site (in this example, the local site is namedLON).Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure JGroups for the Local Site
Cross-site replication requires a non-default JGroups configuration. Add thetransportelement and set up the path to the configuration file as theconfigurationFileproperty. In this example, the JGroups configuration file is namedjgroups-with-relay.xml.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the LON Cache
Configure the cache in siteLONto back up to the sitesNYCandSFO:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Back Up Caches
- Configure the cache in site
NYCto receive back up data fromLON:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Configure the cache in site
SFOto receive back up data fromLON:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Add the Contents of the Configuration File
As a default, Red Hat JBoss Data Grid includes JGroups configuration files such asjgroups-tcp.xmlandjgroups-udp.xmlin theinfinispan-core-{VERSION}.jarpackage.Copy the JGroups configuration to a new file (in this example, it is namedjgroups-with-relay.xml) and add the provided configuration information to this file. Note that therelay.RELAY2protocol configuration must be the last protocol in the configuration stack.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the relay.xml File
Set up therelay.RELAY2configuration in therelay.xmlfile. This file describes the global cluster configuration.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Global Cluster
The filejgroups-global.xmlreferenced inrelay.xmlcontains another JGroups configuration which is used for the global cluster: communication between sites.The global cluster configuration is usuallyTCP-based and uses theTCPPINGprotocol (instead ofPINGorMPING) to discover members. Copy the contents ofjgroups-tcp.xmlintojgroups-global.xmland add the following configuration in order to configureTCPPING:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the hostnames (or IP addresses) inTCPPING.initial_hostswith those used for your site masters. The ports (7800in this example) must match theTCP.bind_port.For more information about theTCPPINGprotocol, see Section 24.3.1.3, “Using the TCPPing Protocol”
27.3.2.2. Configure Cross-Datacenter Replication Programmatically Copy linkLink copied to clipboard!
Procedure 27.3. Configure Cross-Datacenter Replication Programmatically
Identify the Node Location
Declare the site the node resides in:globalConfiguration.site().localSite("LON");globalConfiguration.site().localSite("LON");Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure JGroups
Configure JGroups to use theRELAYprotocol:globalConfiguration.transport().addProperty("configurationFile", jgroups-with-relay.xml);globalConfiguration.transport().addProperty("configurationFile", jgroups-with-relay.xml);Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set Up the Remote Site
Set up JBoss Data Grid caches to replicate to the remote site:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Configure the Backup Caches
JBoss Data Grid implicitly replicates data to a cache with same name as the remote site. If a backup cache on the remote site has a different name, users must specify abackupForcache to ensure data is replicated to the correct cache.Note
This step is optional and only required if the remote site's caches are named differently from the original caches.- Configure the cache in site
NYCto receive backup data fromLON:ConfigurationBuilder NYCbackupOfLon = new ConfigurationBuilder(); lonBackup.sites().backupFor().remoteCache("lon").remoteSite("LON");ConfigurationBuilder NYCbackupOfLon = new ConfigurationBuilder(); lonBackup.sites().backupFor().remoteCache("lon").remoteSite("LON");Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Configure the cache in site
SFOto receive backup data fromLON:ConfigurationBuilder SFObackupOfLon = new ConfigurationBuilder(); lonBackup.sites().backupFor().remoteCache("lon").remoteSite("LON");ConfigurationBuilder SFObackupOfLon = new ConfigurationBuilder(); lonBackup.sites().backupFor().remoteCache("lon").remoteSite("LON");Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Add the Contents of the Configuration File
As a default, Red Hat JBoss Data Grid includes JGroups configuration files such asjgroups-tcp.xmlandjgroups-udp.xmlin theinfinispan-core-{VERSION}.jarpackage.Copy the JGroups configuration to a new file (in this example, it is namedjgroups-with-relay.xml) and add the provided configuration information to this file. Note that therelay.RELAY2protocol configuration must be the last protocol in the configuration stack.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the relay.xml File
Set up therelay.RELAY2configuration in therelay.xmlfile. This file describes the global cluster configuration.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the Global Cluster
The filejgroups-global.xmlreferenced inrelay.xmlcontains another JGroups configuration which is used for the global cluster: communication between sites.The global cluster configuration is usuallyTCP-based and uses theTCPPINGprotocol (instead ofPINGorMPING) to discover members. Copy the contents ofjgroups-tcp.xmlintojgroups-global.xmland add the following configuration in order to configureTCPPING:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the hostnames (or IP addresses) inTCPPING.initial_hostswith those used for your site masters. The ports (7800in this example) must match theTCP.bind_port.For more information about theTCPPINGprotocol, see Section 24.3.1.3, “Using the TCPPing Protocol”
27.4. Taking a Site Offline Copy linkLink copied to clipboard!
- Configure automatically taking a site offline:
- Declaratively in Remote Client-Server mode.
- Declaratively in Library mode.
- Using the programmatic method.
- Manually taking a site offline:
- Using JBoss Operations Network (JON).
- Using the JBoss Data Grid Command Line Interface (CLI).
27.4.1. Taking a Site Offline (Remote Client-Server Mode) Copy linkLink copied to clipboard!
take-offline element is added to the backup element to configure when a site is automatically taken offline. An example of this configuration is as follows:
<backup>
<take-offline after-failures="${NUMBER}"
min-wait="${PERIOD}" />
</backup>
<backup>
<take-offline after-failures="${NUMBER}"
min-wait="${PERIOD}" />
</backup>
take-offline element use the following parameters to configure when to take a site offline:
- The
after-failuresparameter specifies the number of times attempts to contact a site can fail before the site is taken offline. - The
min-waitparameter specifies the number (in milliseconds) to wait to mark an unresponsive site as offline. The site is offline when themin-waitperiod elapses after the first attempt, and the number of failed attempts specified in theafter-failuresparameter occur.
27.4.2. Taking a Site Offline (Library Mode) Copy linkLink copied to clipboard!
backupFor element after defining all back up sites within the backups element:
<backup>
<takeOffline afterFailures="${NUM}"
minTimeToWait="${PERIOD}"/>
</backup>
<backup>
<takeOffline afterFailures="${NUM}"
minTimeToWait="${PERIOD}"/>
</backup>
takeOffline element to the backup element to configure automatically taking a site offline.
- The
afterFailuresparameter specifies the number of times attempts to contact a site can fail before the site is taken offline. The default value (0) allows an infinite number of failures ifminTimeToWaitis less than0. If theminTimeToWaitis not less than0,afterFailuresbehaves as if the value is negative. A negative value for this parameter indicates that the site is taken offline after the time specified byminTimeToWaitelapses. - The
minTimeToWaitparameter specifies the number (in milliseconds) to wait to mark an unresponsive site as offline. The site is taken offline after the number attempts specified in theafterFailuresparameter conclude and the time specified byminTimeToWaitafter the first failure has elapsed. If this parameter is set to a value smaller than or equal to0, this parameter is disregarded and the site is taken offline based solely on theafterFailuresparameter.
27.4.3. Taking a Site Offline (Programmatically) Copy linkLink copied to clipboard!
27.4.4. Taking a Site Offline via JBoss Operations Network (JON) Copy linkLink copied to clipboard!
27.4.5. Taking a Site Offline via the CLI Copy linkLink copied to clipboard!
site command.
site command can be used to check the status of a site as follows:
[jmx://localhost:12000/MyCacheManager/namedCache]> site --status ${SITENAME}
[jmx://localhost:12000/MyCacheManager/namedCache]> site --status ${SITENAME}
online or offline according to the current status of the named site.
[jmx://localhost:12000/MyCacheManager/namedCache]> site --offline ${SITENAME}
[jmx://localhost:12000/MyCacheManager/namedCache]> site --offline ${SITENAME}
[jmx://localhost:12000/MyCacheManager/namedCache]> site --online ${SITENAME}
[jmx://localhost:12000/MyCacheManager/namedCache]> site --online ${SITENAME}
ok displays after the command.
27.4.6. Bring a Site Back Online Copy linkLink copied to clipboard!
bringSiteOnline(siteName) operation on the XSiteAdmin MBean. For details about this MBean, see Section A.21, “XSiteAdmin”
27.5. Configure Multiple Site Masters Copy linkLink copied to clipboard!
27.5.1. Multiple Site Master Operations Copy linkLink copied to clipboard!
27.5.2. Configure Multiple Site Masters (Remote Client-Server Mode) Copy linkLink copied to clipboard!
Configure Cross-Datacenter Replication for Red Hat JBoss Data Grid's Remote Client-Server Mode.
Procedure 27.4. Set Multiple Site Masters in Remote Client-Server Mode
Locate the Target Configuration
Locate the target site's configuration in theclustered-xsite.xmlexample configuration file. The sample configuration looks like the following example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Maximum Sites
Use themax_site_mastersproperty to determine the maximum number of master nodes within the site. Set this value to the number of nodes in the site to make every node a master.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Configure Site Master
Use thecan_become_site_masterproperty to allow the node to become the site master. This flag is set totrueas a default. Setting this flag tofalseprevents the node from becoming a site master. This is required in situations where the node does not have a network interface connected to the external network.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
27.5.3. Configure Multiple Site Masters (Library Mode) Copy linkLink copied to clipboard!
Procedure 27.5. Configure Multiple Site Masters (Library Mode)
Configure Cross-Datacenter Replication
Configure Cross-Datacenter Replication in JBoss Data Grid. Use the instructions in Section 27.3.2.1, “Configure Cross-Datacenter Replication Declaratively” for an XML configuration or the instructions in Section 27.3.2.2, “Configure Cross-Datacenter Replication Programmatically” for a programmatic configuration.Add the Contents of the Configuration File
Add thecan_become_site_masterandmax_site_mastersparameters to the configuration as follows:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Set themax_site_mastersvalue to the number of nodes in the cluster to make all nodes masters.
Appendix A. JMX MBeans in RedHat JBoss Data Grid Copy linkLink copied to clipboard!
A.1. Activation Copy linkLink copied to clipboard!
org.infinispan.eviction.ActivationManagerImpl
| Name | Description | Type | Writable |
|---|---|---|---|
| activations | Number of activation events. | String | No |
| statisticsEnabled | Enables or disables the gathering of statistics by this component. | boolean | Yes |
| Name | Description | Signature |
|---|---|---|
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
A.2. Cache Copy linkLink copied to clipboard!
org.infinispan.CacheImpl
| Name | Description | Type | Writable |
|---|---|---|---|
| cacheName | Returns the cache name. | String | No |
| cacheStatus | Returns the cache status. | String | No |
| configurationAsProperties | Returns the cache configuration in form of properties. | java.util.Properties | No |
| version | Returns the version of Infinispan | java.lang.String | No |
| Name | Description | Signature |
|---|---|---|
| start | Starts the cache. | void start() |
| stop | Stops the cache. | void stop() |
| clear | Clears the cache. | void clear() |
A.3. CacheLoader Copy linkLink copied to clipboard!
org.infinispan.interceptors.CacheLoaderInterceptor
| Name | Description | Type | Writable |
|---|---|---|---|
| cacheLoaderLoads | Number of entries loaded from the cache store. | long | No |
| cacheLoaderMisses | Number of entries that did not exist in cache store. | long | No |
| stores | Returns a collection of cache loader types which are configured and enabled. | Collection | No |
| statisticsEnabled | Enables or disables the gathering of statistics by this component. | boolean | Yes |
| Name | Description | Signature |
|---|---|---|
| disableStore | Disable all cache loaders of a given type, where type is a fully qualified class name of the cache loader to disable. | void disableStore(String storeType) |
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
A.4. CacheManager Copy linkLink copied to clipboard!
org.infinispan.manager.DefaultCacheManager
| Name | Description | Type | Writable |
|---|---|---|---|
| cacheManagerStatus | The status of the cache manager instance. | String | No |
| clusterMembers | Lists members in the cluster. | String | No |
| clusterName | Cluster name. | String | No |
| clusterSize | Size of the cluster in the number of nodes. | int | No |
| createdCacheCount | The total number of created caches, including the default cache. | String | No |
| definedCacheCount | The total number of defined caches, excluding the default cache. | String | No |
| definedCacheNames | The defined cache names and their statuses. The default cache is not included in this representation. | String | No |
| name | The name of this cache manager. | String | No |
| nodeAddress | The network address associated with this instance. | String | No |
| physicalAddresses | The physical network addresses associated with this instance. | String | No |
| runningCacheCount | The total number of running caches, including the default cache. | String | No |
| version | Infinispan version. | String | No. |
| Name | Description | Signature |
|---|---|---|
| startCache | Starts the default cache associated with this cache manager. | void startCache() |
| startCache | Starts a named cache from this cache manager. | void startCache (String p0) |
A.5. CacheStore Copy linkLink copied to clipboard!
org.infinispan.interceptors.CacheWriterInterceptor
| Name | Description | Type | Writable |
|---|---|---|---|
| writesToTheStores | Number of writes to the store. | long | No |
| statisticsEnabled | Enables or disables the gathering of statistics by this component. | boolean | Yes |
| Name | Description | Signature |
|---|---|---|
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
A.6. DeadlockDetectingLockManager Copy linkLink copied to clipboard!
org.infinispan.util.concurrent.locks.DeadlockDetectingLockManager
| Name | Description | Type | Writable |
|---|---|---|---|
| detectedLocalDeadlocks | Number of local transactions that were rolled back due to deadlocks. | long | No |
| detectedRemoteDeadlocks | Number of remote transactions that were rolled back due to deadlocks. | long | No |
| overlapWithNotDeadlockAwareLockOwners | Number of situations when we try to determine a deadlock and the other lock owner is NOT a transaction. In this scenario we cannot run the deadlock detection mechanism. | long | No |
| totalNumberOfDetectedDeadlocks | Total number of local detected deadlocks. | long | No |
| concurrencyLevel | The concurrency level that the MVCC Lock Manager has been configured with. | int | No |
| numberOfLocksAvailable | The number of exclusive locks that are available. | int | No |
| numberOfLocksHeld | The number of exclusive locks that are held. | int | No |
| Name | Description | Signature |
|---|---|---|
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
A.7. DistributionManager Copy linkLink copied to clipboard!
org.infinispan.distribution.DistributionManagerImpl
Note
| Name | Description | Signature |
|---|---|---|
| isAffectedByRehash | Determines whether a given key is affected by an ongoing rehash. | boolean isAffectedByRehash(Object p0) |
| isLocatedLocally | Indicates whether a given key is local to this instance of the cache. Only works with String keys. | boolean isLocatedLocally(String p0) |
| locateKey | Locates an object in a cluster. Only works with String keys. | List locateKey(String p0) |
A.8. Interpreter Copy linkLink copied to clipboard!
org.infinispan.cli.interpreter.Interpreter
| Name | Description | Type | Writable |
|---|---|---|---|
| cacheNames | Retrieves a list of caches for the cache manager. | String[] | No |
| Name | Description | Signature |
|---|---|---|
| createSessionId | Creates a new interpreter session. | String createSessionId(String cacheName) |
| execute | Parses and executes IspnCliQL statements. | String execute(String p0, String p1) |
A.9. Invalidation Copy linkLink copied to clipboard!
org.infinispan.interceptors.InvalidationInterceptor
| Name | Description | Type | Writable |
|---|---|---|---|
| invalidations | Number of invalidations. | long | No |
| statisticsEnabled | Enables or disables the gathering of statistics by this component. | boolean | Yes |
| Name | Description | Signature |
|---|---|---|
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
A.10. LockManager Copy linkLink copied to clipboard!
org.infinispan.util.concurrent.locks.LockManagerImpl
| Name | Description | Type | Writable |
|---|---|---|---|
| concurrencyLevel | The concurrency level that the MVCC Lock Manager has been configured with. | int | No |
| numberOfLocksAvailable | The number of exclusive locks that are available. | int | No |
| numberOfLocksHeld | The number of exclusive locks that are held. | int | No |
A.11. LocalTopologyManager Copy linkLink copied to clipboard!
org.infinispan.topology.LocalTopologyManagerImpl
Note
| Name | Description | Type | Writable |
|---|---|---|---|
| rebalancingEnabled | If false, newly started nodes will not join the existing cluster nor will the state be transferred to them. If any of the current cluster members are stopped when rebalancing is disabled, the nodes will leave the cluster but the state will not be rebalanced among the remaining nodes. This will result in fewer copies than specified by the numOwners attribute until rebalancing is enabled again. | boolean | Yes |
A.12. MassIndexer Copy linkLink copied to clipboard!
org.infinispan.query.MassIndexer
| Name | Description | Signature |
|---|---|---|
| start | Starts rebuilding the index. | void start() |
Note
A.13. Passivation Copy linkLink copied to clipboard!
org.infinispan.interceptors.PassivationInterceptor
| Name | Description | Type | Writable |
|---|---|---|---|
| passivations | Number of passivation events. | String | No |
| statisticsEnabled | Enables or disables the gathering of statistics by this component | boolean | Yes |
| Name | Description | Signature |
|---|---|---|
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
A.14. RecoveryAdmin Copy linkLink copied to clipboard!
org.infinispan.transaction.xa.recovery.RecoveryAdminOperations
| Name | Description | Signature |
|---|---|---|
| forceCommit | Forces the commit of an in-doubt transaction. | String forceCommit(long p0) |
| forceCommit | Forces the commit of an in-doubt transaction | String forceCommit(int p0, byte[] p1, byte[] p2) |
| forceRollback | Forces the rollback of an in-doubt transaction. | String forceRollback(long p0) |
| forceRollback | Forces the rollback of an in-doubt transaction | String forceRollback(int p0, byte[] p1, byte[] p2) |
| forget | Removes recovery info for the given transaction. | String forget(long p0) |
| forget | Removes recovery info for the given transaction. | String forget(int p0, byte[] p1, byte[] p2) |
| showInDoubtTransactions | Shows all the prepared transactions for which the originating node crashed. | String showInDoubtTransactions() |
A.15. RollingUpgradeManager Copy linkLink copied to clipboard!
org.infinispan.upgrade.RollingUpgradeManager
| Name | Description | Signature |
|---|---|---|
| disconnectSource | Disconnects the target cluster from the source cluster according to the specified migrator. | void disconnectSource(String p0) |
| recordKnownGlobalKeyset | Dumps the global known keyset to a well-known key for retrieval by the upgrade process. | void recordKnownGlobalKeyset() |
| synchronizeData | Synchronizes data from the old cluster to this using the specified migrator. | long synchronizeData(String p0) |
A.16. RpcManager Copy linkLink copied to clipboard!
org.infinispan.remoting.rpc.RpcManagerImpl
Note
| Name | Description | Type | Writable |
|---|---|---|---|
| averageReplicationTime | The average time spent in the transport layer, in milliseconds. | long | No |
| committedViewAsString | Retrieves the committed view. | String | No |
| pendingViewAsString | Retrieves the pending view. | String | No |
| replicationCount | Number of successful replications. | long | No |
| replicationFailures | Number of failed replications. | long | No |
| successRatio | Successful replications as a ratio of total replications. | String | No |
| successRatioFloatingPoint | Successful replications as a ratio of total replications in numeric double format. | double | No |
| statisticsEnabled | Enables or disables the gathering of statistics by this component. | boolean | Yes |
| Name | Description | Signature |
|---|---|---|
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
| setStatisticsEnabled | Whether statistics should be enabled or disabled (true/false) | void setStatisticsEnabled(boolean enabled) |
A.17. StateTransferManager Copy linkLink copied to clipboard!
org.infinispan.statetransfer.StateTransferManager
Note
| Name | Description | Type | Writable |
|---|---|---|---|
| joinComplete | If true, the node has successfully joined the grid and is considered to hold state. If false, the join process is still in progress.. | boolean | No |
| stateTransferInProgress | Checks whether there is a pending inbound state transfer on this cluster member. | boolean | No |
A.18. Statistics Copy linkLink copied to clipboard!
org.infinispan.interceptors.CacheMgmtInterceptor
| Name | Description | Type | Writable |
|---|---|---|---|
| averageReadTime | Average number of milliseconds for a read operation on the cache. | long | No |
| averageWriteTime | Average number of milliseconds for a write operation in the cache. | long | No |
| elapsedTime | Number of seconds since cache started. | long | No |
| evictions | Number of cache eviction operations. | long | No |
| hitRatio | Percentage hit/(hit+miss) ratio for the cache. | double | No |
| hits | Number of cache attribute hits. | long | No |
| misses | Number of cache attribute misses. | long | No |
| numberOfEntries | Number of entries currently in the cache. | int | No |
| readWriteRatio | Read/writes ratio for the cache. | double | No |
| removeHits | Number of cache removal hits. | long | No |
| removeMisses | Number of cache removals where keys were not found. | long | No |
| stores | Number of cache attribute PUT operations. | long | No |
| timeSinceReset | Number of seconds since the cache statistics were last reset. | long | No |
| Name | Description | Signature |
|---|---|---|
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
A.19. Transactions Copy linkLink copied to clipboard!
org.infinispan.interceptors.TxInterceptor
| Name | Description | Type | Writable |
|---|---|---|---|
| commits | Number of transaction commits performed since last reset. | long | No |
| prepares | Number of transaction prepares performed since last reset. | long | No |
| rollbacks | Number of transaction rollbacks performed since last reset. | long | No |
| statisticsEnabled | Enables or disables the gathering of statistics by this component. | boolean | Yes |
| Name | Description | Signature |
|---|---|---|
| resetStatistics | Resets statistics gathered by this component. | void resetStatistics() |
A.20. Transport Copy linkLink copied to clipboard!
org.infinispan.server.core.transport.NettyTransport
| Name | Description | Type | Writable |
|---|---|---|---|
| hostName | Returns the host to which the transport binds. | String | No |
| idleTimeout | Returns the idle timeout. | String | No |
| numberOfGlobalConnections | Returns a count of active connections in the cluster. This operation will make remote calls to aggregate results, so latency may have an impact on the speed of calculation for this attribute. | Integer | false |
| numberOfLocalConnections | Returns a count of active connections this server. | Integer | No |
| numberWorkerThreads | Returns the number of worker threads. | String | No |
| port | Returns the port to which the transport binds. | String | |
| receiveBufferSize | Returns the receive buffer size. | String | No |
| sendBufferSize | Returns the send buffer size. | String | No |
| totalBytesRead | Returns the total number of bytes read by the server from clients, including both protocol and user information. | String | No |
| totalBytesWritten | Returns the total number of bytes written by the server back to clients, including both protocol and user information. | String | No |
| tcpNoDelay | Returns whether TCP no delay was configured or not. | String | No |
A.21. XSiteAdmin Copy linkLink copied to clipboard!
org.infinispan.xsite.XSiteAdminOperations
| Name | Description | Signature |
|---|---|---|
| bringSiteOnline | Brings the given site back online on all the cluster. | String bringSiteOnline(String p0) |
| amendTakeOffline | Amends the values for 'TakeOffline' functionality on all the nodes in the cluster. | String amendTakeOffline(String p0, int p1, long p2) |
| getTakeOfflineAfterFailures | Returns the value of the 'afterFailures' for the 'TakeOffline' functionality. | String getTakeOfflineAfterFailures(String p0) |
| getTakeOfflineMinTimeToWait | Returns the value of the 'minTimeToWait' for the 'TakeOffline' functionality. | String getTakeOfflineMinTimeToWait(String p0) |
| setTakeOfflineAfterFailures | Amends the values for 'afterFailures' for the 'TakeOffline' functionality on all the nodes in the cluster. | String setTakeOfflineAfterFailures(String p0, int p1) |
| setTakeOfflineMinTimeToWait | Amends the values for 'minTimeToWait' for the 'TakeOffline' functionality on all the nodes in the cluster. | String setTakeOfflineMinTimeToWait(String p0, long p1) |
| siteStatus | Check whether the given backup site is offline or not. | String siteStatus(String p0) |
| status | Returns the the status(offline/online) of all the configured backup sites. | String status() |
| takeSiteOffline | Takes this site offline in all nodes in the cluster. | String takeSiteOffline(String p0) |
Appendix B. References Copy linkLink copied to clipboard!
B.1. About Consistency Copy linkLink copied to clipboard!
B.2. About Consistency Guarantee Copy linkLink copied to clipboard!
- If Key
Kis hashed to nodes{A,B}and transactionTX1acquires a lock forKon, for example, nodeAand - If another cache access occurs on node
B, or any other node, andTX2attempts to lockK, this access attempt fails with a timeout because the transactionTX1already holds a lock onK.
K is always deterministically acquired on the same node of the cluster, irrespective of the transaction's origin.
B.3. About JBoss Cache Copy linkLink copied to clipboard!
B.4. About RELAY2 Copy linkLink copied to clipboard!
RELAY protocol bridges two remote clusters by creating a connection between one node in each site. This allows multicast messages sent out in one site to be relayed to the other and vice versa.
RELAY2 protocol, which is used for communication between sites in Red Hat JBoss Data Grid's Cross-Site Replication.
RELAY2 protocol works similarly to RELAY but with slight differences. Unlike RELAY, the RELAY2 protocol:
- connects more than two sites.
- connects sites that operate autonomously and are unaware of each other.
- offers both unicasts and multicast routing between sites.
B.5. About Return Values Copy linkLink copied to clipboard!
B.6. About Runnable Interfaces Copy linkLink copied to clipboard!
run() method, which executes the active part of the class' code. The Runnable object can be executed in its own thread after it is passed to a thread constructor.
B.7. About Two Phase Commit (2PC) Copy linkLink copied to clipboard!
B.8. About Key-Value Pairs Copy linkLink copied to clipboard!
- A key is unique to a particular data entry and is composed from data attributes of the particular entry it relates to.
- A value is the data assigned to and identified by the key.
B.9. The Externalizer Copy linkLink copied to clipboard!
B.9.1. About Externalizer Copy linkLink copied to clipboard!
Externalizer is a class that can:
- Marshall a given object type to a byte array.
- Unmarshall the contents of a byte array into an instance of the object type.
B.9.2. Internal Externalizer Implementation Access Copy linkLink copied to clipboard!
B.10. Hash Space Allocation Copy linkLink copied to clipboard!
B.10.1. About Hash Space Allocation Copy linkLink copied to clipboard!
B.10.2. Locating a Key in the Hash Space Copy linkLink copied to clipboard!
B.10.3. Requesting a Full Byte Array Copy linkLink copied to clipboard!
As a default, JBoss Data Grid only partially prints byte arrays to logs to avoid unnecessarily printing large byte arrays. This occurs when either:
- JBoss Data Grid caches are configured for lazy deserialization. Lazy deserialization is not available in JBoss Data Grid's Remote Client-Server mode.
- A
MemcachedorHot Rodserver is run.
-Dinfinispan.arrays.debug=true system property at start up.
Example B.1. Partial Byte Array Log
Appendix C. Revision History Copy linkLink copied to clipboard!
| Revision History | ||||||||
|---|---|---|---|---|---|---|---|---|
| Revision 6.2.1-7 | Thu Sep 04 2014 | |||||||
| ||||||||
| Revision 6.2.1-6 | Wed Sep 03 2014 | |||||||
| ||||||||
| Revision 6.2.1-5 | Wed Aug 06 2014 | |||||||
| ||||||||
| Revision 6.2.1-4 | Wed Apr 02 2014 | |||||||
| ||||||||
| Revision 6.2.1-3 | Tue Mar 11 2014 | |||||||
| ||||||||
| Revision 6.2.1-2 | Thu Mar 06 2014 | |||||||
| ||||||||
| Revision 6.2.1-1 | Wed Feb 26 2014 | |||||||
| ||||||||