bug fixed for useGlobalDataSourceStat.

This commit is contained in:
wenshao
2018-03-05 14:50:29 +08:00
parent 2f4292635c
commit 9a87c66ba9
2 changed files with 14 additions and 0 deletions
@@ -85,4 +85,6 @@ public interface DruidDataSourceMBean extends DruidAbstractDataSourceMBean {
int fill() throws SQLException;
int fill(int toCount) throws SQLException;
boolean isUseGlobalDataSourceStat();
}
@@ -145,9 +145,21 @@ public final class DruidStatManagerFacade {
Set<Object> dataSources = getDruidDataSourceInstances();
if (dataSourceId == null) {
JdbcDataSourceStat globalStat = JdbcDataSourceStat.getGlobal();
List<Map<String, Object>> sqlList = new ArrayList<Map<String, Object>>();
DruidDataSource globalStatDataSource = null;
for (Object datasource : dataSources) {
if (datasource instanceof DruidDataSource) {
if (((DruidDataSource) datasource).getDataSourceStat() == globalStat) {
if (globalStatDataSource == null) {
globalStatDataSource = (DruidDataSource) datasource;
} else {
continue;
}
}
}
sqlList.addAll(getSqlStatDataList(datasource));
}