mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
增强监控
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@344 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -915,11 +915,17 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
map.put("StatementExecuteCount_200_500_Millis", stat.getStatementStat().getCount_200_500_Millis());
|
||||
map.put("StatementExecuteCount_500_1000_Millis", stat.getStatementStat().getCount_500_1000_Millis());
|
||||
|
||||
map.put("StatementExecuteCount_1000_2000_Millis", stat.getStatementStat().getCount_1000_2000_Millis());
|
||||
map.put("StatementExecuteCount_2000_5000_Millis", stat.getStatementStat().getCount_2000_5000_Millis());
|
||||
map.put("StatementExecuteCount_5000_10000_Millis", stat.getStatementStat().getCount_5000_10000_Millis());
|
||||
map.put("StatementExecuteCount_10000_20000_Millis", stat.getStatementStat().getCount_10000_20000_Millis());
|
||||
map.put("StatementExecuteCount_20000_more_Millis", stat.getStatementStat().getCount_20000_more_Millis());
|
||||
map.put("StatementExecuteCount_1_2_Seconds", stat.getStatementStat().getCount_1_2_Seconds());
|
||||
map.put("StatementExecuteCount_2_5_Seconds", stat.getStatementStat().getCount_2_5_Seconds());
|
||||
map.put("StatementExecuteCount_5_10_Seconds", stat.getStatementStat().getCount_5_10_Seconds());
|
||||
map.put("StatementExecuteCount_10_30_Seconds", stat.getStatementStat().getCount_10_30_Seconds());
|
||||
map.put("StatementExecuteCount_30_60_Seconds", stat.getStatementStat().getCount_30_60_Seconds());
|
||||
|
||||
map.put("StatementExecuteCount_1_2_Minutes", stat.getStatementStat().getCount_1_2_minutes());
|
||||
map.put("StatementExecuteCount_2_5_Minutes", stat.getStatementStat().getCount_2_5_minutes());
|
||||
map.put("StatementExecuteCount_5_10_Minutes", stat.getStatementStat().getCount_5_10_minutes());
|
||||
map.put("StatementExecuteCount_10_30_Minutes", stat.getStatementStat().getCount_10_30_minutes());
|
||||
map.put("StatementExecuteCount_30_more_Minutes", stat.getStatementStat().getCount_30_more_minutes());
|
||||
} else {
|
||||
map.put("ConnectionActiveCount", null);
|
||||
map.put("ConnectionActiveCountMax", null);
|
||||
@@ -1004,11 +1010,17 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
map.put("StatementExecuteCount_200_500_Millis", null);
|
||||
map.put("StatementExecuteCount_500_1000_Millis", null);
|
||||
|
||||
map.put("StatementExecuteCount_1000_2000_Millis", null);
|
||||
map.put("StatementExecuteCount_2000_5000_Millis", null);
|
||||
map.put("StatementExecuteCount_5000_10000_Millis", null);
|
||||
map.put("StatementExecuteCount_10000_20000_Millis", null);
|
||||
map.put("StatementExecuteCount_20000_more_Millis", null);
|
||||
map.put("StatementExecuteCount_1_2_Seconds", null);
|
||||
map.put("StatementExecuteCount_2_5_Seconds", null);
|
||||
map.put("StatementExecuteCount_5_10_Seconds", null);
|
||||
map.put("StatementExecuteCount_10_30_Seconds", null);
|
||||
map.put("StatementExecuteCount_30_60_Seconds", null);
|
||||
|
||||
map.put("StatementExecuteCount_1_2_Minutes", null);
|
||||
map.put("StatementExecuteCount_2_5_Minutes", null);
|
||||
map.put("StatementExecuteCount_5_10_Minutes", null);
|
||||
map.put("StatementExecuteCount_10_30_Minutes", null);
|
||||
map.put("StatementExecuteCount_30_more_Minutes", null);
|
||||
}
|
||||
|
||||
return new CompositeDataSupport(JdbcStatManager.getDataSourceCompositeType(), map);
|
||||
|
||||
@@ -321,11 +321,17 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
|
||||
map.put("StatementExecuteCount_200_500_Millis", stat.getStatementStat().getCount_200_500_Millis());
|
||||
map.put("StatementExecuteCount_500_1000_Millis", stat.getStatementStat().getCount_500_1000_Millis());
|
||||
|
||||
map.put("StatementExecuteCount_1000_2000_Millis", stat.getStatementStat().getCount_1000_2000_Millis());
|
||||
map.put("StatementExecuteCount_2000_5000_Millis", stat.getStatementStat().getCount_2000_5000_Millis());
|
||||
map.put("StatementExecuteCount_5000_10000_Millis", stat.getStatementStat().getCount_5000_10000_Millis());
|
||||
map.put("StatementExecuteCount_10000_20000_Millis", stat.getStatementStat().getCount_10000_20000_Millis());
|
||||
map.put("StatementExecuteCount_20000_more_Millis", stat.getStatementStat().getCount_20000_more_Millis());
|
||||
map.put("StatementExecuteCount_1_2_Seconds", stat.getStatementStat().getCount_1_2_Seconds());
|
||||
map.put("StatementExecuteCount_2_5_Seconds", stat.getStatementStat().getCount_2_5_Seconds());
|
||||
map.put("StatementExecuteCount_5_10_Seconds", stat.getStatementStat().getCount_5_10_Seconds());
|
||||
map.put("StatementExecuteCount_10_30_Seconds", stat.getStatementStat().getCount_10_30_Seconds());
|
||||
map.put("StatementExecuteCount_30_60_Seconds", stat.getStatementStat().getCount_30_60_Seconds());
|
||||
|
||||
map.put("StatementExecuteCount_1_2_Minutes", stat.getStatementStat().getCount_1_2_minutes());
|
||||
map.put("StatementExecuteCount_2_5_Minutes", stat.getStatementStat().getCount_2_5_minutes());
|
||||
map.put("StatementExecuteCount_5_10_Minutes", stat.getStatementStat().getCount_5_10_minutes());
|
||||
map.put("StatementExecuteCount_10_30_Minutes", stat.getStatementStat().getCount_10_30_minutes());
|
||||
map.put("StatementExecuteCount_30_more_Minutes", stat.getStatementStat().getCount_30_more_minutes());
|
||||
} else {
|
||||
map.put("ConnectionActiveCount", null);
|
||||
map.put("ConnectionActiveCountMax", null);
|
||||
@@ -411,11 +417,17 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
|
||||
map.put("StatementExecuteCount_200_500_Millis", null);
|
||||
map.put("StatementExecuteCount_500_1000_Millis", null);
|
||||
|
||||
map.put("StatementExecuteCount_1000_2000_Millis", null);
|
||||
map.put("StatementExecuteCount_2000_5000_Millis", null);
|
||||
map.put("StatementExecuteCount_5000_10000_Millis", null);
|
||||
map.put("StatementExecuteCount_10000_20000_Millis", null);
|
||||
map.put("StatementExecuteCount_20000_more_Millis", null);
|
||||
map.put("StatementExecuteCount_1_2_Seconds", null);
|
||||
map.put("StatementExecuteCount_2_5_Seconds", null);
|
||||
map.put("StatementExecuteCount_5_10_Seconds", null);
|
||||
map.put("StatementExecuteCount_10_30_Seconds", null);
|
||||
map.put("StatementExecuteCount_30_60_Seconds", null);
|
||||
|
||||
map.put("StatementExecuteCount_1_2_Minutes", null);
|
||||
map.put("StatementExecuteCount_2_5_Minutes", null);
|
||||
map.put("StatementExecuteCount_5_10_Minutes", null);
|
||||
map.put("StatementExecuteCount_10_30_Minutes", null);
|
||||
map.put("StatementExecuteCount_30_more_Minutes", null);
|
||||
}
|
||||
|
||||
return new CompositeDataSupport(JdbcStatManager.getDataSourceCompositeType(), map);
|
||||
|
||||
@@ -20,7 +20,6 @@ import java.io.StringWriter;
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.management.JMException;
|
||||
@@ -62,21 +61,29 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
private final AtomicLong updateCount = new AtomicLong();
|
||||
private final AtomicLong fetchRowCount = new AtomicLong();
|
||||
|
||||
private AtomicInteger count_0_2 = new AtomicInteger();
|
||||
private AtomicInteger count_2_5 = new AtomicInteger();
|
||||
private AtomicInteger count_5_10 = new AtomicInteger();
|
||||
private AtomicInteger count_10_20 = new AtomicInteger();
|
||||
private AtomicInteger count_20_50 = new AtomicInteger();
|
||||
private AtomicInteger count_50_100 = new AtomicInteger();
|
||||
private AtomicInteger count_100_200 = new AtomicInteger();
|
||||
private AtomicInteger count_200_500 = new AtomicInteger();
|
||||
private AtomicInteger count_500_1000 = new AtomicInteger();
|
||||
private AtomicInteger count_1000_2000 = new AtomicInteger();
|
||||
private AtomicInteger count_2000_5000 = new AtomicInteger();
|
||||
private AtomicInteger count_5000_10000 = new AtomicInteger();
|
||||
private AtomicInteger count_10000_20000 = new AtomicInteger();
|
||||
private AtomicInteger count_20000_50000 = new AtomicInteger();
|
||||
private AtomicInteger count_50000_more = new AtomicInteger();
|
||||
private AtomicLong count_0_1_Millis = new AtomicLong();
|
||||
private AtomicLong count_1_2_Millis = new AtomicLong();
|
||||
private AtomicLong count_2_5_Millis = new AtomicLong();
|
||||
private AtomicLong count_5_10_Millis = new AtomicLong();
|
||||
private AtomicLong count_10_20_Millis = new AtomicLong();
|
||||
|
||||
private AtomicLong count_20_50_Millis = new AtomicLong();
|
||||
private AtomicLong count_50_100_Millis = new AtomicLong();
|
||||
private AtomicLong count_100_200_Millis = new AtomicLong();
|
||||
private AtomicLong count_200_500_Millis = new AtomicLong();
|
||||
private AtomicLong count_500_1000_Millis = new AtomicLong();
|
||||
|
||||
private AtomicLong count_1_2_Seconds = new AtomicLong();
|
||||
private AtomicLong count_2_5_Seconds = new AtomicLong();
|
||||
private AtomicLong count_5_10_Seconds = new AtomicLong();
|
||||
private AtomicLong count_10_30_Seconds = new AtomicLong();
|
||||
private AtomicLong count_30_60_Seconds = new AtomicLong();
|
||||
|
||||
private AtomicLong count_1_2_minutes = new AtomicLong();
|
||||
private AtomicLong count_2_5_minutes = new AtomicLong();
|
||||
private AtomicLong count_5_10_minutes = new AtomicLong();
|
||||
private AtomicLong count_10_30_minutes = new AtomicLong();
|
||||
private AtomicLong count_30_more_minutes = new AtomicLong();
|
||||
|
||||
public JdbcSqlStat(String sql){
|
||||
this.sql = sql;
|
||||
@@ -174,21 +181,29 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
updateCount.set(0);
|
||||
fetchRowCount.set(0);
|
||||
|
||||
count_0_2.set(0);
|
||||
count_2_5.set(0);
|
||||
count_5_10.set(0);
|
||||
count_10_20.set(0);
|
||||
count_20_50.set(0);
|
||||
count_50_100.set(0);
|
||||
count_100_200.set(0);
|
||||
count_200_500.set(0);
|
||||
count_500_1000.set(0);
|
||||
count_1000_2000.set(0);
|
||||
count_2000_5000.set(0);
|
||||
count_5000_10000.set(0);
|
||||
count_10000_20000.set(0);
|
||||
count_20000_50000.set(0);
|
||||
count_50000_more.set(0);
|
||||
count_0_1_Millis.set(0);
|
||||
count_1_2_Millis.set(0);
|
||||
count_2_5_Millis.set(0);
|
||||
count_5_10_Millis.set(0);
|
||||
count_10_20_Millis.set(0);
|
||||
|
||||
count_20_50_Millis.set(0);
|
||||
count_50_100_Millis.set(0);
|
||||
count_100_200_Millis.set(0);
|
||||
count_200_500_Millis.set(0);
|
||||
count_500_1000_Millis.set(0);
|
||||
|
||||
count_1_2_Seconds.set(0);
|
||||
count_2_5_Seconds.set(0);
|
||||
count_5_10_Seconds.set(0);
|
||||
count_10_30_Seconds.set(0);
|
||||
count_30_60_Seconds.set(0);
|
||||
|
||||
count_1_2_minutes.set(0);
|
||||
count_2_5_minutes.set(0);
|
||||
count_5_10_minutes.set(0);
|
||||
count_10_30_minutes.set(0);
|
||||
count_30_more_minutes.set(0);
|
||||
}
|
||||
|
||||
public long getConcurrentMax() {
|
||||
@@ -324,36 +339,52 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
}
|
||||
|
||||
|
||||
if (nanoSpan <= 2 * 1000 * 1000) {
|
||||
count_0_2.incrementAndGet();
|
||||
} else if (nanoSpan <= 5 * 1000 * 1000) {
|
||||
count_2_5.incrementAndGet();
|
||||
} else if (nanoSpan <= 10 * 1000 * 1000) {
|
||||
count_5_10.incrementAndGet();
|
||||
} else if (nanoSpan <= 20 * 1000 * 1000) {
|
||||
count_10_20.incrementAndGet();
|
||||
} else if (nanoSpan <= 50 * 1000 * 1000) {
|
||||
count_20_50.incrementAndGet();
|
||||
} else if (nanoSpan <= 100 * 1000 * 1000) {
|
||||
count_50_100.incrementAndGet();
|
||||
} else if (nanoSpan <= 200 * 1000 * 1000) {
|
||||
count_100_200.incrementAndGet();
|
||||
} else if (nanoSpan <= 500 * 1000 * 1000) {
|
||||
count_200_500.incrementAndGet();
|
||||
} else if (nanoSpan <= 1000 * 1000 * 1000) {
|
||||
count_500_1000.incrementAndGet();
|
||||
} else if (nanoSpan <= 2000 * 1000 * 1000) {
|
||||
count_1000_2000.incrementAndGet();
|
||||
} else if (nanoSpan <= 5000 * 1000 * 1000) {
|
||||
count_2000_5000.incrementAndGet();
|
||||
} else if (nanoSpan <= 10000 * 1000 * 1000) {
|
||||
count_5000_10000.incrementAndGet();
|
||||
} else if (nanoSpan <= 20000 * 1000 * 1000) {
|
||||
count_10000_20000.incrementAndGet();
|
||||
} else if (nanoSpan <= 50000 * 1000 * 1000) {
|
||||
count_20000_50000.incrementAndGet();
|
||||
final long MILLIS = 1000 * 1000;
|
||||
final long SECOND = 1000 * MILLIS;
|
||||
final long MINUTE = 60 * SECOND;
|
||||
if (nanoSpan < MILLIS) {
|
||||
count_0_1_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 2 * MILLIS) {
|
||||
count_1_2_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 5 * MILLIS) {
|
||||
count_2_5_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 10 * MILLIS) {
|
||||
count_5_10_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 20 * MILLIS) {
|
||||
count_10_20_Millis.incrementAndGet();
|
||||
|
||||
} else if (nanoSpan < 50 * MILLIS) {
|
||||
count_20_50_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 100 * MILLIS) {
|
||||
count_50_100_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 200 * MILLIS) {
|
||||
count_100_200_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 500 * MILLIS) {
|
||||
count_200_500_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 1000 * MILLIS) {
|
||||
count_500_1000_Millis.incrementAndGet();
|
||||
|
||||
} else if (nanoSpan < 2 * SECOND) {
|
||||
count_1_2_Seconds.incrementAndGet();
|
||||
} else if (nanoSpan < 5 * SECOND) {
|
||||
count_2_5_Seconds.incrementAndGet();
|
||||
} else if (nanoSpan < 10 * SECOND) {
|
||||
count_5_10_Seconds.incrementAndGet();
|
||||
} else if (nanoSpan < 30 * SECOND) {
|
||||
count_10_30_Seconds.incrementAndGet();
|
||||
} else if (nanoSpan < 60 * SECOND) {
|
||||
count_30_60_Seconds.incrementAndGet();
|
||||
|
||||
} else if (nanoSpan < 2 * MINUTE) {
|
||||
count_1_2_minutes.incrementAndGet();
|
||||
} else if (nanoSpan < 5 * MINUTE) {
|
||||
count_2_5_minutes.incrementAndGet();
|
||||
} else if (nanoSpan < 10 * MINUTE) {
|
||||
count_5_10_minutes.incrementAndGet();
|
||||
} else if (nanoSpan < 30 * MINUTE) {
|
||||
count_10_30_minutes.incrementAndGet();
|
||||
} else {
|
||||
count_50000_more.incrementAndGet();
|
||||
count_30_more_minutes.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -374,66 +405,88 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
return executeBatchSizeMax.get();
|
||||
}
|
||||
|
||||
public int getCount_0_2() {
|
||||
return count_0_2.get();
|
||||
|
||||
public long getCount_0_1_Millis() {
|
||||
return count_0_1_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_2_5() {
|
||||
return count_2_5.get();
|
||||
public long getCount_1_2_Millis() {
|
||||
return count_1_2_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_5_10() {
|
||||
return count_5_10.get();
|
||||
public long getCount_2_5_Millis() {
|
||||
return count_2_5_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_10_20() {
|
||||
return count_10_20.get();
|
||||
public long getCount_5_10_Millis() {
|
||||
return count_5_10_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_20_50() {
|
||||
return count_20_50.get();
|
||||
public long getCount_10_20_Millis() {
|
||||
return count_10_20_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_50_100() {
|
||||
return count_50_100.get();
|
||||
public long getCount_20_50_Millis() {
|
||||
return count_20_50_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_100_200() {
|
||||
return count_100_200.get();
|
||||
public long getCount_50_100_Millis() {
|
||||
return count_50_100_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_200_500() {
|
||||
return count_200_500.get();
|
||||
public long getCount_100_200_Millis() {
|
||||
return count_100_200_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_500_1000() {
|
||||
return count_500_1000.get();
|
||||
public long getCount_200_500_Millis() {
|
||||
return count_200_500_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_1000_2000() {
|
||||
return count_1000_2000.get();
|
||||
public long getCount_500_1000_Millis() {
|
||||
return count_500_1000_Millis.get();
|
||||
}
|
||||
|
||||
public int getCount_2000_5000() {
|
||||
return count_2000_5000.get();
|
||||
public long getCount_1_2_Seconds() {
|
||||
return count_1_2_Seconds.get();
|
||||
}
|
||||
|
||||
public int getCount_5000_10000() {
|
||||
return count_5000_10000.get();
|
||||
public long getCount_2_5_Seconds() {
|
||||
return count_2_5_Seconds.get();
|
||||
}
|
||||
|
||||
public int getCount_10000_20000() {
|
||||
return count_10000_20000.get();
|
||||
public long getCount_5_10_Seconds() {
|
||||
return count_5_10_Seconds.get();
|
||||
}
|
||||
|
||||
public int getCount_20000_50000() {
|
||||
return count_20000_50000.get();
|
||||
public long getCount_10_30_Seconds() {
|
||||
return count_10_30_Seconds.get();
|
||||
}
|
||||
|
||||
public int getCount_50000_more() {
|
||||
return count_50000_more.get();
|
||||
public long getCount_30_60_Seconds() {
|
||||
return count_30_60_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_1_2_minutes() {
|
||||
return count_1_2_minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_2_5_minutes() {
|
||||
return count_2_5_minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_5_10_minutes() {
|
||||
return count_5_10_minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_10_30_minutes() {
|
||||
return count_10_30_minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_30_more_minutes() {
|
||||
return count_30_more_minutes.get();
|
||||
}
|
||||
|
||||
|
||||
private static CompositeType COMPOSITE_TYPE = null;
|
||||
|
||||
public static CompositeType getCompositeType() throws JMException {
|
||||
@@ -447,20 +500,22 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING, SimpleType.STRING,
|
||||
SimpleType.STRING, SimpleType.DATE, SimpleType.STRING, SimpleType.STRING //
|
||||
|
||||
, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER //
|
||||
, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER //
|
||||
, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.INTEGER //
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
|
||||
};
|
||||
|
||||
String[] indexNames = { "ID", "DataSource", "SQL", "ExecuteCount", "ErrorCount", "TotalTime", "LastTime", "MaxTimespan", "LastError",
|
||||
"EffectedRowCount", "FetchRowCount", "MaxTimespanOccurTime", "BatchSizeMax", "BatchSizeTotal", "ConcurrentMax", "RunningCount", "Name", "File",
|
||||
"LastErrorMessage", "LastErrorClass", "LastErrorStackTrace", "LastErrorTime", "DbType", "URL", //
|
||||
String[] indexNames = { "ID", "DataSource", "SQL", "ExecuteCount", "ErrorCount" //
|
||||
, "TotalTime", "LastTime", "MaxTimespan", "LastError", "EffectedRowCount" //
|
||||
, "FetchRowCount", "MaxTimespanOccurTime", "BatchSizeMax", "BatchSizeTotal", "ConcurrentMax" //
|
||||
, "RunningCount", "Name", "File" , "LastErrorMessage", "LastErrorClass" //
|
||||
, "LastErrorStackTrace", "LastErrorTime", "DbType", "URL" //
|
||||
|
||||
"Count_0_2", "Count_2_5", "Count_5_10", "Count_10_20", "Count_20_50" //
|
||||
|
||||
, "Count_50_100", "Count_100_200", "Count_200_500", "Count_500_1000", "Count_1000_2000" //
|
||||
|
||||
, "Count_2000_5000", "Count_5000_10000", "Count_10000_20000", "Count_20000_50000", "Count_50000_more", //
|
||||
, "ExecuteCount_0_1_Millis", "ExecuteCount_1_2_Millis", "ExecuteCount_2_5_Millis", "ExecuteCount_5_10_Millis", "ExecuteCount_10_20_Millis"
|
||||
, "ExecuteCount_20_50_Millis", "ExecuteCount_50_100_Millis", "ExecuteCount_100_200_Millis", "ExecuteCount_200_500_Millis", "ExecuteCount_500_1000_Millis"
|
||||
, "ExecuteCount_1_2_Seconds", "ExecuteCount_2_5_Seconds", "ExecuteCount_5_10_Seconds", "ExecuteCount_10_30_Seconds", "ExecuteCount_30_60_Seconds"
|
||||
, "ExecuteCount_1_2_Minutes", "ExecuteCount_2_5_Minutes", "ExecuteCount_5_10_Minutes", "ExecuteCount_10_30_Minutes", "ExecuteCount_30_more_Minutes"
|
||||
};
|
||||
String[] indexDescriptions = indexNames;
|
||||
COMPOSITE_TYPE = new CompositeType("SqlStatistic", "Sql Statistic", indexNames, indexDescriptions, indexTypes);
|
||||
@@ -516,23 +571,29 @@ public final class JdbcSqlStat implements JdbcSqlStatMBean {
|
||||
map.put("DbType", dbType);
|
||||
map.put("URL", null);
|
||||
|
||||
map.put("Count_0_2", this.getCount_0_2());
|
||||
map.put("Count_2_5", this.getCount_2_5());
|
||||
map.put("Count_5_10", this.getCount_5_10());
|
||||
map.put("Count_10_20", this.getCount_10_20());
|
||||
map.put("Count_20_50", this.getCount_20_50());
|
||||
|
||||
map.put("Count_50_100", this.getCount_50_100());
|
||||
map.put("Count_100_200", this.getCount_100_200());
|
||||
map.put("Count_200_500", this.getCount_200_500());
|
||||
map.put("Count_500_1000", this.getCount_500_1000());
|
||||
map.put("Count_1000_2000", this.getCount_1000_2000());
|
||||
|
||||
map.put("Count_2000_5000", this.getCount_2000_5000());
|
||||
map.put("Count_5000_10000", this.getCount_5000_10000());
|
||||
map.put("Count_10000_20000", this.getCount_10000_20000());
|
||||
map.put("Count_20000_50000", this.getCount_20000_50000());
|
||||
map.put("Count_50000_more", this.getCount_50000_more());
|
||||
map.put("ExecuteCount_0_1_Millis", this.getCount_0_1_Millis());
|
||||
map.put("ExecuteCount_1_2_Millis", this.getCount_1_2_Millis());
|
||||
map.put("ExecuteCount_2_5_Millis", this.getCount_2_5_Millis());
|
||||
map.put("ExecuteCount_5_10_Millis", this.getCount_5_10_Millis());
|
||||
map.put("ExecuteCount_10_20_Millis", this.getCount_10_20_Millis());
|
||||
|
||||
map.put("ExecuteCount_20_50_Millis", this.getCount_20_50_Millis());
|
||||
map.put("ExecuteCount_50_100_Millis", this.getCount_50_100_Millis());
|
||||
map.put("ExecuteCount_100_200_Millis", this.getCount_100_200_Millis());
|
||||
map.put("ExecuteCount_200_500_Millis", this.getCount_200_500_Millis());
|
||||
map.put("ExecuteCount_500_1000_Millis", this.getCount_500_1000_Millis());
|
||||
|
||||
map.put("ExecuteCount_1_2_Seconds", this.getCount_1_2_Seconds());
|
||||
map.put("ExecuteCount_2_5_Seconds", this.getCount_2_5_Seconds());
|
||||
map.put("ExecuteCount_5_10_Seconds", this.getCount_5_10_Seconds());
|
||||
map.put("ExecuteCount_10_30_Seconds", this.getCount_10_30_Seconds());
|
||||
map.put("ExecuteCount_30_60_Seconds", this.getCount_30_60_Seconds());
|
||||
|
||||
map.put("ExecuteCount_1_2_Minutes", this.getCount_1_2_minutes());
|
||||
map.put("ExecuteCount_2_5_Minutes", this.getCount_2_5_minutes());
|
||||
map.put("ExecuteCount_5_10_Minutes", this.getCount_5_10_minutes());
|
||||
map.put("ExecuteCount_10_30_Minutes", this.getCount_10_30_minutes());
|
||||
map.put("ExecuteCount_30_more_Minutes", this.getCount_30_more_minutes());
|
||||
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -125,6 +125,7 @@ public class JdbcStatManager implements JdbcStatManagerMBean {
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG, SimpleType.LONG //
|
||||
//
|
||||
//
|
||||
};
|
||||
@@ -146,7 +147,8 @@ public class JdbcStatManager implements JdbcStatManagerMBean {
|
||||
//
|
||||
, "StatementExecuteCount_0_1_Millis", "StatementExecuteCount_1_2_Millis", "StatementExecuteCount_2_5_Millis", "StatementExecuteCount_5_10_Millis", "StatementExecuteCount_10_20_Millis"
|
||||
, "StatementExecuteCount_20_50_Millis", "StatementExecuteCount_50_100_Millis", "StatementExecuteCount_100_200_Millis", "StatementExecuteCount_200_500_Millis", "StatementExecuteCount_500_1000_Millis"
|
||||
, "StatementExecuteCount_1000_2000_Millis", "StatementExecuteCount_2000_5000_Millis", "StatementExecuteCount_5000_10000_Millis", "StatementExecuteCount_10000_20000_Millis", "StatementExecuteCount_20000_more_Millis"
|
||||
, "StatementExecuteCount_1_2_Seconds", "StatementExecuteCount_2_5_Seconds", "StatementExecuteCount_5_10_Seconds", "StatementExecuteCount_10_30_Seconds", "StatementExecuteCount_30_60_Seconds"
|
||||
, "StatementExecuteCount_1_2_Minutes", "StatementExecuteCount_2_5_Minutes", "StatementExecuteCount_5_10_Minutes", "StatementExecuteCount_10_30_Minutes", "StatementExecuteCount_30_more_Minutes"
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
@@ -26,41 +26,47 @@ import com.alibaba.druid.util.JMXUtils;
|
||||
|
||||
public class JdbcStatementStat implements JdbcStatementStatMBean {
|
||||
|
||||
private final AtomicLong createCount = new AtomicLong(0); // 执行createStatement的计数
|
||||
private final AtomicLong prepareCount = new AtomicLong(0); // 执行parepareStatement的计数
|
||||
private final AtomicLong prepareCallCount = new AtomicLong(0); // 执行preCall的计数
|
||||
private final AtomicLong closeCount = new AtomicLong(0); // Statement关闭的计数
|
||||
private final AtomicLong createCount = new AtomicLong(0); // 执行createStatement的计数
|
||||
private final AtomicLong prepareCount = new AtomicLong(0); // 执行parepareStatement的计数
|
||||
private final AtomicLong prepareCallCount = new AtomicLong(0); // 执行preCall的计数
|
||||
private final AtomicLong closeCount = new AtomicLong(0); // Statement关闭的计数
|
||||
|
||||
private final AtomicInteger runningCount = new AtomicInteger();
|
||||
private final AtomicInteger concurrentMax = new AtomicInteger();
|
||||
private final AtomicInteger runningCount = new AtomicInteger();
|
||||
private final AtomicInteger concurrentMax = new AtomicInteger();
|
||||
|
||||
private final AtomicLong count = new AtomicLong();
|
||||
private final AtomicLong errorCount = new AtomicLong();
|
||||
private final AtomicLong count = new AtomicLong();
|
||||
private final AtomicLong errorCount = new AtomicLong();
|
||||
|
||||
private final AtomicLong nanoTotal = new AtomicLong();
|
||||
private final AtomicLong nanoTotal = new AtomicLong();
|
||||
|
||||
private Throwable lastError;
|
||||
private long lastErrorTime;
|
||||
|
||||
private long lastSampleTime = 0;
|
||||
private long lastSampleTime = 0;
|
||||
|
||||
private AtomicLong count_0_1 = new AtomicLong();
|
||||
private AtomicLong count_1_2 = new AtomicLong();
|
||||
private AtomicLong count_2_5 = new AtomicLong();
|
||||
private AtomicLong count_5_10 = new AtomicLong();
|
||||
private AtomicLong count_10_20 = new AtomicLong();
|
||||
private AtomicLong count_0_1_Millis = new AtomicLong();
|
||||
private AtomicLong count_1_2_Millis = new AtomicLong();
|
||||
private AtomicLong count_2_5_Millis = new AtomicLong();
|
||||
private AtomicLong count_5_10_Millis = new AtomicLong();
|
||||
private AtomicLong count_10_20_Millis = new AtomicLong();
|
||||
|
||||
private AtomicLong count_20_50 = new AtomicLong();
|
||||
private AtomicLong count_50_100 = new AtomicLong();
|
||||
private AtomicLong count_100_200 = new AtomicLong();
|
||||
private AtomicLong count_200_500 = new AtomicLong();
|
||||
private AtomicLong count_500_1000 = new AtomicLong();
|
||||
private AtomicLong count_20_50_Millis = new AtomicLong();
|
||||
private AtomicLong count_50_100_Millis = new AtomicLong();
|
||||
private AtomicLong count_100_200_Millis = new AtomicLong();
|
||||
private AtomicLong count_200_500_Millis = new AtomicLong();
|
||||
private AtomicLong count_500_1000_Millis = new AtomicLong();
|
||||
|
||||
private AtomicLong count_1000_2000 = new AtomicLong();
|
||||
private AtomicLong count_2000_5000 = new AtomicLong();
|
||||
private AtomicLong count_5000_10000 = new AtomicLong();
|
||||
private AtomicLong count_10000_20000 = new AtomicLong();
|
||||
private AtomicLong count_20000_more = new AtomicLong();
|
||||
private AtomicLong count_1_2_Seconds = new AtomicLong();
|
||||
private AtomicLong count_2_5_Seconds = new AtomicLong();
|
||||
private AtomicLong count_5_10_Seconds = new AtomicLong();
|
||||
private AtomicLong count_10_30_Seconds = new AtomicLong();
|
||||
private AtomicLong count_30_60_Seconds = new AtomicLong();
|
||||
|
||||
private AtomicLong count_1_2_minutes = new AtomicLong();
|
||||
private AtomicLong count_2_5_minutes = new AtomicLong();
|
||||
private AtomicLong count_5_10_minutes = new AtomicLong();
|
||||
private AtomicLong count_10_30_minutes = new AtomicLong();
|
||||
private AtomicLong count_30_more_minutes = new AtomicLong();
|
||||
|
||||
public void reset() {
|
||||
runningCount.set(0);
|
||||
@@ -77,63 +83,82 @@ public class JdbcStatementStat implements JdbcStatementStatMBean {
|
||||
prepareCallCount.set(0);
|
||||
closeCount.set(0);
|
||||
|
||||
count_0_1.set(0);
|
||||
count_1_2.set(0);
|
||||
count_2_5.set(0);
|
||||
count_5_10.set(0);
|
||||
count_10_20.set(0);
|
||||
count_0_1_Millis.set(0);
|
||||
count_1_2_Millis.set(0);
|
||||
count_2_5_Millis.set(0);
|
||||
count_5_10_Millis.set(0);
|
||||
count_10_20_Millis.set(0);
|
||||
|
||||
count_20_50.set(0);
|
||||
count_50_100.set(0);
|
||||
count_100_200.set(0);
|
||||
count_200_500.set(0);
|
||||
count_500_1000.set(0);
|
||||
count_20_50_Millis.set(0);
|
||||
count_50_100_Millis.set(0);
|
||||
count_100_200_Millis.set(0);
|
||||
count_200_500_Millis.set(0);
|
||||
count_500_1000_Millis.set(0);
|
||||
|
||||
count_1000_2000.set(0);
|
||||
count_2000_5000.set(0);
|
||||
count_5000_10000.set(0);
|
||||
count_10000_20000.set(0);
|
||||
count_20000_more.set(0);
|
||||
count_1_2_Seconds.set(0);
|
||||
count_2_5_Seconds.set(0);
|
||||
count_5_10_Seconds.set(0);
|
||||
count_10_30_Seconds.set(0);
|
||||
count_30_60_Seconds.set(0);
|
||||
|
||||
count_1_2_minutes.set(0);
|
||||
count_2_5_minutes.set(0);
|
||||
count_5_10_minutes.set(0);
|
||||
count_10_30_minutes.set(0);
|
||||
count_30_more_minutes.set(0);
|
||||
}
|
||||
|
||||
public void afterExecute(long nanoSpan) {
|
||||
runningCount.decrementAndGet();
|
||||
|
||||
nanoTotal.addAndGet(nanoSpan);
|
||||
|
||||
final long MILLIS = 1000 * 100;
|
||||
|
||||
final long MILLIS = 1000 * 1000;
|
||||
final long SECOND = 1000 * MILLIS;
|
||||
final long MINUTE = 60 * SECOND;
|
||||
if (nanoSpan < MILLIS) {
|
||||
count_0_1.incrementAndGet();
|
||||
count_0_1_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 2 * MILLIS) {
|
||||
count_1_2.incrementAndGet();
|
||||
count_1_2_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 5 * MILLIS) {
|
||||
count_2_5.incrementAndGet();
|
||||
count_2_5_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 10 * MILLIS) {
|
||||
count_5_10.incrementAndGet();
|
||||
count_5_10_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 20 * MILLIS) {
|
||||
count_10_20.incrementAndGet();
|
||||
|
||||
count_10_20_Millis.incrementAndGet();
|
||||
|
||||
} else if (nanoSpan < 50 * MILLIS) {
|
||||
count_20_50.incrementAndGet();
|
||||
count_20_50_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 100 * MILLIS) {
|
||||
count_50_100.incrementAndGet();
|
||||
count_50_100_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 200 * MILLIS) {
|
||||
count_100_200.incrementAndGet();
|
||||
count_100_200_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 500 * MILLIS) {
|
||||
count_200_500.incrementAndGet();
|
||||
count_200_500_Millis.incrementAndGet();
|
||||
} else if (nanoSpan < 1000 * MILLIS) {
|
||||
count_500_1000.incrementAndGet();
|
||||
count_500_1000_Millis.incrementAndGet();
|
||||
|
||||
} else if (nanoSpan < 2 * SECOND) {
|
||||
count_1_2_Seconds.incrementAndGet();
|
||||
} else if (nanoSpan < 5 * SECOND) {
|
||||
count_2_5_Seconds.incrementAndGet();
|
||||
} else if (nanoSpan < 10 * SECOND) {
|
||||
count_5_10_Seconds.incrementAndGet();
|
||||
} else if (nanoSpan < 30 * SECOND) {
|
||||
count_10_30_Seconds.incrementAndGet();
|
||||
} else if (nanoSpan < 60 * SECOND) {
|
||||
count_30_60_Seconds.incrementAndGet();
|
||||
|
||||
} else if (nanoSpan < 2000 * MILLIS) {
|
||||
count_1000_2000.incrementAndGet();
|
||||
} else if (nanoSpan < 5000 * MILLIS) {
|
||||
count_2000_5000.incrementAndGet();
|
||||
} else if (nanoSpan < 10000 * MILLIS) {
|
||||
count_5000_10000.incrementAndGet();
|
||||
} else if (nanoSpan < 20000 * MILLIS) {
|
||||
count_10000_20000.incrementAndGet();
|
||||
} else if (nanoSpan < 2 * MINUTE) {
|
||||
count_1_2_minutes.incrementAndGet();
|
||||
} else if (nanoSpan < 5 * MINUTE) {
|
||||
count_2_5_minutes.incrementAndGet();
|
||||
} else if (nanoSpan < 10 * MINUTE) {
|
||||
count_5_10_minutes.incrementAndGet();
|
||||
} else if (nanoSpan < 30 * MINUTE) {
|
||||
count_10_30_minutes.incrementAndGet();
|
||||
} else {
|
||||
count_20000_more.incrementAndGet();
|
||||
count_30_more_minutes.incrementAndGet();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -259,63 +284,83 @@ public class JdbcStatementStat implements JdbcStatementStatMBean {
|
||||
}
|
||||
|
||||
public long getCount_0_1_Millis() {
|
||||
return count_0_1.get();
|
||||
return count_0_1_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_1_2_Millis() {
|
||||
return count_1_2.get();
|
||||
return count_1_2_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_2_5_Millis() {
|
||||
return count_2_5.get();
|
||||
return count_2_5_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_5_10_Millis() {
|
||||
return count_5_10.get();
|
||||
return count_5_10_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_10_20_Millis() {
|
||||
return count_10_20.get();
|
||||
return count_10_20_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_20_50_Millis() {
|
||||
return count_20_50.get();
|
||||
return count_20_50_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_50_100_Millis() {
|
||||
return count_50_100.get();
|
||||
return count_50_100_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_100_200_Millis() {
|
||||
return count_100_200.get();
|
||||
return count_100_200_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_200_500_Millis() {
|
||||
return count_200_500.get();
|
||||
return count_200_500_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_500_1000_Millis() {
|
||||
return count_500_1000.get();
|
||||
return count_500_1000_Millis.get();
|
||||
}
|
||||
|
||||
public long getCount_1000_2000_Millis() {
|
||||
return count_1000_2000.get();
|
||||
public long getCount_1_2_Seconds() {
|
||||
return count_1_2_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_2000_5000_Millis() {
|
||||
return count_2000_5000.get();
|
||||
public long getCount_2_5_Seconds() {
|
||||
return count_2_5_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_5000_10000_Millis() {
|
||||
return count_5000_10000.get();
|
||||
public long getCount_5_10_Seconds() {
|
||||
return count_5_10_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_10000_20000_Millis() {
|
||||
return count_10000_20000.get();
|
||||
public long getCount_10_30_Seconds() {
|
||||
return count_10_30_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_20000_more_Millis() {
|
||||
return count_20000_more.get();
|
||||
public long getCount_30_60_Seconds() {
|
||||
return count_30_60_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_1_2_minutes() {
|
||||
return count_1_2_minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_2_5_minutes() {
|
||||
return count_2_5_minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_5_10_minutes() {
|
||||
return count_5_10_minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_10_30_minutes() {
|
||||
return count_10_30_minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_30_more_minutes() {
|
||||
return count_30_more_minutes.get();
|
||||
}
|
||||
|
||||
public static class Entry {
|
||||
|
||||
@@ -42,8 +42,12 @@ public class TestOracle extends TestCase {
|
||||
stmt.close();
|
||||
conn.close();
|
||||
|
||||
TabularData dataSourcesList = JdbcStatManager.getInstance().getDataSourceList();
|
||||
for (Object item : dataSourcesList.values()) {
|
||||
for (Object item : JdbcStatManager.getInstance().getDataSourceList().values()) {
|
||||
String text = JSON.toJSONString(item, SerializerFeature.UseISO8601DateFormat);
|
||||
System.out.println(JSON.toJSONString(JSON.parseObject(text, TreeMap.class), true));
|
||||
}
|
||||
|
||||
for (Object item : JdbcStatManager.getInstance().getSqlList().values()) {
|
||||
String text = JSON.toJSONString(item, SerializerFeature.UseISO8601DateFormat);
|
||||
System.out.println(JSON.toJSONString(JSON.parseObject(text, TreeMap.class), true));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user