mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
改进Connection和Statement的直方图计算
git-svn-id: http://code.alibabatech.com/svn/druid/trunk@909 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -190,219 +190,12 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean {
|
||||
return min / (1000 * 1000);
|
||||
}
|
||||
|
||||
final static long SECOND = 1000 * 1000 * 1000;
|
||||
final static long MINUTE = SECOND * 60;
|
||||
final static long HOUR = MINUTE * 60;
|
||||
final static long DAY = HOUR * 24;
|
||||
|
||||
public long getConnectionCount_Alive_0_1_Seconds() {
|
||||
long count = this.getConnectionStat().getCount_Alive_0_1_Seconds();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano < SECOND) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
public long[] getConnectionHistogramRanges() {
|
||||
return connectionStat.getHistogramRanges();
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_1_5_Seconds() {
|
||||
long count = this.getConnectionStat().getCount_Alive_1_5_Seconds();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= SECOND && connectionAliveNano < 5 * SECOND) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_5_10_Seconds() {
|
||||
long count = this.getConnectionStat().getCount_Alive_5_10_Seconds();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 5 * SECOND && connectionAliveNano < 10 * SECOND) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_10_30_Seconds() {
|
||||
long count = this.getConnectionStat().getCount_Alive_10_30_Seconds();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 10 * SECOND && connectionAliveNano < 30 * SECOND) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_30_60_Seconds() {
|
||||
long count = this.getConnectionStat().getCount_Alive_30_60_Seconds();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 30 * SECOND && connectionAliveNano < 60 * SECOND) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_1_5_Minutes() {
|
||||
long count = this.getConnectionStat().getCount_Alive_1_5_Minutes();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 1 * MINUTE && connectionAliveNano < 5 * MINUTE) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_5_10_Minutes() {
|
||||
long count = this.getConnectionStat().getCount_Alive_5_10_Minutes();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 5 * MINUTE && connectionAliveNano < 10 * MINUTE) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_10_30_Minutes() {
|
||||
long count = this.getConnectionStat().getCount_Alive_10_30_Minutes();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 10 * MINUTE && connectionAliveNano < 30 * MINUTE) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_30_60_Minutes() {
|
||||
long count = this.getConnectionStat().getCount_Alive_30_60_Minutes();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 30 * MINUTE && connectionAliveNano < 60 * MINUTE) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_1_6_Hours() {
|
||||
long count = this.getConnectionStat().getCount_Alive_1_6_Hours();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 1 * HOUR && connectionAliveNano < 6 * HOUR) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_6_24_Hours() {
|
||||
long count = this.getConnectionStat().getCount_Alive_6_24_Hours();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 6 * HOUR && connectionAliveNano < 24 * HOUR) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_1_7_day() {
|
||||
long count = this.getConnectionStat().getCount_Alive_1_7_Day();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 1 * DAY && connectionAliveNano < 7 * DAY) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_7_30_Day() {
|
||||
long count = this.getConnectionStat().getCount_Alive_7_30_Day();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 7 * DAY && connectionAliveNano < 30 * DAY) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_30_90_Day() {
|
||||
long count = this.getConnectionStat().getCount_Alive_30_90_Day();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 30 * DAY && connectionAliveNano < 90 * DAY) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_90_more_Day() {
|
||||
long count = this.getConnectionStat().getCount_Alive_90_more_Day();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 90 * DAY) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
public long[] getConnectionHistogramValues() {
|
||||
return connectionStat.getHistorgramValues();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user