Este contenido no está disponible en el idioma seleccionado.

Chapter 10. Connecting to Data Grid Clusters


Connect to Data Grid via the REST or Hot Rod endpoints. You can then remotely create and modify cache definitions and store data across Data Grid clusters.

The examples in this section use $SERVICE_HOSTNAME to denote the service that provides access to your Data Grid cluster.

Clients running in OpenShift can specify the name of the internal service that Data Grid Operator creates.

Clients running outside OpenShift should specify hostnames according to the type of external service and provider. For example, if using a load balancer service on AWS, the service hostname could be:

.status.loadBalancer.ingress[0].hostname

On GCP or Azure, hostnames might be as follows:

.status.loadBalancer.ingress[0].ip

10.1. Invoking the Data Grid REST API

You can invoke the Data Grid REST API with any appropriate HTTP client.

For convenience, the following examples show how to invoke the REST API with curl using unencrypted connections. It is beyond the scope of this document to describe how to configure HTTP clients to use encryption.

Procedure

  1. Open a remote shell to a Data Grid node, for example:

    $ oc rsh example-rhdatagrid
    Copy to Clipboard Toggle word wrap
  2. Cache service provides a default cache instance, but Data Grid service does not. Before you can store data with Data Grid service clusters, you must create a cache as in the following example:

    $ curl -X POST \
      -u developer:$PASSWORD \
      $SERVICE_HOSTNAME:11222/rest/v2/caches/default
      ...
      < HTTP/1.1 200 OK
      ...
    Copy to Clipboard Toggle word wrap
  3. Put an entry in the cache.

    $ curl -X POST \
      -u developer:$PASSWORD \
      -H 'Content-type: text/plain' -d 'world' \
      $SERVICE_HOSTNAME:11222/rest/v2/caches/default/hello
      ...
      < HTTP/1.1 204 No Content
    Copy to Clipboard Toggle word wrap
  4. Verify the entry.

    $ curl -X GET \
      -u developer:$PASSWORD \
      $SERVICE_HOSTNAME:11222/rest/v2/caches/default/hello/
      ...
      < HTTP/1.1 200 OK
      ...
      world
    Copy to Clipboard Toggle word wrap

10.2. Configuring Hot Rod Clients

Configure Hot Rod Java clients to connect to Data Grid clusters.

Hot Rod client ConfigurationBuilder

import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;

ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer()
       //Connection
       .host("$SERVICE_HOSTNAME").port(11222)
       //Client intelligence
       //External clients can use `BASIC` intelligence only.
       .clientIntelligence(ClientIntelligence.BASIC)
       .security()
          //Authentication
          .authentication().enable()
            //Application user credentials.
            //The default username is developer.
            .username("developer")
            .password("$PASSWORD")
            .serverName("$CLUSTER_NAME")
            .saslQop(SaslQop.AUTH)
            .saslMechanism("DIGEST-MD5")
          //Encryption
          .ssl()
            .sniHostName("$SERVICE_HOSTNAME")
            //Path to the TLS certificate.
            //Clients automatically generate trust stores from certificates.
            .trustStorePath​(tls.crt);
Copy to Clipboard Toggle word wrap

Hot Rod client properties

# Connection
infinispan.client.hotrod.server_list=$SERVICE_HOSTNAME:11222

# Client intelligence
# External clients can use `BASIC` intelligence only.
infinispan.client.hotrod.client_intelligence=BASIC

# Authentication
infinispan.client.hotrod.use_auth=true
# Application user credentials.
# The default username is developer.
infinispan.client.hotrod.auth_username=developer
infinispan.client.hotrod.auth_password=$PASSWORD
infinispan.client.hotrod.auth_server_name=$CLUSTER_NAME
infinispan.client.hotrod.sasl_properties.javax.security.sasl.qop=auth
infinispan.client.hotrod.sasl_mechanism=DIGEST-MD5

# Encryption
infinispan.client.hotrod.sni_host_name=$SERVICE_HOSTNAME
# Path to the TLS certificate.
# Clients automatically generate trust stores from certificates.
infinispan.client.hotrod.trust_store_path=tls.crt
Copy to Clipboard Toggle word wrap

Volver arriba
Red Hat logoGithubredditYoutubeTwitter

Aprender

Pruebe, compre y venda

Comunidades

Acerca de la documentación de Red Hat

Ayudamos a los usuarios de Red Hat a innovar y alcanzar sus objetivos con nuestros productos y servicios con contenido en el que pueden confiar. Explore nuestras recientes actualizaciones.

Hacer que el código abierto sea más inclusivo

Red Hat se compromete a reemplazar el lenguaje problemático en nuestro código, documentación y propiedades web. Para más detalles, consulte el Blog de Red Hat.

Acerca de Red Hat

Ofrecemos soluciones reforzadas que facilitan a las empresas trabajar en plataformas y entornos, desde el centro de datos central hasta el perímetro de la red.

Theme

© 2025 Red Hat