Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
19.10. Custom Cache Stores
CacheLoaderCacheWriterAdvancedCacheLoaderAdvancedCacheWriterExternalStoreAdvancedLoadWriteStore
Note
AdvancedCacheWriter is not implemented, the expired entries cannot be purged or cleared using the given writer.
Note
AdvancedCacheLoader is not implemented, the entries stored in the given loader will not be used for preloading.
SingleFileStore as an example. To view the SingleFileStore example code, download the JBoss Data Grid source code.
SingleFileStore example code from the Customer Portal:
Procedure 19.6. Download JBoss Data Grid Source Code
- To access the Red Hat Customer Portal, navigate to https://access.redhat.com/home in a browser.
- Click .
- In the section labeled JBoss Development and Management, click .
- Enter the relevant credentials in the Red Hat Login and Password fields and click .
- From the list of downloadable files, locate Red Hat JBoss Data Grid 7 Source Code and click . Save and unpack it in a desired location.
- Locate the
SingleFileStoresource code by navigating throughjboss-datagrid-7.0.0-sources/infinispan-8.3.0.Final-redhat-1-src/core/src/main/java/org/infinispan/persistence/file/SingleFileStore.java.
19.10.1. Custom Cache Store Maven Archetype Link kopierenLink in die Zwischenablage kopiert!
Procedure 19.7. Generate a Maven Archetype
- Ensure the JBoss Data Grid Maven repository has been installed by following the instructions in the Red Hat JBoss Data Grid Getting Started Guide.
- Open a command prompt and execute the following command to generate an archetype in the current directory:
mvn -Dmaven.repo.local="path/to/unzipped/jboss-datagrid-7.0.0-maven-repository/" archetype:generate -DarchetypeGroupId=org.infinispan -DarchetypeArtifactId=custom-cache-store-archetype -DarchetypeVersion=8.3.0.Final-redhat-1
mvn -Dmaven.repo.local="path/to/unzipped/jboss-datagrid-7.0.0-maven-repository/" archetype:generate -DarchetypeGroupId=org.infinispan -DarchetypeArtifactId=custom-cache-store-archetype -DarchetypeVersion=8.3.0.Final-redhat-1Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note
The above command has been broken into multiple lines for readability; however, when executed this command and all arguments must be on a single line.
19.10.2. Custom Cache Store Configuration (Remote Client-Server Mode) Link kopierenLink in die Zwischenablage kopiert!
Example 19.2. Custom Cache Store Configuration
<distributed-cache name="cacheStore" mode="SYNC" segments="20" owners="2" remote-timeout="30000">
<store class="my.package.CustomCacheStore">
<property name="customStoreProperty">10</property>
</store>
</distributed-cache>
<distributed-cache name="cacheStore" mode="SYNC" segments="20" owners="2" remote-timeout="30000">
<store class="my.package.CustomCacheStore">
<property name="customStoreProperty">10</property>
</store>
</distributed-cache>
19.10.2.1. Option 1: Add Custom Cache Store using deployments (Remote Client-Server Mode) Link kopierenLink in die Zwischenablage kopiert!
Procedure 19.8. Deploy Custom Cache Store .jar file to JDG server using deployments
- Add the following Java service loader file
META-INF/services/org.infinispan.persistence.spi.AdvancedLoadWriteStoreto the module and add a reference to the Custom Cache Store Class, such as seen below:my.package.CustomCacheStore
my.package.CustomCacheStoreCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Copy the jar to the
$JDG_HOME/standalone/deployments/directory. - If the .jar file is available the server the following message will be displayed in the logs:
JBAS010287: Registering Deployed Cache Store service for store 'my.package.CustomCacheStore'
JBAS010287: Registering Deployed Cache Store service for store 'my.package.CustomCacheStore'Copy to Clipboard Copied! Toggle word wrap Toggle overflow - In the
infinispan-coresubsystem add an entry for the cache inside acache-container, specifying the class that overrides one of the interfaces from Section 19.10, “Custom Cache Stores”:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
19.10.2.2. Option 2: Add Custom Cache Store using the CLI (Remote Client-Server Mode) Link kopierenLink in die Zwischenablage kopiert!
Procedure 19.9. Deploying Custom Cache Store .jar file to JDG server using the CLI
- Connect to the JDG server by running the below command:
[$JDG_HOME] $ bin/cli.sh --connect --controller=$IP:$PORT
[$JDG_HOME] $ bin/cli.sh --connect --controller=$IP:$PORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Deploy the .jar file by executing the following command:
deploy /path/to/artifact.jar
deploy /path/to/artifact.jarCopy to Clipboard Copied! Toggle word wrap Toggle overflow
19.10.2.3. Option 3: Add Custom Cache Store using JON (Remote Client-Server Mode) Link kopierenLink in die Zwischenablage kopiert!
Procedure 19.10. Deploying Custom Cache Store .jar file to JDG server using JBoss Operation Network
- Log into JON.
- Navigate to
Bundlesalong the upper bar. - Click the
Newbutton and choose theReciperadio button. - Insert a deployment bundle file content that references the store, similar to the following example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Proceed with
Nextbutton toBundle Groupsconfiguration wizard page and proceed withNextbutton once again. - Locate custom cache store
.jarfile using file uploader andUploadthe file. - Proceed with
Nextbutton toSummaryconfiguration wizard page. Proceed withFinishbutton in order to finish bundle configuration. - Navigate back to the
Bundlestab along the upper bar. - Select the newly created bundle and click
Deploybutton. - Enter
Destination Nameand choose the proper Resource Group; this group should only consist of JDG servers. - Choose
Install DirectoryfromBase Location's radio box group. - Enter
/standalone/deploymentsinDeployment Directorytext field below. - Proceed with the wizard using the default options.
- Validate the deployment using the following command on the server's host:
find $JDG_HOME -name "custom-store.jar"
find $JDG_HOME -name "custom-store.jar"Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Confirm the bundle has been installed in
$JDG_HOME/standalone/deployments.
Note
19.10.3. Custom Cache Store Configuration (Library Mode) Link kopierenLink in die Zwischenablage kopiert!
Example 19.3. Custom Cache Store Configuration
Note