moved closing of SQL connection to a separate method
This commit is contained in:
parent
8cdb43c6ac
commit
c94f3e5a6b
1 changed files with 9 additions and 12 deletions
|
@ -142,7 +142,7 @@ public class Transactor extends Thread {
|
||||||
nmgr.updateNode (nmgr.db, txn, node);
|
nmgr.updateNode (nmgr.db, txn, node);
|
||||||
node.setState (Node.CLEAN);
|
node.setState (Node.CLEAN);
|
||||||
upd++;
|
upd++;
|
||||||
IServer.getLogger().log ("updated: "+node.getFullName ());
|
IServer.getLogger().log ("updated: Node "+node.getName ()+"/"+node.getID ());
|
||||||
} else if (nstate == Node.DELETED) {
|
} else if (nstate == Node.DELETED) {
|
||||||
// IServer.getLogger().log ("deleted: "+node.getFullName ()+" ("+node.getName ()+")");
|
// IServer.getLogger().log ("deleted: "+node.getFullName ()+" ("+node.getName ()+")");
|
||||||
nmgr.deleteNode (nmgr.db, txn, node);
|
nmgr.deleteNode (nmgr.db, txn, node);
|
||||||
|
@ -156,7 +156,6 @@ public class Transactor extends Thread {
|
||||||
|
|
||||||
nodes.clear ();
|
nodes.clear ();
|
||||||
cleannodes.clear ();
|
cleannodes.clear ();
|
||||||
// sqlCon.clear ();
|
|
||||||
|
|
||||||
if (nmgr.idgen.dirty) {
|
if (nmgr.idgen.dirty) {
|
||||||
nmgr.db.save (txn, "idgen", nmgr.idgen);
|
nmgr.db.save (txn, "idgen", nmgr.idgen);
|
||||||
|
@ -174,7 +173,6 @@ public class Transactor extends Thread {
|
||||||
|
|
||||||
public synchronized void abort () throws Exception {
|
public synchronized void abort () throws Exception {
|
||||||
|
|
||||||
int l = nodes.size ();
|
|
||||||
for (Iterator i=nodes.values().iterator(); i.hasNext(); ) {
|
for (Iterator i=nodes.values().iterator(); i.hasNext(); ) {
|
||||||
Node node = (Node) i.next ();
|
Node node = (Node) i.next ();
|
||||||
// Declare node as invalid, so it won't be used by other threads that want to
|
// Declare node as invalid, so it won't be used by other threads that want to
|
||||||
|
@ -184,13 +182,8 @@ public class Transactor extends Thread {
|
||||||
}
|
}
|
||||||
nodes.clear ();
|
nodes.clear ();
|
||||||
cleannodes.clear ();
|
cleannodes.clear ();
|
||||||
for (Iterator i=sqlCon.values().iterator(); i.hasNext(); ) {
|
// close any JDBC connections associated with this transactor thread
|
||||||
try {
|
closeConnections ();
|
||||||
Connection con = (Connection) i.next ();
|
|
||||||
con.close ();
|
|
||||||
} catch (Exception ignore) {}
|
|
||||||
}
|
|
||||||
sqlCon.clear ();
|
|
||||||
|
|
||||||
if (active) {
|
if (active) {
|
||||||
active = false;
|
active = false;
|
||||||
|
@ -220,20 +213,24 @@ public class Transactor extends Thread {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void cleanup () {
|
public void closeConnections () {
|
||||||
// IServer.getLogger().log("Cleaning up Transactor thread");
|
// IServer.getLogger().log("Cleaning up Transactor thread");
|
||||||
if (sqlCon != null) {
|
if (sqlCon != null) {
|
||||||
for (Iterator i=sqlCon.values().iterator(); i.hasNext(); ) {
|
for (Iterator i=sqlCon.values().iterator(); i.hasNext(); ) {
|
||||||
try {
|
try {
|
||||||
Connection con = (Connection) i.next();
|
Connection con = (Connection) i.next();
|
||||||
con.close ();
|
con.close ();
|
||||||
|
IServer.getLogger ().log ("Closing DB connection: "+con);
|
||||||
} catch (Exception ignore) {}
|
} catch (Exception ignore) {}
|
||||||
}
|
}
|
||||||
sqlCon.clear ();
|
sqlCon.clear ();
|
||||||
sqlCon = null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String toString () {
|
||||||
|
return "Transactor["+tname+"]";
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue