mirror of
https://github.com/alibaba/druid.git
synced 2023-03-04 19:17:16 +00:00
ha
This commit is contained in:
@@ -108,6 +108,9 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
|
||||
private String initStackTrace;
|
||||
|
||||
private Throwable lastError;
|
||||
private Throwable lastCreateError;
|
||||
|
||||
public DruidDataSource(){
|
||||
}
|
||||
|
||||
@@ -123,6 +126,14 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
this.resetStatEnable = resetStatEnable;
|
||||
}
|
||||
|
||||
public Throwable getLastCreateError() {
|
||||
return lastCreateError;
|
||||
}
|
||||
|
||||
public Throwable getLastError() {
|
||||
return this.lastError;
|
||||
}
|
||||
|
||||
public void restart() {
|
||||
lock.lock();
|
||||
try {
|
||||
@@ -501,6 +512,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
final ConnectionHolder holder = pooledConnection.getConnectionHolder();
|
||||
|
||||
errorCount.incrementAndGet();
|
||||
lastError = t;
|
||||
|
||||
if (t instanceof SQLException) {
|
||||
SQLException sqlEx = (SQLException) t;
|
||||
@@ -717,7 +729,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
if (notEmptyWaitThreadCount > notEmptyWaitThreadPeak) {
|
||||
notEmptyWaitThreadPeak = notEmptyWaitThreadCount;
|
||||
}
|
||||
|
||||
|
||||
try {
|
||||
long startEstimate = estimate;
|
||||
estimate = notEmpty.awaitNanos(estimate); // signal by
|
||||
@@ -864,10 +876,13 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
}
|
||||
|
||||
} catch (InterruptedException e) {
|
||||
lastCreateError = e;
|
||||
break;
|
||||
} catch (RuntimeException e) {
|
||||
lastCreateError = e;
|
||||
LOG.error("create connection error", e);
|
||||
} catch (Error e) {
|
||||
lastCreateError = e;
|
||||
LOG.error("create connection error", e);
|
||||
break;
|
||||
} finally {
|
||||
@@ -1150,7 +1165,7 @@ public class DruidDataSource extends DruidAbstractDataSource implements DruidDat
|
||||
public int getNotEmptyWaitThreadCount() {
|
||||
return notEmptyWaitThreadCount;
|
||||
}
|
||||
|
||||
|
||||
public int getNotEmptyWaitThreadPeak() {
|
||||
lock.lock();
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user