5.4. 连接在 OpenShift 外部运行的 Hot Rod 客户端
使用您部署数据网格集群的 OpenShift 集群外部运行的 Hot Rod 客户端访问远程缓存。
先决条件
- 在网络上公开您的数据网格集群。
- 检索网络服务详细信息。
流程
在客户端配置中,为您的 Data Grid 集群指定内部网络服务详情。
在以下配置示例中,
$SERVICE_HOSTNAME:$PORT表示可访问您的 Data Grid 集群的主机名和端口。- 指定凭证以便客户端可以通过 Data Grid 进行身份验证。
-
将客户端配置为使用
BASIC智能功能。
程序配置
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);
热 Rod 客户端属性
# 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