Este contenido no está disponible en el idioma seleccionado.
Data Grid Library Mode
Data Grid Documentation Copiar enlaceEnlace copiado en el portapapeles!
Abstract
1. Red Hat Data Grid Copiar enlaceEnlace copiado en el portapapeles!
Data Grid is a high-performance, distributed in-memory data store.
- Schemaless data structure
- Flexibility to store different objects as key-value pairs.
- Grid-based data storage
- Designed to distribute and replicate data across clusters.
- Elastic scaling
- Dynamically adjust the number of nodes to meet demand without service disruption.
- Data interoperability
- Store, retrieve, and query data in the grid from different endpoints.
1.1. Data Grid Documentation Copiar enlaceEnlace copiado en el portapapeles!
Documentation for Data Grid is available on the Red Hat customer portal.
1.2. Data Grid Downloads Copiar enlaceEnlace copiado en el portapapeles!
Access the Data Grid Software Downloads on the Red Hat customer portal.
You must have a Red Hat account to access and download Data Grid software.
2. Configuring the Data Grid Maven Repository Copiar enlaceEnlace copiado en el portapapeles!
Data Grid Java distributions are available from Maven.
You can download the Data Grid Maven repository from the customer portal or pull Data Grid dependencies from the public Red Hat Enterprise Maven repository.
2.1. Downloading the Data Grid Maven Repository Copiar enlaceEnlace copiado en el portapapeles!
Download and install the Data Grid Maven repository to a local file system, Apache HTTP server, or Maven repository manager if you do not want to use the public Red Hat Enterprise Maven repository.
Procedure
- Log in to the Red Hat customer portal.
- Navigate to the Software Downloads for Data Grid.
- Download the Red Hat Data Grid 8.0 Maven Repository.
- Extract the archived Maven repository to your local file system.
-
Open the
README.mdfile and follow the appropriate installation instructions.
2.2. Adding the Red Hat GA Maven Repository Copiar enlaceEnlace copiado en el portapapeles!
Configure your Maven settings file, typically ~/.m2/settings.xml, to include the Red Hat GA repository. Alternatively, include the repository directly in your project pom.xml file.
The following configuration uses the public Red Hat Enterprise Maven repository. To use the Data Grid Maven repository that you downloaded from the Red Hat customer portal, change the value of url elements to the correct location.
Reference
2.3. Configuring Your Data Grid POM Copiar enlaceEnlace copiado en el portapapeles!
Maven uses configuration files called Project Object Model (POM) files to define projects and manage builds. POM files are in XML format and describe the module and component dependencies, build order, and targets for the resulting project packaging and output.
Procedure
-
Open your project
pom.xmlfor editing. -
Define the
version.infinispanproperty with the correct Data Grid version. Include the
infinispan-bomin adependencyManagementsection.The Bill Of Materials (BOM) controls dependency versions, which avoids version conflicts and means you do not need to set the version for each Data Grid artifact you add as a dependency to your project.
-
Save and close
pom.xml.
The following example shows the Data Grid version and BOM:
Next Steps
Add Data Grid artifacts as dependencies to your pom.xml as required.
3. Installing Data Grid in Library Mode Copiar enlaceEnlace copiado en el portapapeles!
Add Data Grid as an embedded library in your project.
Procedure
-
Add the
infinispan-coreartifact as a dependency in yourpom.xmlas follows:
4. Running Data Grid as an Embedded Library Copiar enlaceEnlace copiado en el portapapeles!
Learn how to run Data Grid as an embedded data store in your project.
Procedure
- Initialize the default Cache Manager and add a cache definition as follows:
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
DefaultCacheManager cacheManager = new DefaultCacheManager(global.build());
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
cacheManager.administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).getOrCreateCache("myCache", builder.build());
GlobalConfigurationBuilder global = GlobalConfigurationBuilder.defaultClusteredBuilder();
DefaultCacheManager cacheManager = new DefaultCacheManager(global.build());
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.clustering().cacheMode(CacheMode.DIST_SYNC);
cacheManager.administration().withFlags(CacheContainerAdmin.AdminFlag.VOLATILE).getOrCreateCache("myCache", builder.build());
The preceding code initializes a default, clustered Cache Manager. Cache Managers contain your cache definitions and control cache lifecycles.
Data Grid does not provide default cache definitions so after initializing the default Cache Manager, you need to add at least one cache instance. This example uses the ConfigurationBuilder class to create a cache definition that uses the distributed, synchronous cache mode. You then call the getOrCreateCache() method that either creates a cache named "myCache" on all nodes in the cluster or returns it if it already exists.
Next steps
Now that you have a running Cache Manager with a cache created, you can add some more cache definitions, put some data into the cache, or configure Data Grid as needed.
Reference
- Configuring Data Grid Programmatically
- Setting Up Cluster Transport
- org.infinispan.Cache
- org.infinispan.commons.api.CacheContainerAdmin
- org.infinispan.configuration.cache.CacheMode
- org.infinispan.configuration.cache.Configuration
- org.infinispan.configuration.cache.ConfigurationBuilder
- org.infinispan.configuration.global.GlobalConfigurationBuilder
- org.infinispan.manager.DefaultCacheManager
- org.infinispan.manager.EmbeddedCacheManager