mirror of https://github.com/zlatinb/muwire
recycle the groovy.sql.Sql object as it tends to get very large
parent
b89bb93c26
commit
dbc4731358
|
@ -253,16 +253,24 @@ class H2HostCache extends HostCache {
|
||||||
allHosts.size()
|
allHosts.size()
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
private synchronized void initSQL() {
|
||||||
public synchronized void start(Supplier<Collection<Destination>> connected) {
|
|
||||||
this.connSupplier = connected
|
|
||||||
|
|
||||||
def db = [ url : "jdbc:h2:" + h2Home.getAbsolutePath(),
|
def db = [ url : "jdbc:h2:" + h2Home.getAbsolutePath(),
|
||||||
user : "muwire",
|
user : "muwire",
|
||||||
password : "",
|
password : "",
|
||||||
driver : "org.h2.Driver" ]
|
driver : "org.h2.Driver" ]
|
||||||
sql = Sql.newInstance(db.url, db.user, db.password, db.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," +
|
boolean success = sql.execute("CREATE TABLE IF NOT EXISTS HOST_ATTEMPTS(DESTINATION VARCHAR(1024), TSTAMP TIMESTAMP," +
|
||||||
"STATUS ENUM('SUCCESSFUL','REJECTED','FAILED'))")
|
"STATUS ENUM('SUCCESSFUL','REJECTED','FAILED'))")
|
||||||
log.info("created table attempts $success")
|
log.info("created table attempts $success")
|
||||||
|
@ -331,6 +339,7 @@ class H2HostCache extends HostCache {
|
||||||
|
|
||||||
log.fine("loaded ${allHosts.size()} hosts from db")
|
log.fine("loaded ${allHosts.size()} hosts from db")
|
||||||
timer.schedule({
|
timer.schedule({
|
||||||
|
recycleSQL()
|
||||||
purgeHopeless()
|
purgeHopeless()
|
||||||
verifyHosts()
|
verifyHosts()
|
||||||
recordConnectionCount()
|
recordConnectionCount()
|
||||||
|
|
Loading…
Reference in New Issue