db-torque-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tfisc...@apache.org
Subject svn commit: r1237865 - /db/torque/torque4/trunk/torque-runtime/src/main/java/org/apache/torque/oid/IDBroker.java
Date Mon, 30 Jan 2012 18:04:36 GMT
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: torque-dev-unsubscribe@db.apache.org
For additional commands, e-mail: torque-dev-help@db.apache.org


Mime
View raw message