mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
add stat service
This commit is contained in:
@@ -54,18 +54,31 @@ public class DruidStatService {
|
||||
dataSourceStat.setUrl(dataSource.getUrl());
|
||||
dataSourceStat.setDbType(dataSource.getDbType());
|
||||
|
||||
dataSourceStatList.add(dataSourceStat);
|
||||
|
||||
Collection<JdbcSqlStat> sqlStats = dataSource.getDataSourceStat().getSqlStatMap().values();
|
||||
|
||||
List<SqlInfo> sqlStatInfoList = new ArrayList<SqlInfo>(sqlStats.size());
|
||||
for (JdbcSqlStat sqlStat : dataSource.getDataSourceStat().getSqlStatMap().values()) {
|
||||
SqlInfo sqlStatInfo = new SqlInfo();
|
||||
|
||||
if (sqlStat.getExecuteCount() == 0 && sqlStat.getRunningCount() == 0) {
|
||||
continue;
|
||||
}
|
||||
|
||||
sqlStatInfo.setSql(sqlStat.getSql());
|
||||
sqlStatInfo.setExecuteCount((int) sqlStat.getExecuteCount());
|
||||
sqlStatInfo.setRunningCount((int) sqlStat.getRunningCount());
|
||||
sqlStatInfo.setConcurrentMax((int) sqlStat.getConcurrentMax());
|
||||
sqlStatInfo.setErrorCount((int) sqlStat.getErrorCount());
|
||||
sqlStatInfo.setInTransactionCount((int) sqlStat.getInTransactionCount());
|
||||
sqlStatInfo.setFetchRowCount(sqlStat.getFetchRowCount());
|
||||
sqlStatInfo.setUpdateCount(sqlStat.getUpdateCount());
|
||||
|
||||
sqlStatInfoList.add(sqlStatInfo);
|
||||
}
|
||||
|
||||
dataSourceStat.setSqlList(sqlStatInfoList);
|
||||
|
||||
dataSourceStatList.add(dataSourceStat);
|
||||
}
|
||||
|
||||
store.saveDataSource(timeMillis, dataSourceStatList);
|
||||
|
||||
@@ -3,11 +3,8 @@ package com.alibaba.druid.stat.service;
|
||||
import java.util.List;
|
||||
|
||||
import com.alibaba.druid.stat.service.dto.DataSourceInfo;
|
||||
import com.alibaba.druid.stat.service.dto.SqlInfo;
|
||||
|
||||
public interface DruidStatStore {
|
||||
|
||||
void saveSql(long timeMillis, List<SqlInfo> sqlList);
|
||||
|
||||
void saveDataSource(long timeMillis, List<DataSourceInfo> dataSourceList);
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ public class SqlInfo {
|
||||
private int executeCount;
|
||||
private int runningCount;
|
||||
private int concurrentMax;
|
||||
private int executeErrorCount;
|
||||
private int errorCount;
|
||||
private int inTransactionCount;
|
||||
|
||||
private long fetchRowCount;
|
||||
@@ -48,12 +48,12 @@ public class SqlInfo {
|
||||
this.concurrentMax = concurrentMax;
|
||||
}
|
||||
|
||||
public int getExecuteErrorCount() {
|
||||
return executeErrorCount;
|
||||
public int getErrorCount() {
|
||||
return errorCount;
|
||||
}
|
||||
|
||||
public void setExecuteErrorCount(int executeErrorCount) {
|
||||
this.executeErrorCount = executeErrorCount;
|
||||
public void setErrorCount(int errorCount) {
|
||||
this.errorCount = errorCount;
|
||||
}
|
||||
|
||||
public int getInTransactionCount() {
|
||||
|
||||
@@ -4,16 +4,10 @@ import java.util.List;
|
||||
|
||||
import com.alibaba.druid.stat.service.DruidStatStore;
|
||||
import com.alibaba.druid.stat.service.dto.DataSourceInfo;
|
||||
import com.alibaba.druid.stat.service.dto.SqlInfo;
|
||||
|
||||
|
||||
public class DruidStatMemoryStore implements DruidStatStore {
|
||||
|
||||
@Override
|
||||
public void saveSql(long timeMillis, List<SqlInfo> sqlList) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveDataSource(long timeMillis, List<DataSourceInfo> dataSourceList) {
|
||||
|
||||
|
||||
Reference in New Issue
Block a user