JBoss.orgCommunity Documentation
The Infinispan repository connector allows a Infinispan instance to be used as a ModeShape (and thus JCR) repository. This provides a way for the content in a repository to be stored in an effective, scalable, and distributed data grid, and can be federated with other repository sources to provide a distributed repository.
The InfinispanSource
class provides a number of JavaBean properties that control its behavior:
Table 19.1. InfinispanSource
properties
Property | Description |
---|---|
cacheManagerJndiName | Optional property that, if used, specifies the name in JNDI where an existing Infinispan Cache Manager instance can be found.
That factory would then be used if needed to create an Infinispan Cache instance. If no value is provided, then the
Infinispan DefaultCacheManager class is used. |
cacheConfigurationName |
Optional property that, if used, specifies the name of the configuration resource or file that is supplied to the cache manager when creating a new Infinispan DefaultCacheManager instance. The configuration name is first treated as a resource name and will be attempted to be loaded from the ClassLoader. If that is unsuccessful, the configuration name is assumed to be a file name and will be loaded from the file system. This initialization happens the first time that the source is used. Note that the |
defaultCachePolicy | Optional property that, if used, defines the default for how long this information provided by this source may to be cached by other, higher-level components. The default value of null implies that this source does not define a specific duration for caching information provided by this repository source. |
defaultWorkspaceName | Optional property that is initialized to an empty string and which defines the name for the workspace that will be used by default if none is specified. |
name | The name of the repository source, which is used by the RepositoryService when obtaining a RepositoryConnection by name. |
predefinedWorkspaceNames | Optional property that defines the names of the workspaces that exist and that are available for use without having to create them. |
retryLimit | Optional property that, if used, defines the number of times that any single operation on a RepositoryConnection to this source should be retried following a communication failure. The default value is '0'. |
rootNodeUuid | Optional property that, if used, specifies the UUID that should be used for the root node of each workspace. If no value is specified, a pre-defined UUID constant is used. A custom value need only be supplied for Infinispan sources created prior to ModeShape 2.0, or if a specific UUID is desired or needed. |
updatesAllowed | Determines whether the content in the connector is can be updated ("true"), or if the content may only be read ("false"). The default value is "true". |
One way to configure the Infinispan connector is to create JcrConfiguration
instance with a repository source that uses the InfinispanSource
class.
For example:
JcrConfiguration config = ...
config.repositorySource("Infinispan Store")
.usingClass(InfinispanSource.class)
.setDescription("The repository for our content")
.setProperty("defaultWorkspaceName", "prod")
.setProperty("predefinedWorkspaceNames", new String[] { "staging", "dev"});
Another way to configure the Infinispan connector is to create JcrConfiguration
instance and load an XML configuration file that contains a repository source that
uses the InfinispanSource
class.
For example a file named configRepository.xml can be created with these contents:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns:mode="http://www.modeshape.org/1.0" xmlns:jcr="http://www.jcp.org/jcr/1.0">
<!--
Define the sources for the content. These sources are directly accessible using the
ModeShape-specific Graph API. In fact, this is how the ModeShape JCR implementation works. You
can think of these as being similar to JDBC DataSource objects, except that they expose
graph content via the Graph API instead of records via SQL or JDBC.
-->
<mode:sources jcr:primaryType="nt:unstructured">
<!--
The 'Infinispan Store' repository is a Infinispan repository with a single default
workspace (though others could be created, too).
-->
<mode:source jcr:name="Infinispan Store"
mode:classname="org.modeshape.connector.infinispan.InfinispanSource"
mode:description="The repository for our content"
mode:defaultworkspaceName="prod">
<mode:predefinedWorkspaceNames>staging</mode:predefinedWorkspaceNames>
<mode:predefinedWorkspaceNames>dev</mode:predefinedWorkspaceNames>
</mode:source>
</mode:sources>
<!-- MIME type detectors and JCR repositories would be defined below -->
</configuration>
The configuration can then be loaded from Java like this:
JcrConfiguration config = new JcrConfiguration().loadFrom("/configRepository.xml");
The InfinispanSource
can be used to provide access to an Infinispan cluster, but be sure to use the DIST_SYNC
cache mode. Using other modes will likely lead to data inconsistency.
Additionally, some operating systems (e.g., OS X) require you to set either the java.net.preferIPv4Stack
or the java.net.preferIPv6Addresses
system property to true
. These properties are used by
JGroups, the communications library that underlies Infinispan, to help determine which address type to use.
The rootNodeUuid
property must be set to the same value for all Infinispan sources in the cluster.