Keep at least one DataSource in the pool when update by events.

This commit is contained in:
DigitalSonic
2020-05-05 22:21:00 +08:00
parent 75391df4ad
commit 99270819ee
5 changed files with 65 additions and 6 deletions
@@ -97,6 +97,7 @@ public class HighAvailableDataSource extends WrapperAdapter implements DataSourc
private String dataSourceFile = DEFAULT_DATA_SOURCE_FILE;
private String propertyPrefix = "";
private int poolPurgeIntervalSeconds = PoolUpdater.DEFAULT_INTERVAL;
private boolean allowEmptyPoolWhenUpdate = false;
private volatile boolean inited = false;
@@ -113,6 +114,7 @@ public class HighAvailableDataSource extends WrapperAdapter implements DataSourc
}
if (dataSourceMap == null || dataSourceMap.isEmpty()) {
poolUpdater.setIntervalSeconds(poolPurgeIntervalSeconds);
poolUpdater.setAllowEmptyPool(allowEmptyPoolWhenUpdate);
poolUpdater.init();
createNodeMap();
}
@@ -304,6 +306,14 @@ public class HighAvailableDataSource extends WrapperAdapter implements DataSourc
nodeListener.update(); // Do update in the current Thread at the startup
}
public boolean isAllowEmptyPoolWhenUpdate() {
return allowEmptyPoolWhenUpdate;
}
public void setAllowEmptyPoolWhenUpdate(boolean allowEmptyPoolWhenUpdate) {
this.allowEmptyPoolWhenUpdate = allowEmptyPoolWhenUpdate;
}
// Getters & Setters
public int getPoolPurgeIntervalSeconds() {