incubator-seata
incubator-seata copied to clipboard
feature: add SQL monitoring and connection pool abstraction with implementation and tests
- [ ] I have registered the PR changes.
Ⅰ. Describe what this PR did
This PR introduces a complete SQL monitoring system and a connection pool abstraction with a concrete implementation, forming the foundation of the connection-pool in Seata.
-
SQL‑event collector (package
org.apache.seata.common.monitor)-
SqlExecutionEntry: immutable model of a single SQL execution event (sql,executionTimeMillis,holdTimeMillis,timestamp). -
SqlMonitor: singleton collector that- records all SQL events (up to
maxAllRecords) - records slow SQL events (
execMs > slowThreshold) up tomaxSlowEntries - exposes
getAllRecords(),getSlowSqlList(),clearOldRecords(),resetForTest().
- records all SQL events (up to
-
-
ConnectionPool (package
org.apache.seata.common.pool)-
ConnectionPoolConfig&ConnectionPoolMetrics: plain‐old‐Java objects representing connection‐pool metrics and config. -
PoolManager: interface defining methodsgetConfig(),getMetrics(),updateConfig(). -
PoolManagerRegistry: simple lookup/factory returning aPoolManagerinstance byDataSourcetype.
-
- Concrete Connection Pool Implementation
- Adds actual implementation of
PoolManagerfor supported pool types (e.g., Druid/Hikari) using reflection.
- Adds actual implementation of
- Unit Tests
-
SqlMonitorTest: Covers core monitor behaviors (recording, slow query detection, eviction, clear/reset) -
Connection Pool Tests: Verifies the correctness of
PoolManagerimplementations, metric reporting, and configuration updating.
-
Ⅱ. Does this pull request fix one issue?
No — this is a new feature for the common module and rm-datasource module, including features about SQL monitor for Druid, connection‐pool metrics config, and the implementation of the connection-pool.
Ⅲ. Why don't you add test cases (unit test/integration test)?
Unit tests are included for all core behaviors of SqlMonitor.
Connection pool implementation (config, metrics, update)