Chapter 5. Connecting to Data Grid clusters
After you configure and deploy Data Grid clusters you can establish remote connections through the Data Grid Console, command line interface (CLI), Hot Rod client, or REST API.
5.1. Accessing Data Grid Console Copy linkLink copied to clipboard!
Access the console to create caches, perform adminstrative operations, and monitor your Data Grid clusters.
Prerequisites
- Expose your Data Grid cluster on the network.
- Retrieve network service details.
Procedure
Access Data Grid Console from any browser at
$SERVICE_HOSTNAME:$PORT.Replace
$SERVICE_HOSTNAME:$PORTwith the hostname and port where Data Grid is available on the network.
5.2. Connecting with the command line interface (CLI) Copy linkLink copied to clipboard!
Use the Data Grid CLI to connect to clusters and create caches, manipulate data, and perform administrative operations.
Prerequisites
- Expose your Data Grid cluster on the network.
- Retrieve network service details.
- Download the native Data Grid CLI distribution from the Data Grid software downloads.
-
Extract the
.ziparchive for the native Data Grid CLI distribution to your host filesystem.
Procedure
Start the Data Grid CLI with the network service as the value for the
-cargument, for example:$ {native_cli} -c http://cluster-name-myroute.hostname.net/- Enter your Data Grid credentials when prompted.
Perform CLI operations as required.
TipPress the tab key or use the
--helpargument to view available options and help text.-
Use the
quitcommand to exit the CLI.
5.3. Connecting Hot Rod clients running on OpenShift Copy linkLink copied to clipboard!
Access remote caches with Hot Rod clients running on the same OpenShift cluster as your Data Grid cluster.
Prerequisites
- Retrieve network service details.
Procedure
Specify the internal network service detail for your Data Grid cluster in the client configuration.
In the following configuration examples,
$SERVICE_HOSTNAME:$PORTdenotes the hostname and port that allows access to your Data Grid cluster.- Specify your credentials so the client can authenticate with Data Grid.
Configure client intelligence, if required.
Hot Rod clients running on OpenShift can use any client intelligence because they can access internal IP addresses for Data Grid pods.
The default intelligence,HASH_DISTRIBUTION_AWARE, is recommended because it allows clients to route requests to primary owners, which improves performance.
Programmatic configuration
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.SaslQop;
import org.infinispan.client.hotrod.impl.ConfigurationProperties;
...
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer()
.host("$SERVICE_HOSTNAME")
.port(ConfigurationProperties.DEFAULT_HOTROD_PORT)
.security().authentication()
.username("username")
.password("changeme")
.realm("default")
.saslQop(SaslQop.AUTH)
.saslMechanism("SCRAM-SHA-512");
Hot Rod client properties
# Connection
infinispan.client.hotrod.server_list=$SERVICE_HOSTNAME:$PORT
# Authentication
infinispan.client.hotrod.use_auth=true
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=SCRAM-SHA-512
5.4. Connecting Hot Rod clients running outside OpenShift Copy linkLink copied to clipboard!
Access remote caches with Hot Rod clients running externally to the OpenShift cluster where you deploy your Data Grid cluster.
Prerequisites
- Expose your Data Grid cluster on the network.
- Retrieve network service details.
Procedure
Specify the internal network service detail for your Data Grid cluster in the client configuration.
In the following configuration examples,
$SERVICE_HOSTNAME:$PORTdenotes the hostname and port that allows access to your Data Grid cluster.- Specify your credentials so the client can authenticate with Data Grid.
-
Configure clients to use
BASICintelligence.
Programmatic configuration
import org.infinispan.client.hotrod.configuration.ClientIntelligence;
import org.infinispan.client.hotrod.configuration.ConfigurationBuilder;
import org.infinispan.client.hotrod.configuration.SaslQop;
...
ConfigurationBuilder builder = new ConfigurationBuilder();
builder.addServer()
.host("$SERVICE_HOSTNAME")
.port("$PORT")
.security().authentication()
.username("username")
.password("changeme")
.realm("default")
.saslQop(SaslQop.AUTH)
.saslMechanism("SCRAM-SHA-512");
builder.clientIntelligence(ClientIntelligence.BASIC);
Hot Rod client properties
# Connection
infinispan.client.hotrod.server_list=$SERVICE_HOSTNAME:$PORT
# Client intelligence
infinispan.client.hotrod.client_intelligence=BASIC
# Authentication
infinispan.client.hotrod.use_auth=true
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=SCRAM-SHA-512
5.5. Accessing the REST API Copy linkLink copied to clipboard!
Data Grid provides a RESTful interface that you can interact with using HTTP clients.
Prerequisites
- Expose your Data Grid cluster on the network.
- Retrieve network service details.
Procedure
Access the REST API with any HTTP client at
$SERVICE_HOSTNAME:$PORT/rest/v2.Replace
$SERVICE_HOSTNAME:$PORTwith the hostname and port where Data Grid is available on the network.