recycle the groovy.sql.Sql object as it tends to get very large

reproducible
Zlatin Balevsky 2021-02-25 17:20:13 +00:00
parent b89bb93c26
commit dbc4731358
No known key found for this signature in database
GPG Key ID: A72832072D525E41
1 changed files with 13 additions and 4 deletions

View File

@ -253,16 +253,24 @@ class H2HostCache extends HostCache {
allHosts.size()
}
@Override
public synchronized void start(Supplier<Collection<Destination>> connected) {
this.connSupplier = connected
private synchronized void initSQL() {
def db = [ url : "jdbc:h2:" + h2Home.getAbsolutePath(),
user : "muwire",
password : "",
driver : "org.h2.Driver" ]
sql = Sql.newInstance(db.url, db.user, db.password, db.driver)
}
private synchronized void recycleSQL() {
sql?.close()
initSQL()
}
@Override
public synchronized void start(Supplier<Collection<Destination>> connected) {
this.connSupplier = connected
initSQL()
boolean success = sql.execute("CREATE TABLE IF NOT EXISTS HOST_ATTEMPTS(DESTINATION VARCHAR(1024), TSTAMP TIMESTAMP," +
"STATUS ENUM('SUCCESSFUL','REJECTED','FAILED'))")
log.info("created table attempts $success")
@ -331,6 +339,7 @@ class H2HostCache extends HostCache {
log.fine("loaded ${allHosts.size()} hosts from db")
timer.schedule({
recycleSQL()
purgeHopeless()
verifyHosts()
recordConnectionCount()