2024.03.08.sharding-jdbc+Hikari
2024-03-30 11:03:13 0 举报
sharding-jdbc+Hikari
作者其他创作
大纲/内容
ShardingDataSource #getConnection()
new ConcurrentBag()
new ShardingRule()
new ShardingPreparedStatement()
this.rewrite()
DataNodeRouter #route()
HikariDataSource
getDataSource()
new SQLParserEngine(databaseTypeName)
设置dataSource属性
ShardingDataSourceFactory#createDataSource()
DataSourcePropertiesSetterHolder.getDataSourcePropertiesSetterByType()
MergeEngine #merge()
ShardingPreparedStatement #executeQuery()
execute()
启动
addConnectionExecutor
new HouseKeeper()
Class.forName()
super()
new MergeEngine()
ShardingPreparedStatement #executeUpdate()
addSQLTokenGenerators()
引用DS对象
new ShardingDataSource()
dataSource.getConnection()
mergeQuery()
new ShardingParameterMetaData()
@Bean
SQLRewriteEntry #decorate()
new RouteContext()
SPIRouteDecorator
new ShardingTokenGenerateBuilder()
new ShardingConnection()
new ShardingRuntimeContext()
SQLParserEngine
createThreadPoolExecutor()
DataSource shardingDataSource()
AbstractRuntimeContext
setEnvironment()
new BatchPreparedStatementExecutor()
ShardingPreparedStatement #execute()
fillPool()
HikariDataSource #getConnection()
HouseKeeper implements Runnable
new ShardingResultSet()
createRouteContext()
PropertyUtil.handle()
clearPrevious();
new ShardingTransactionManagerEngine()
HikariDataSourcePropertiesSetter.propertiesSet()
new RouteResult()
获取此db下的所有配置key,value
获取type,如:spring.shardingsphere.datasource.master1.type = com.zaxxer.hikari.HikariDataSource
SPISQLRewriteContextDecorator
new ShardingRuleConfigurationYamlSwapper().swap(shardingRule)
new PreparedQueryPrepareEngine()
BasePrepareEngine #executeRewrite()
this.registerRewriteDecorator()
SQLParserEngine#parse()
softEvictConnections()
new ExecutorEngine()
prepare()
new SQLRewriteContext()
initPreparedStatementExecutor()
initializeHouseKeepingExecutorService()
程序excute
spring.shardingsphere.datasource.names
preparedStatementExecutor.executeQuery()
start()
new SQLParserExecutor()
callSetterMethod()
AbstractDataSourceAdapter#createDatabaseType()
SpringBootConfiguration
closeConnection()
ShardingRuntimeContext#createCachedDatabaseMetaData()
PreparedStatementExecutor
decorator.decorate()
RouteDecorator#decorate()
registerRouteDecorator()
中间步骤忽略
this.handoffQueue = new SynchronousQueue<>(true);this.waiters = new AtomicInteger();this.sharedList = new CopyOnWriteArrayList<>();
SQLParserExecutor
clearBatch();
ParameterRewriter#rewrite();
采用Antlr4
生成datasouce实例
DataNodeRouter #executeRoute()
route()
DataNodeRouter
ParseTree parseTree =getRootNode()
设置各个属性
ShardingConnection #prepareStatement()
rewriter.createSQLRewriteContext()
spring.shardingsphere.datasource.master0.data-source-properties
BasePrepareEngine #executeRoute()
new ExecutionContext()
SPIShardingTransactionManager
shardingTransactionManagerEngine#init
执行各种增、删、改、查操作
活动获取到的name
SQLParserEngineFactory.getSQLParserEngine()
DataSourceUtil.getDataSource()
new PreparedStatementExecutor()
getDataSourceNames()
new HikariPool()
closeConnectionExecutor
收藏
收藏
0 条评论
下一页