02-rtdb-connection-pool.md 1.7 KB

RTDB 连接池(基于 icore-rtdb)

现状

icore-rtdbcom.steerinfo.rtdb无内置连接池

  • ClientImpl:单 TCP socket + 请求多路复用
  • 现网 TestClient2 使用单例 DbConstants.client

高并发写入场景下,单连接仍可能成为瓶颈或故障单点,因此自建 多 Client 池

设计

类包:com.steerinfo.meterwork.rtdb

职责
RtdbPoolProperties 配置绑定
RtdbClientPool 固定大小 ArrayBlockingQueue<Client>,borrow / release,ping 失败重建
RtdbClientConfiguration Spring Bean,destroyMethod 关闭全部 Client

借用 / 归还

borrow(timeout) → Client
  try: 业务 call / replace
  catch: invalidate(client)  // close + 新建放回
  finally: release(client)   // 正常归还

API 用法(与现网一致)

client.syncOps().call("db.space.METER_WORK_MONITOR:replace", tuple);
client.syncOps().call("db.space.METER_WORK_MONITOR:get", pointNo);
client.syncOps().call("db.space.METER_WORK_MONITOR:update", key, ops);
client.syncOps().call("db.space.METER_WORK_MONITOR:select"); // 全表 / dirty 扫描

配置项

Key 默认 说明
rtdb.host 172.22.42.3 Tarantool 主机
rtdb.port 2101 端口
rtdb.username guest 用户
rtdb.password 密码
rtdb.pool.size 8 池内 Client 数
rtdb.pool.borrow-timeout-ms 3000 借用超时
rtdb.monitor.enabled true 是否启用 Monitor RTDB 写入

Monitor 写入走本池;DbConstants.client 仍供其它读路径使用。