# HG changeset patch # User robcast # Date 1324491496 -3600 # Node ID 7bcc6765c2093e584a0fc1aa61f11fe0fee1c818 # Parent 172079f9a398c8793cd749e2d482ee9976b0fd4e improved runtime statistics diff -r 172079f9a398 -r 7bcc6765c209 common/src/main/java/digilib/io/DocuDirCache.java --- a/common/src/main/java/digilib/io/DocuDirCache.java Wed Dec 21 17:57:30 2011 +0100 +++ b/common/src/main/java/digilib/io/DocuDirCache.java Wed Dec 21 19:18:16 2011 +0100 @@ -27,6 +27,7 @@ import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentMap; +import java.util.concurrent.atomic.AtomicInteger; import org.apache.log4j.Logger; @@ -51,13 +52,13 @@ private FileClass[] fileClasses = null; /** number of files in the whole cache (approximate) */ - long numFiles = 0; + protected AtomicInteger numImgFiles = new AtomicInteger(0); /** number of cache hits */ - long hits = 0; + protected AtomicInteger hits = new AtomicInteger(0); /** number of cache misses */ - long misses = 0; + protected AtomicInteger misses = new AtomicInteger(0); /** the root directory element */ public static Directory ROOT = null; @@ -111,7 +112,7 @@ logger.warn("Duplicate key in DocuDirCache.put -- ignoring!"); return olddir; } - numFiles += newdir.size(); + numImgFiles.addAndGet(newdir.size(FileClass.IMAGE)); return newdir; } @@ -193,7 +194,7 @@ dd = map.get(fn); if (dd == null) { // cache miss - misses++; + misses.incrementAndGet(); /* * see if fn is a directory */ @@ -228,14 +229,14 @@ } } else { // it was not a real cache miss - misses--; + misses.decrementAndGet(); } // get the file's index n = dd.indexOf(f.getName(), fc); } } else { // cache hit - hits++; + hits.incrementAndGet(); } dd.refresh(); if (dd.isValid()) { @@ -263,7 +264,7 @@ dd = map.get(fn); if (dd == null) { // cache miss - misses++; + misses.incrementAndGet(); // see if it's a directory File f = new File(baseDirNames[0], fn); if (f.isDirectory()) { @@ -289,7 +290,7 @@ } } else { // not a real cache miss then - misses--; + misses.decrementAndGet(); } } else { // it's not even a file :-( @@ -298,7 +299,7 @@ } } else { // cache hit - hits++; + hits.incrementAndGet(); } dd.refresh(); if (dd.isValid()) { @@ -315,13 +316,6 @@ } /** - * @return long - */ - public long getNumFiles() { - return numFiles; - } - - /** * Sets the baseDirNames. * * @param baseDirNames @@ -331,18 +325,25 @@ this.baseDirNames = baseDirNames; } + /** + * @return long + */ + public int getNumFiles() { + return numImgFiles.get(); + } + /** * @return long */ - public long getHits() { - return hits; + public int getHits() { + return hits.get(); } /** * @return long */ - public long getMisses() { - return misses; + public int getMisses() { + return misses.get(); } /** diff -r 172079f9a398 -r 7bcc6765c209 common/src/main/java/digilib/io/DocuDirectory.java --- a/common/src/main/java/digilib/io/DocuDirectory.java Wed Dec 21 17:57:30 2011 +0100 +++ b/common/src/main/java/digilib/io/DocuDirectory.java Wed Dec 21 19:18:16 2011 +0100 @@ -228,7 +228,7 @@ } // update number of cached files if this was the first time if (dirMTime == 0) { - cache.numFiles += size(); + cache.numImgFiles.addAndGet(size(FileClass.IMAGE)); } dirMTime = dir.lastModified(); // read metadata as well diff -r 172079f9a398 -r 7bcc6765c209 servlet3/src/main/java/digilib/servlet/DigilibServletConfiguration.java --- a/servlet3/src/main/java/digilib/servlet/DigilibServletConfiguration.java Wed Dec 21 17:57:30 2011 +0100 +++ b/servlet3/src/main/java/digilib/servlet/DigilibServletConfiguration.java Wed Dec 21 19:18:16 2011 +0100 @@ -51,6 +51,12 @@ */ public class DigilibServletConfiguration extends DigilibConfiguration { + /** time the webapp (i.e. this class) was loaded */ + public final Long webappStartTime = System.currentTimeMillis(); + + /** counter for HttpRequests (mostly for debugging) */ + public AtomicInteger webappRequestCnt = new AtomicInteger(0); + /** counter for open HttpRequests (mostly for debugging) */ public AtomicInteger openRequestCnt = new AtomicInteger(0); diff -r 172079f9a398 -r 7bcc6765c209 servlet3/src/main/java/digilib/servlet/Initialiser.java --- a/servlet3/src/main/java/digilib/servlet/Initialiser.java Wed Dec 21 17:57:30 2011 +0100 +++ b/servlet3/src/main/java/digilib/servlet/Initialiser.java Wed Dec 21 19:18:16 2011 +0100 @@ -212,6 +212,7 @@ @Override public void requestInitialized(ServletRequestEvent arg0) { + dlConfig.webappRequestCnt.incrementAndGet(); int i = dlConfig.openRequestCnt.incrementAndGet(); logger.debug("ServletRequest created. (cnt="+i+")"); } diff -r 172079f9a398 -r 7bcc6765c209 webapp/src/main/webapp/server/dlConfig.jsp --- a/webapp/src/main/webapp/server/dlConfig.jsp Wed Dec 21 17:57:30 2011 +0100 +++ b/webapp/src/main/webapp/server/dlConfig.jsp Wed Dec 21 19:18:16 2011 +0100 @@ -81,22 +81,35 @@ currently running<%= imageProcessor.getRunningJobs() %> + + +

Webapp

+ + + + + + + + + +
currently open requests<%= dlConfig.openRequestCnt.get() %> (including this)
total requests<%= dlConfig.webappRequestCnt.get() %>
total runtime <%= (System.currentTimeMillis() - dlConfig.webappStartTime)/1000 %>seconds

Directory cache

- - + + - - + +
size (directories)<%= dirCache.size() %>size<%= dirCache.size() %>directories
numFiles<%= dirCache.getNumFiles() %><%= dirCache.getNumFiles() %>image files (approximately)
hits<%= dirCache.getHits() %>