feature: add SQL monitoring and connection pool abstraction with implementation and tests #7556
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Ⅰ. 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.
org.apache.seata.common.monitor
)SqlExecutionEntry
: immutable model of a single SQL execution event (sql
,executionTimeMillis
,holdTimeMillis
,timestamp
).SqlMonitor
: singleton collector thatmaxAllRecords
)execMs > slowThreshold
) up tomaxSlowEntries
getAllRecords()
,getSlowSqlList()
,clearOldRecords()
,resetForTest()
.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 aPoolManager
instance byDataSource
type.PoolManager
for supported pool types (e.g., Druid/Hikari) using reflection.SqlMonitorTest
: Covers core monitor behaviors (recording, slow query detection, eviction, clear/reset)PoolManager
implementations, 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)
Ⅳ. Describe how to verify it
Ⅴ. Special notes for reviews