热 Rod Java 客户端保持与数据网格服务器的持久连接池,以重复利用 TCP 连接,而不是在每个请求上创建它们。
客户端使用异步线程,通过迭代连接池并将 ping 发送到 Data Grid 服务器来检查连接的有效性。这通过在池中闲置时发现有问题的连接来提高性能,而不是在应用程序请求中。
流程
使用 ConnectionPoolConfigurationBuilder 类配置 Hot Rod 客户端连接池设置。
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
clientBuilder
.addServer()
.host("127.0.0.1")
.port(11222)
//Configure client connection pools.
.connectionPool()
//Set the maximum number of active connections per server.
.maxActive(10)
//Set the minimum number of idle connections
//that must be available per server.
.minIdle(20);
remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
ConfigurationBuilder clientBuilder = new ConfigurationBuilder();
clientBuilder
.addServer()
.host("127.0.0.1")
.port(11222)
//Configure client connection pools.
.connectionPool()
//Set the maximum number of active connections per server.
.maxActive(10)
//Set the minimum number of idle connections
//that must be available per server.
.minIdle(20);
remoteCacheManager = new RemoteCacheManager(clientBuilder.build());
Copy to ClipboardCopied!Toggle word wrapToggle overflow