tuohai666 commented on issue #2927: Use JavaAgent introducing Sharding-JDBC
URL: 
https://github.com/apache/incubator-shardingsphere/issues/2927#issuecomment-527095080
 
 
   I'd like to share some details about how to redefine the DataSource.
   
   1. Use SkyWalking 
[apm-agent-core](https://github.com/apache/skywalking/tree/master/apm-sniffer/apm-agent-core)
 instead of byte-buddy to hack JDBC code. apm-agent-core has significantly 
enhanced byte-buddy.
   
   2. When an original DataSource is hacked for example to a 
ShardingDataSource. How to decide the behavior when the method of this 
DataSource is called? 
   If the user call ds.getConnection(), we want the DataSource behaves like a 
ShardingDataSource. While if the Sharding-JDBC call ds.getConnection(), we want 
the DataSource behaves like an original DataSource.
   It's convenient that we can find out who currently call getConnection() via 
Thread.currentThread().getStackTrace(). When the stack trace is from 
Sharding-JDBC, we treat the DataSource as the original one. 
   
   3. How to support so many DataSources from various connection pools?
   We have to redefine DataSources for some popular connection pools one by 
one. At first we only need to hack HikariDataSource and add it to a support 
list. After that users can add others they want.
   

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

Reply via email to