now uses HashMap instead of Hashtable for thread-local caching

This commit is contained in:
hns 2001-01-05 15:16:08 +00:00
parent 0910855981
commit 554ec4a3a5

View file

@ -21,9 +21,9 @@ public class Transactor extends Thread {
NodeManager nmgr; NodeManager nmgr;
// List of nodes to be updated // List of nodes to be updated
private Hashtable nodes; private HashMap nodes;
// List of visited clean nodes // List of visited clean nodes
private Hashtable cleannodes; private HashMap cleannodes;
// Is a transaction in progress? // Is a transaction in progress?
private volatile boolean active; private volatile boolean active;
private volatile boolean killed; private volatile boolean killed;
@ -31,7 +31,7 @@ public class Transactor extends Thread {
// Transaction for the embedded database // Transaction for the embedded database
protected DbTxn txn; protected DbTxn txn;
// Transactions for SQL data sources // Transactions for SQL data sources
protected Hashtable sqlCon; protected HashMap sqlCon;
public Timer timer; public Timer timer;
// when did the current transaction start? // when did the current transaction start?
@ -43,9 +43,9 @@ public class Transactor extends Thread {
public Transactor (Runnable runnable, NodeManager nmgr) { public Transactor (Runnable runnable, NodeManager nmgr) {
super (Server.txgroup, runnable, "Transactor"); super (Server.txgroup, runnable, "Transactor");
this.nmgr = nmgr; this.nmgr = nmgr;
nodes = new Hashtable (); nodes = new HashMap ();
cleannodes = new Hashtable (); cleannodes = new HashMap ();
sqlCon = new Hashtable (); sqlCon = new HashMap ();
active = false; active = false;
killed = false; killed = false;
timer = new Timer(); timer = new Timer();
@ -123,8 +123,8 @@ public class Transactor extends Thread {
int ins = 0, upd = 0, dlt = 0; int ins = 0, upd = 0, dlt = 0;
int l = nodes.size (); int l = nodes.size ();
for (Enumeration e=nodes.elements (); e.hasMoreElements (); ) { for (Iterator i=nodes.values().iterator(); i.hasNext (); ) {
Node node = (Node) e.nextElement (); Node node = (Node) i.next ();
// update nodes in db // update nodes in db
int nstate = node.getState (); int nstate = node.getState ();
@ -171,8 +171,8 @@ public class Transactor extends Thread {
public synchronized void abort () throws Exception { public synchronized void abort () throws Exception {
int l = nodes.size (); int l = nodes.size ();
for (Enumeration e=nodes.elements(); e.hasMoreElements(); ) { for (Iterator i=nodes.values().iterator(); i.hasNext(); ) {
Node node = (Node) e.nextElement (); 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
// write on it and remove it from cache // write on it and remove it from cache
nmgr.evictNode (node); nmgr.evictNode (node);
@ -180,9 +180,9 @@ public class Transactor extends Thread {
} }
nodes.clear (); nodes.clear ();
cleannodes.clear (); cleannodes.clear ();
for (Enumeration e=sqlCon.elements(); e.hasMoreElements(); ) { for (Iterator i=sqlCon.values().iterator(); i.hasNext(); ) {
try { try {
Connection con = (Connection) e.nextElement (); Connection con = (Connection) i.next ();
con.close (); con.close ();
} catch (Exception ignore) {} } catch (Exception ignore) {}
} }
@ -223,9 +223,9 @@ public class Transactor extends Thread {
public void cleanup () { public void cleanup () {
if (sqlCon != null) { if (sqlCon != null) {
for (Enumeration e=sqlCon.elements(); e.hasMoreElements(); ) { for (Iterator i=sqlCon.values().iterator(); i.hasNext(); ) {
try { try {
Connection con = (Connection) e.nextElement (); Connection con = (Connection) i.next();
con.close (); con.close ();
} catch (Exception ignore) {} } catch (Exception ignore) {}
} }