# HG changeset patch # User robcast # Date 1114190201 -7200 # Node ID 5275a132dbd1c6bb32a233485278057f727550fa # Parent 69fee4d7eb529bc71f61d5e86b88a64133cd0b22 Servlet version 1.5.7b - new max-waiting-threads parameter and handling - DocumentBean also gets real image sizes (for dlInfo-xml et al.) diff -r 69fee4d7eb52 -r 5275a132dbd1 servlet/src/digilib/servlet/DigilibConfiguration.java --- a/servlet/src/digilib/servlet/DigilibConfiguration.java Wed Feb 23 18:13:40 2005 +0100 +++ b/servlet/src/digilib/servlet/DigilibConfiguration.java Fri Apr 22 19:16:41 2005 +0200 @@ -143,6 +143,8 @@ newParameter("safe-dir-index", Boolean.FALSE, null, 'f'); // number of working threads newParameter("worker-threads", new Integer(1), null, 'f'); + // max number of waiting threads + newParameter("max-waiting-threads", new Integer(0), null, 'f'); } diff -r 69fee4d7eb52 -r 5275a132dbd1 servlet/src/digilib/servlet/DigilibRequest.java --- a/servlet/src/digilib/servlet/DigilibRequest.java Wed Feb 23 18:13:40 2005 +0100 +++ b/servlet/src/digilib/servlet/DigilibRequest.java Fri Apr 22 19:16:41 2005 +0200 @@ -157,6 +157,10 @@ newParameter("img.dpix", new Integer(0), null, 'c'); // image dpi y newParameter("img.dpiy", new Integer(0), null, 'c'); + // hires image size x + newParameter("img.pix_x", new Integer(0), null, 'c'); + // hires image size y + newParameter("img.pix_y", new Integer(0), null, 'c'); // total number of pages newParameter("pt", new Integer(0), null, 'c'); // display level of digilib (0 = just image, 1 = one HTML page diff -r 69fee4d7eb52 -r 5275a132dbd1 servlet/src/digilib/servlet/DigilibWorker.java --- a/servlet/src/digilib/servlet/DigilibWorker.java Wed Feb 23 18:13:40 2005 +0100 +++ b/servlet/src/digilib/servlet/DigilibWorker.java Fri Apr 22 19:16:41 2005 +0200 @@ -29,7 +29,6 @@ * image operation worker. * * @author casties - * */ public abstract class DigilibWorker { @@ -39,6 +38,8 @@ private static int waitingThreads = 0; + private static int maxWaitingThreads = 0; + public static Semaphore lock = new FIFOSemaphore(1); protected boolean busy = false; @@ -76,21 +77,30 @@ } catch (Exception e) { error = e; logger.error(e); + } finally { + busy = false; + runningThreads--; + lock.release(); } - busy = false; - runningThreads--; - lock.release(); } - - /** Returns the name of this thread. + /** + * Returns the name of this thread. * * @return */ public String getName() { return Thread.currentThread().getName(); } - + + /** Returns if the worker could run (i.e. is not overloaded). + * + * @return + */ + public static boolean canRun() { + return ((DigilibWorker.maxWaitingThreads == 0) || (DigilibWorker.waitingThreads <= DigilibWorker.maxWaitingThreads)); + } + /** * @return Returns the busy. */ @@ -128,18 +138,36 @@ public static void setLock(Semaphore lock) { DigilibWorker.lock = lock; } - - /** The number of currently running threads (approximate). + + /** + * The number of currently running threads (approximate). + * * @return */ public static int getNumRunning() { return runningThreads; } - /** The number of currently waiting threads (approximate). + /** + * The number of currently waiting threads (approximate). + * * @return */ public static int getNumWaiting() { return waitingThreads; } + + /** + * @return Returns the maxWaitingThreads. + */ + public static int getMaxWaitingThreads() { + return maxWaitingThreads; + } + + /** + * @param maxWaitingThreads The maxWaitingThreads to set. + */ + public static void setMaxWaitingThreads(int maxWaitingThreads) { + DigilibWorker.maxWaitingThreads = maxWaitingThreads; + } }