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()
|
||||
}
|
||||
|
||||
@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()
|
||||
|
|
Loading…
Reference in New Issue