changeset 342:84bfba8a1c9e

servlet version 1.5.5b - output of the number of running and waiting threads in dlConfig.jsp
author robcast
date Thu, 18 Nov 2004 21:37:26 +0100
parents d10e4ce2a153
children d4c302cdeed1
files client/digitallibrary/WEB-INF/lib/DigilibServlet.jar client/digitallibrary/server/dlConfig.jsp servlet/src/digilib/servlet/DigilibWorker.java servlet/src/digilib/servlet/Scaler.java
diffstat 4 files changed, 33 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
Binary file client/digitallibrary/WEB-INF/lib/DigilibServlet.jar has changed
--- a/client/digitallibrary/server/dlConfig.jsp	Wed Nov 17 19:30:34 2004 +0100
+++ b/client/digitallibrary/server/dlConfig.jsp	Thu Nov 18 21:37:26 2004 +0100
@@ -65,6 +65,19 @@
 %>
 </table>
 
+<h2>Threads</h2>
+
+<table>
+  <tr>
+    <td>currently waiting</td><td><b><%= digilib.servlet.DigilibWorker.getNumWaiting() %></b></td>
+    <td></td>
+  </tr>
+  <tr>
+    <td>currently running</td><td><b><%= digilib.servlet.DigilibWorker.getNumRunning() %></b></td>
+    <td></td>
+  </tr>
+</table>
+
 <h2>Directory cache</h2>
 
 <table>
--- a/servlet/src/digilib/servlet/DigilibWorker.java	Wed Nov 17 19:30:34 2004 +0100
+++ b/servlet/src/digilib/servlet/DigilibWorker.java	Thu Nov 18 21:37:26 2004 +0100
@@ -37,6 +37,8 @@
 
 	private static int runningThreads = 0;
 
+	private static int waitingThreads = 0;
+
 	public static Semaphore lock = new FIFOSemaphore(1);
 
 	protected boolean busy = false;
@@ -58,11 +60,14 @@
 	 * Do the work.
 	 */
 	public void run() {
+		logger.debug((++waitingThreads) + " waiting threads");
 		try {
 			lock.acquire();
+			waitingThreads--;
 		} catch (InterruptedException e) {
 			error = e;
 			busy = false;
+			waitingThreads--;
 			return;
 		}
 		logger.debug((++runningThreads) + " running threads");
@@ -123,4 +128,18 @@
 	public static void setLock(Semaphore lock) {
 		DigilibWorker.lock = lock;
 	}
+	
+	/** The number of currently running threads (approximate).
+	 * @return
+	 */
+	public static int getNumRunning() {
+		return runningThreads;
+	}
+
+	/** The number of currently waiting threads (approximate).
+	 * @return
+	 */
+	public static int getNumWaiting() {
+		return waitingThreads;
+	}
 }
--- a/servlet/src/digilib/servlet/Scaler.java	Wed Nov 17 19:30:34 2004 +0100
+++ b/servlet/src/digilib/servlet/Scaler.java	Thu Nov 18 21:37:26 2004 +0100
@@ -59,7 +59,7 @@
 	private static final long serialVersionUID = -325080527268912852L;
 
 	/** digilib servlet version (for all components) */
-	public static final String dlVersion = "1.5.4b";
+	public static final String dlVersion = "1.5.5b";
 
 	/** logger for accounting requests */
 	private static Logger accountlog = Logger.getLogger("account.request");