Author: tfischer
Date: Mon Jan 30 18:04:36 2012
New Revision: 1237865
URL: http://svn.apache.org/viewvc?rev=1237865&view=rev
Log:
- TORQUE-117 clear cached ids when idbroker is stopped
- provide a method to check whether the housekeeping thread is still running
- make housekeeper thread stop immediately on stop()
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
Modified:
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
URL:
http://svn.apache.org/viewvc/db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java?rev=1237865&r1=1237864&r2=1237865&view=diff
==============================================================================
---
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
(original)
+++
db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
Mon Jan 30 18:04:36 2012
@@ -164,6 +164,9 @@ public class IDBroker implements Runnabl
*/
private boolean transactionsSupported = false;
+ /** Whether the idBroker thread is running or not. */
+ private boolean threadRunning = false;
+
/**
* The value of ONE!
*/
@@ -388,6 +391,16 @@ public class IDBroker implements Runnabl
}
/**
+ * Returns whether the idbroker thread is running.
+ *
+ * @return true if the thread is running, false otherwise.
+ */
+ public boolean isThreadRunning()
+ {
+ return threadRunning;
+ }
+
+ /**
* This method returns x number of ids for the given table.
*
* @param tableName The name of the table for which we want an id.
@@ -520,6 +533,7 @@ public class IDBroker implements Runnabl
public void run()
{
log.debug("IDBroker thread was started.");
+ threadRunning = true;
Thread thisThread = Thread.currentThread();
while (houseKeeperThread == thisThread)
@@ -565,6 +579,7 @@ public class IDBroker implements Runnabl
}
}
log.debug("IDBroker thread finished.");
+ threadRunning = false;
}
/**
@@ -575,7 +590,16 @@ public class IDBroker implements Runnabl
*/
public void stop()
{
- houseKeeperThread = null;
+ if (houseKeeperThread != null)
+ {
+ Thread localHouseKeeperThread = houseKeeperThread;
+ houseKeeperThread = null;
+ localHouseKeeperThread.interrupt();
+ }
+ ids.clear();
+ lastQueryTime.clear();
+ quantityStore.clear();
+ transactionsSupported = false;
}
/**
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]