mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
Merge branch 'master' of https://github.com/alibaba/druid
This commit is contained in:
-14
@@ -55,18 +55,4 @@ public class DruidDataSourceAutoConfigure {
|
||||
LOGGER.info("Init DruidDataSource");
|
||||
return new DruidDataSourceWrapper();
|
||||
}
|
||||
|
||||
@Bean
|
||||
@ConditionalOnMissingBean
|
||||
@ConditionalOnBean({MeterRegistry.class, DruidDataSource.class})
|
||||
public DataSourcePoolMetadataProvider druidPoolDataSourceMetadataProvider() {
|
||||
return (dataSource) -> {
|
||||
DruidDataSource ds = DataSourceUnwrapper.unwrap(dataSource,
|
||||
DruidDataSource.class);
|
||||
if (ds != null) {
|
||||
return new DruidDataSourcePoolMetadata(ds);
|
||||
}
|
||||
return null;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
-47
@@ -1,47 +0,0 @@
|
||||
package com.alibaba.druid.spring.boot.autoconfigure.metrics;
|
||||
|
||||
import com.alibaba.druid.pool.DruidDataSource;
|
||||
import org.springframework.boot.jdbc.metadata.AbstractDataSourcePoolMetadata;
|
||||
|
||||
/**
|
||||
* @author hai
|
||||
* @version 1.0
|
||||
* Created on 2021/11/16 下午7:15
|
||||
* @description
|
||||
*/
|
||||
public class DruidDataSourcePoolMetadata extends AbstractDataSourcePoolMetadata<DruidDataSource> {
|
||||
|
||||
/**
|
||||
* Create an instance with the data source to use.
|
||||
*
|
||||
* @param dataSource the data source
|
||||
*/
|
||||
public DruidDataSourcePoolMetadata(DruidDataSource dataSource) {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getActive() {
|
||||
return getDataSource().getActiveCount();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMax() {
|
||||
return getDataSource().getMaxActive();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer getMin() {
|
||||
return getDataSource().getMinIdle();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getValidationQuery() {
|
||||
return getDataSource().getValidationQuery();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Boolean getDefaultAutoCommit() {
|
||||
return getDataSource().isDefaultAutoCommit();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user