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@340 b9813039-fb51-4c41-a8b9-e21c2acb5095
This commit is contained in:
@@ -884,6 +884,24 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
map.put("ConnectionErrorLastTime", stat.getConnectionStat().getErrorLastTime());
|
||||
map.put("ConnectionAliveMillisMax", stat.getConnectionConnectAliveMillisMax());
|
||||
map.put("ConnectionAliveMillisMin", stat.getConnectionConnectAliveMillisMin());
|
||||
|
||||
map.put("ConnectionCount_Alive_0_1_Seconds", stat.getConnectionCount_Alive_0_1_Seconds());
|
||||
map.put("ConnectionCount_Alive_1_5_Seconds", stat.getConnectionCount_Alive_1_5_Seconds());
|
||||
map.put("ConnectionCount_Alive_5_10_Seconds", stat.getConnectionCount_Alive_5_10_Seconds());
|
||||
map.put("ConnectionCount_Alive_10_30_Seconds", stat.getConnectionCount_Alive_10_30_Seconds());
|
||||
map.put("ConnectionCount_Alive_30_60_Seconds", stat.getConnectionCount_Alive_30_60_Seconds());
|
||||
|
||||
map.put("ConnectionCount_Alive_1_5_Minutes", stat.getConnectionCount_Alive_1_5_Minutes());
|
||||
map.put("ConnectionCount_Alive_5_10_Minutes", stat.getConnectionCount_Alive_5_10_Minutes());
|
||||
map.put("ConnectionCount_Alive_10_30_Minutes", stat.getConnectionCount_Alive_10_30_Minutes());
|
||||
map.put("ConnectionCount_Alive_30_60_Minutes", stat.getConnectionCount_Alive_30_60_Minutes());
|
||||
map.put("ConnectionCount_Alive_1_3_Hours", stat.getConnectionCount_Alive_1_3_Hours());
|
||||
|
||||
map.put("ConnectionCount_Alive_3_6_Hours", stat.getConnectionCount_Alive_3_6_Hours());
|
||||
map.put("ConnectionCount_Alive_6_12_Hours", stat.getConnectionCount_Alive_6_12_Hours());
|
||||
map.put("ConnectionCount_Alive_12_24_Hours", stat.getConnectionCount_Alive_12_24_Hours());
|
||||
map.put("ConnectionCount_Alive_1_3_Day", stat.getConnectionCount_Alive_1_3_Day());
|
||||
map.put("ConnectionCount_Alive_3_more_Day", stat.getConnectionCount_Alive_3_more_Day());
|
||||
} else {
|
||||
map.put("ConnectionActiveCount", null);
|
||||
map.put("ConnectionActiveCountMax", null);
|
||||
@@ -937,6 +955,24 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
map.put("ConnectionErrorLastTime", null);
|
||||
map.put("ConnectionAliveMillisMax", null);
|
||||
map.put("ConnectionAliveMillisMin", null);
|
||||
|
||||
map.put("ConnectionCount_Alive_0_1_Seconds", null);
|
||||
map.put("ConnectionCount_Alive_1_5_Seconds", null);
|
||||
map.put("ConnectionCount_Alive_5_10_Seconds", null);
|
||||
map.put("ConnectionCount_Alive_10_30_Seconds", null);
|
||||
map.put("ConnectionCount_Alive_30_60_Seconds", null);
|
||||
|
||||
map.put("ConnectionCount_Alive_1_5_Minutes", null);
|
||||
map.put("ConnectionCount_Alive_5_10_Minutes", null);
|
||||
map.put("ConnectionCount_Alive_10_30_Minutes", null);
|
||||
map.put("ConnectionCount_Alive_30_60_Minutes", null);
|
||||
map.put("ConnectionCount_Alive_1_3_Hours", null);
|
||||
|
||||
map.put("ConnectionCount_Alive_3_6_Hours", null);
|
||||
map.put("ConnectionCount_Alive_6_12_Hours", null);
|
||||
map.put("ConnectionCount_Alive_12_24_Hours", null);
|
||||
map.put("ConnectionCount_Alive_1_3_Day", null);
|
||||
map.put("ConnectionCount_Alive_3_more_Day", null);
|
||||
}
|
||||
|
||||
return new CompositeDataSupport(JdbcStatManager.getDataSourceCompositeType(), map);
|
||||
|
||||
@@ -290,6 +290,24 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
|
||||
map.put("ConnectionErrorLastTime", stat.getConnectionStat().getErrorLastTime());
|
||||
map.put("ConnectionAliveMillisMax", stat.getConnectionConnectAliveMillisMax());
|
||||
map.put("ConnectionAliveMillisMin", stat.getConnectionConnectAliveMillisMin());
|
||||
|
||||
map.put("ConnectionCount_Alive_0_1_Seconds", stat.getConnectionCount_Alive_0_1_Seconds());
|
||||
map.put("ConnectionCount_Alive_1_5_Seconds", stat.getConnectionCount_Alive_1_5_Seconds());
|
||||
map.put("ConnectionCount_Alive_5_10_Seconds", stat.getConnectionCount_Alive_5_10_Seconds());
|
||||
map.put("ConnectionCount_Alive_10_30_Seconds", stat.getConnectionCount_Alive_10_30_Seconds());
|
||||
map.put("ConnectionCount_Alive_30_60_Seconds", stat.getConnectionCount_Alive_30_60_Seconds());
|
||||
|
||||
map.put("ConnectionCount_Alive_1_5_Minutes", stat.getConnectionCount_Alive_1_5_Minutes());
|
||||
map.put("ConnectionCount_Alive_5_10_Minutes", stat.getConnectionCount_Alive_5_10_Minutes());
|
||||
map.put("ConnectionCount_Alive_10_30_Minutes", stat.getConnectionCount_Alive_10_30_Minutes());
|
||||
map.put("ConnectionCount_Alive_30_60_Minutes", stat.getConnectionCount_Alive_30_60_Minutes());
|
||||
map.put("ConnectionCount_Alive_1_3_Hours", stat.getConnectionCount_Alive_1_3_Hours());
|
||||
|
||||
map.put("ConnectionCount_Alive_3_6_Hours", stat.getConnectionCount_Alive_3_6_Hours());
|
||||
map.put("ConnectionCount_Alive_6_12_Hours", stat.getConnectionCount_Alive_6_12_Hours());
|
||||
map.put("ConnectionCount_Alive_12_24_Hours", stat.getConnectionCount_Alive_12_24_Hours());
|
||||
map.put("ConnectionCount_Alive_1_3_Day", stat.getConnectionCount_Alive_1_3_Day());
|
||||
map.put("ConnectionCount_Alive_3_more_Day", stat.getConnectionCount_Alive_3_more_Day());
|
||||
} else {
|
||||
map.put("ConnectionActiveCount", null);
|
||||
map.put("ConnectionActiveCountMax", null);
|
||||
@@ -343,6 +361,27 @@ public class DataSourceProxyImpl implements DataSourceProxy, DataSourceProxyImpl
|
||||
map.put("ConnectionErrorLastTime", null);
|
||||
map.put("ConnectionAliveMillisMax", null);
|
||||
map.put("ConnectionAliveMillisMin", null);
|
||||
|
||||
|
||||
map.put("ConnectionCount_Alive_0_1_Seconds", null);
|
||||
map.put("ConnectionCount_Alive_1_5_Seconds", null);
|
||||
map.put("ConnectionCount_Alive_5_10_Seconds", null);
|
||||
map.put("ConnectionCount_Alive_10_30_Seconds", null);
|
||||
map.put("ConnectionCount_Alive_30_60_Seconds", null);
|
||||
|
||||
map.put("ConnectionCount_Alive_1_5_Minutes", null);
|
||||
map.put("ConnectionCount_Alive_5_10_Minutes", null);
|
||||
map.put("ConnectionCount_Alive_10_30_Minutes", null);
|
||||
map.put("ConnectionCount_Alive_30_60_Minutes", null);
|
||||
map.put("ConnectionCount_Alive_1_3_Hours", null);
|
||||
|
||||
map.put("ConnectionCount_Alive_3_6_Hours", null);
|
||||
map.put("ConnectionCount_Alive_6_12_Hours", null);
|
||||
map.put("ConnectionCount_Alive_12_24_Hours", null);
|
||||
map.put("ConnectionCount_Alive_1_3_Day", null);
|
||||
map.put("ConnectionCount_Alive_3_more_Day", null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
return new CompositeDataSupport(JdbcStatManager.getDataSourceCompositeType(), map);
|
||||
|
||||
@@ -36,32 +36,50 @@ import com.alibaba.druid.util.JMXUtils;
|
||||
*/
|
||||
public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
|
||||
private final AtomicInteger activeCount = new AtomicInteger();
|
||||
private final AtomicInteger activeCountMax = new AtomicInteger();
|
||||
|
||||
private final AtomicInteger connectingCount = new AtomicInteger();
|
||||
private final AtomicInteger connectingMax = new AtomicInteger();
|
||||
private final AtomicInteger activeCount = new AtomicInteger();
|
||||
private final AtomicInteger activeCountMax = new AtomicInteger();
|
||||
|
||||
private final AtomicLong connectCount = new AtomicLong();
|
||||
private final AtomicLong connectErrorCount = new AtomicLong();
|
||||
private final AtomicInteger connectingCount = new AtomicInteger();
|
||||
private final AtomicInteger connectingMax = new AtomicInteger();
|
||||
|
||||
private final AtomicLong connectCount = new AtomicLong();
|
||||
private final AtomicLong connectErrorCount = new AtomicLong();
|
||||
private Throwable connectErrorLast;
|
||||
private final AtomicLong connectNanoTotal = new AtomicLong(0); // 连接建立消耗时间总和(纳秒)
|
||||
private final AtomicLong connectNanoMax = new AtomicLong(0); // 连接建立消耗最大时间(纳秒)
|
||||
private final AtomicLong connectNanoTotal = new AtomicLong(0); // 连接建立消耗时间总和(纳秒)
|
||||
private final AtomicLong connectNanoMax = new AtomicLong(0); // 连接建立消耗最大时间(纳秒)
|
||||
|
||||
private final AtomicLong errorCount = new AtomicLong();
|
||||
private final AtomicLong errorCount = new AtomicLong();
|
||||
|
||||
private final AtomicLong aliveNanoTotal = new AtomicLong();
|
||||
private final AtomicLong aliveNanoTotal = new AtomicLong();
|
||||
private Throwable lastError;
|
||||
private long lastErrorTime;
|
||||
|
||||
private long connectLastTime = 0;
|
||||
private long connectLastTime = 0;
|
||||
|
||||
private final AtomicLong closeCount = new AtomicLong(0); // 执行Connection.close的计数
|
||||
private final AtomicLong commitCount = new AtomicLong(0); // 执行commit的计数
|
||||
private final AtomicLong rollbackCount = new AtomicLong(0); // 执行rollback的计数
|
||||
|
||||
private final AtomicLong aliveNanoMin = new AtomicLong();
|
||||
private final AtomicLong aliveNanoMax = new AtomicLong();
|
||||
private final AtomicLong closeCount = new AtomicLong(0); // 执行Connection.close的计数
|
||||
private final AtomicLong commitCount = new AtomicLong(0); // 执行commit的计数
|
||||
private final AtomicLong rollbackCount = new AtomicLong(0); // 执行rollback的计数
|
||||
|
||||
private final AtomicLong aliveNanoMin = new AtomicLong();
|
||||
private final AtomicLong aliveNanoMax = new AtomicLong();
|
||||
|
||||
private final AtomicLong count_Alive_0_1_Seconds = new AtomicLong();
|
||||
private final AtomicLong count_Alive_1_5_Seconds = new AtomicLong();
|
||||
private final AtomicLong count_Alive_5_10_Seconds = new AtomicLong();
|
||||
private final AtomicLong count_Alive_10_30_Seconds = new AtomicLong();
|
||||
private final AtomicLong count_Alive_30_60_Seconds = new AtomicLong();
|
||||
|
||||
private final AtomicLong count_Alive_1_5_Minutes = new AtomicLong();
|
||||
private final AtomicLong count_Alive_5_10_Minutes = new AtomicLong();
|
||||
private final AtomicLong count_Alive_10_30_Minutes = new AtomicLong();
|
||||
private final AtomicLong count_Alive_30_60_Minutes = new AtomicLong();
|
||||
private final AtomicLong count_Alive_1_3_Hours = new AtomicLong();
|
||||
|
||||
private final AtomicLong count_Alive_3_6_Hours = new AtomicLong();
|
||||
private final AtomicLong count_Alive_6_12_Hours = new AtomicLong();
|
||||
private final AtomicLong count_Alive_12_24_Hours = new AtomicLong();
|
||||
private final AtomicLong count_Alive_1_3_Day = new AtomicLong();
|
||||
private final AtomicLong count_Alive_3_more_Day = new AtomicLong();
|
||||
|
||||
public void reset() {
|
||||
connectingMax.set(0);
|
||||
@@ -80,6 +98,24 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
rollbackCount.set(0);
|
||||
connectNanoTotal.set(0);
|
||||
connectNanoMax.set(0);
|
||||
|
||||
count_Alive_0_1_Seconds.set(0);
|
||||
count_Alive_1_5_Seconds.set(0);
|
||||
count_Alive_5_10_Seconds.set(0);
|
||||
count_Alive_10_30_Seconds.set(0);
|
||||
count_Alive_30_60_Seconds.set(0);
|
||||
|
||||
count_Alive_1_5_Minutes.set(0);
|
||||
count_Alive_5_10_Minutes.set(0);
|
||||
count_Alive_10_30_Minutes.set(0);
|
||||
count_Alive_30_60_Minutes.set(0);
|
||||
count_Alive_1_3_Hours.set(0);
|
||||
|
||||
count_Alive_3_6_Hours.set(0);
|
||||
count_Alive_6_12_Hours.set(0);
|
||||
count_Alive_12_24_Hours.set(0);
|
||||
count_Alive_1_3_Day.set(0);
|
||||
count_Alive_3_more_Day.set(0);
|
||||
}
|
||||
|
||||
public void beforeConnect() {
|
||||
@@ -101,12 +137,12 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
connectCount.incrementAndGet();
|
||||
connectLastTime = System.currentTimeMillis();
|
||||
}
|
||||
|
||||
|
||||
public void afterConnected(long delta) {
|
||||
connectingCount.decrementAndGet();
|
||||
connectNanoTotal.addAndGet(delta);
|
||||
for (;;) {
|
||||
//connectNanoMax
|
||||
// connectNanoMax
|
||||
long max = connectNanoMax.get();
|
||||
if (delta > max) {
|
||||
if (connectNanoMax.compareAndSet(max, delta)) {
|
||||
@@ -118,14 +154,14 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
activeCount.incrementAndGet();
|
||||
}
|
||||
|
||||
|
||||
public long getConnectNanoMax() {
|
||||
return this.connectNanoMax.get();
|
||||
}
|
||||
|
||||
|
||||
public long getConnectMillisMax() {
|
||||
return this.connectNanoMax.get() / (1000 * 1000);
|
||||
}
|
||||
@@ -146,11 +182,11 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public int getActiveCount() {
|
||||
return activeCount.get();
|
||||
}
|
||||
|
||||
|
||||
public int getAtiveCountMax() {
|
||||
return this.activeCount.get();
|
||||
}
|
||||
@@ -170,19 +206,19 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
public long getAliveTotal() {
|
||||
return aliveNanoTotal.get();
|
||||
}
|
||||
|
||||
|
||||
public long getAliveNanoMin() {
|
||||
return aliveNanoMin.get();
|
||||
}
|
||||
|
||||
|
||||
public long getAliveMillisMin() {
|
||||
return aliveNanoMin.get() / (1000 * 1000);
|
||||
}
|
||||
|
||||
|
||||
public long getAliveNanoMax() {
|
||||
return aliveNanoMax.get();
|
||||
}
|
||||
|
||||
|
||||
public long getAliveMillisMax() {
|
||||
return aliveNanoMax.get() / (1000 * 1000);
|
||||
}
|
||||
@@ -190,7 +226,7 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
public void afterClose(long aliveNano) {
|
||||
activeCount.decrementAndGet();
|
||||
aliveNanoTotal.addAndGet(aliveNano);
|
||||
|
||||
|
||||
for (;;) {
|
||||
long max = aliveNanoMax.get();
|
||||
if (aliveNano > max) {
|
||||
@@ -203,7 +239,7 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
for (;;) {
|
||||
long min = aliveNanoMin.get();
|
||||
if (min == 0 || aliveNano < min) {
|
||||
@@ -216,7 +252,45 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
break;
|
||||
}
|
||||
}
|
||||
//holdTimeMin
|
||||
|
||||
final long SECOND = 1000 * 1000 * 1000;
|
||||
final long MINUTE = SECOND * 60;
|
||||
final long HOUR = MINUTE * 60;
|
||||
final long DAY = HOUR * 24;
|
||||
if (aliveNano < 1 * SECOND) {
|
||||
count_Alive_0_1_Seconds.incrementAndGet();
|
||||
} else if (aliveNano < 5 * SECOND) {
|
||||
count_Alive_1_5_Seconds.incrementAndGet();
|
||||
} else if (aliveNano < 10 * SECOND) {
|
||||
count_Alive_5_10_Seconds.incrementAndGet();
|
||||
} else if (aliveNano < 30 * SECOND) {
|
||||
count_Alive_10_30_Seconds.incrementAndGet();
|
||||
} else if (aliveNano < 60 * SECOND) {
|
||||
count_Alive_30_60_Seconds.incrementAndGet();
|
||||
|
||||
} else if (aliveNano < 5 * MINUTE) {
|
||||
count_Alive_1_5_Minutes.incrementAndGet();
|
||||
} else if (aliveNano < 10 * MINUTE) {
|
||||
count_Alive_5_10_Minutes.incrementAndGet();
|
||||
} else if (aliveNano < 30 * MINUTE) {
|
||||
count_Alive_10_30_Minutes.incrementAndGet();
|
||||
} else if (aliveNano < 60 * MINUTE) {
|
||||
count_Alive_30_60_Minutes.incrementAndGet();
|
||||
} else if (aliveNano < 3 * HOUR) {
|
||||
count_Alive_1_3_Hours.incrementAndGet();
|
||||
|
||||
} else if (aliveNano < 6 * HOUR) {
|
||||
count_Alive_3_6_Hours.incrementAndGet();
|
||||
} else if (aliveNano < 12 * HOUR) {
|
||||
count_Alive_6_12_Hours.incrementAndGet();
|
||||
} else if (aliveNano < 24 * HOUR) {
|
||||
count_Alive_12_24_Hours.incrementAndGet();
|
||||
} else if (aliveNano < 3 * DAY) {
|
||||
count_Alive_1_3_Day.incrementAndGet();
|
||||
} else {
|
||||
count_Alive_3_more_Day.incrementAndGet();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public Throwable getErrorLast() {
|
||||
@@ -294,8 +368,6 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
return new Date(connectLastTime);
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void incrementConnectionCloseCount() {
|
||||
closeCount.incrementAndGet();
|
||||
}
|
||||
@@ -477,4 +549,64 @@ public class JdbcConnectionStat implements JdbcConnectionStatMBean {
|
||||
|
||||
void reset();
|
||||
}
|
||||
|
||||
public long getCount_Alive_0_1_Seconds() {
|
||||
return count_Alive_0_1_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_1_5_Seconds() {
|
||||
return count_Alive_1_5_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_5_10_Seconds() {
|
||||
return count_Alive_5_10_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_10_30_Seconds() {
|
||||
return count_Alive_10_30_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_30_60_Seconds() {
|
||||
return count_Alive_30_60_Seconds.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_1_5_Minutes() {
|
||||
return count_Alive_1_5_Minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_5_10_Minutes() {
|
||||
return count_Alive_5_10_Minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_10_30_Minutes() {
|
||||
return count_Alive_10_30_Minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_30_60_Minutes() {
|
||||
return count_Alive_30_60_Minutes.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_1_3_Hours() {
|
||||
return count_Alive_1_3_Hours.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_3_6_Hours() {
|
||||
return count_Alive_3_6_Hours.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_6_12_Hours() {
|
||||
return count_Alive_6_12_Hours.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_12_24_Hours() {
|
||||
return count_Alive_12_24_Hours.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_1_3_Day() {
|
||||
return count_Alive_1_3_Day.get();
|
||||
}
|
||||
|
||||
public long getCount_Alive_3_more_Day() {
|
||||
return count_Alive_3_more_Day.get();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -162,11 +162,11 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean {
|
||||
}
|
||||
return aliveNanoSpan / (1000 * 1000);
|
||||
}
|
||||
|
||||
|
||||
public long getConnectionConnectAliveMillisMax() {
|
||||
long nowNano = System.nanoTime();
|
||||
long max = this.getConnectionStat().getAliveNanoMax();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano > max) {
|
||||
@@ -175,11 +175,11 @@ public class JdbcDataSourceStat implements JdbcDataSourceStatMBean {
|
||||
}
|
||||
return max / (1000 * 1000);
|
||||
}
|
||||
|
||||
|
||||
public long getConnectionConnectAliveMillisMin() {
|
||||
long nowNano = System.nanoTime();
|
||||
long min = this.getConnectionStat().getAliveNanoMin();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano < min || min == 0) {
|
||||
@@ -188,4 +188,220 @@ 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 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_3_Hours() {
|
||||
long count = this.getConnectionStat().getCount_Alive_1_3_Hours();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 1 * HOUR && connectionAliveNano < 3 * HOUR) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_3_6_Hours() {
|
||||
long count = this.getConnectionStat().getCount_Alive_3_6_Hours();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 3 * HOUR && connectionAliveNano < 6 * HOUR) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_6_12_Hours() {
|
||||
long count = this.getConnectionStat().getCount_Alive_6_12_Hours();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 6 * HOUR && connectionAliveNano < 12 * HOUR) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_12_24_Hours() {
|
||||
long count = this.getConnectionStat().getCount_Alive_12_24_Hours();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 12 * HOUR && connectionAliveNano < 24 * HOUR) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_1_3_Day() {
|
||||
long count = this.getConnectionStat().getCount_Alive_1_3_Day();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 1 * DAY && connectionAliveNano < 2 * DAY) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
public long getConnectionCount_Alive_3_more_Day() {
|
||||
long count = this.getConnectionStat().getCount_Alive_3_more_Day();
|
||||
|
||||
long nowNano = System.nanoTime();
|
||||
for (JdbcConnectionStat.Entry connection : connections.values()) {
|
||||
long connectionAliveNano = nowNano - connection.getEstablishNano();
|
||||
if (connectionAliveNano >= 2 * DAY) {
|
||||
count++;
|
||||
}
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -116,33 +116,29 @@ public class JdbcStatManager implements JdbcStatManagerMBean {
|
||||
, SimpleType.LONG, SimpleType.INTEGER, SimpleType.INTEGER, SimpleType.LONG, SimpleType.DATE //
|
||||
, SimpleType.LONG, SimpleType.LONG, SimpleType.DATE, SimpleType.STRING, SimpleType.STRING //
|
||||
, SimpleType.LONG, SimpleType.STRING, SimpleType.STRING, SimpleType.LONG, SimpleType.INTEGER //
|
||||
, SimpleType.LONG, SimpleType.DATE, SimpleType.LONG, SimpleType.LONG
|
||||
, SimpleType.LONG, SimpleType.DATE, 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", "URL", "Name",
|
||||
"FilterClasses",
|
||||
"CreatedTime", //
|
||||
"RawUrl", "RawDriverClassName", "RawDriverMajorVersion",
|
||||
"RawDriverMinorVersion",
|
||||
"Properties" //
|
||||
, "ConnectionActiveCount", "ConnectionActiveCountMax", "ConnectionCloseCount",
|
||||
"ConnectionCommitCount",
|
||||
"ConnectionRollbackCount" //
|
||||
, "ConnectionConnectLastTime", "ConnectionConnectErrorCount", "ConnectionConnectErrorLastTime",
|
||||
"ConnectionConnectErrorLastMessage",
|
||||
"ConnectionConnectErrorLastStackTrace" //
|
||||
, "StatementCreateCount", "StatementPrepareCount", "StatementPreCallCount", "StatementExecuteCount",
|
||||
"StatementRunningCount" //
|
||||
, "StatementConcurrentMax", "StatementCloseCount", "StatementErrorCount", "StatementLastErrorTime",
|
||||
"StatementLastErrorMessage" //
|
||||
, "StatementLastErrorStackTrace", "StatementExecuteMillis", "ConnectionConnectingCount", "StatementExecuteLastTime",
|
||||
"ResultSetCloseCount" //
|
||||
, "ResultSetOpenCount", "ResultSetOpenningCount", "ResultSetOpenningMax", "ResultSetFetchRowCount",
|
||||
"ResultSetLastOpenTime" //
|
||||
, "ResultSetErrorCount", "ResultSetOpenningMillisTotal", "ResultSetLastErrorTime", "ResultSetLastErrorMessage", "ResultSetLastErrorStackTrace",
|
||||
"ConnectionConnectCount", "ConnectionErrorLastMessage", "ConnectionErrorLastStackTrace", "ConnectionConnectMillisTotal", "ConnectionConnectingCountMax" //
|
||||
, "ConnectionConnectMillisMax", "ConnectionErrorLastTime", "ConnectionAliveMillisMax", "ConnectionAliveMillisMin"
|
||||
String[] indexNames = { "ID", "URL", "Name", "FilterClasses", "CreatedTime", //
|
||||
"RawUrl", "RawDriverClassName", "RawDriverMajorVersion", "RawDriverMinorVersion", "Properties" //
|
||||
, "ConnectionActiveCount", "ConnectionActiveCountMax", "ConnectionCloseCount", "ConnectionCommitCount", "ConnectionRollbackCount" //
|
||||
, "ConnectionConnectLastTime", "ConnectionConnectErrorCount", "ConnectionConnectErrorLastTime", "ConnectionConnectErrorLastMessage", "ConnectionConnectErrorLastStackTrace" //
|
||||
, "StatementCreateCount", "StatementPrepareCount", "StatementPreCallCount", "StatementExecuteCount", "StatementRunningCount" //
|
||||
, "StatementConcurrentMax", "StatementCloseCount", "StatementErrorCount", "StatementLastErrorTime", "StatementLastErrorMessage" //
|
||||
, "StatementLastErrorStackTrace", "StatementExecuteMillis", "ConnectionConnectingCount", "StatementExecuteLastTime", "ResultSetCloseCount" //
|
||||
, "ResultSetOpenCount", "ResultSetOpenningCount", "ResultSetOpenningMax", "ResultSetFetchRowCount", "ResultSetLastOpenTime" //
|
||||
, "ResultSetErrorCount", "ResultSetOpenningMillisTotal", "ResultSetLastErrorTime", "ResultSetLastErrorMessage", "ResultSetLastErrorStackTrace", "ConnectionConnectCount", "ConnectionErrorLastMessage", "ConnectionErrorLastStackTrace", "ConnectionConnectMillisTotal", "ConnectionConnectingCountMax" //
|
||||
, "ConnectionConnectMillisMax", "ConnectionErrorLastTime", "ConnectionAliveMillisMax", "ConnectionAliveMillisMin" //
|
||||
//
|
||||
, "ConnectionCount_Alive_0_1_Seconds", "ConnectionCount_Alive_1_5_Seconds", "ConnectionCount_Alive_5_10_Seconds", "ConnectionCount_Alive_10_30_Seconds", "ConnectionCount_Alive_30_60_Seconds" //
|
||||
, "ConnectionCount_Alive_1_5_Minutes", "ConnectionCount_Alive_5_10_Minutes", "ConnectionCount_Alive_10_30_Minutes", "ConnectionCount_Alive_30_60_Minutes", "ConnectionCount_Alive_1_3_Hours" //
|
||||
, "ConnectionCount_Alive_3_6_Hours", "ConnectionCount_Alive_6_12_Hours", "ConnectionCount_Alive_12_24_Hours", "ConnectionCount_Alive_1_3_Day", "ConnectionCount_Alive_3_more_Day" //
|
||||
//
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user