SOLR-539: Fix for non-atomic long counters and a cast fix to avoid divide by zero

git-svn-id: https://svn.apache.org/repos/asf/lucene/solr/trunk@658977 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Otis Gospodnetic 2008-05-22 02:12:50 +00:00
parent 7f03f165a7
commit 15fb1cd0cf
2 changed files with 7 additions and 4 deletions

View File

@ -404,6 +404,9 @@ Bug Fixes
been added for people who have come to depend on the existing
broken behavior. (hossman)
30. SOLR-539: Fix for non-atomic long counters and a cast fix to avoid divide
by zero. (Sean Timm via Otis Gospodnetic)
Other Changes
1. SOLR-135: Moved common classes to org.apache.solr.common and altered the
build scripts to make two jars: apache-solr-1.3.jar and

View File

@ -39,13 +39,13 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo
// statistics
// TODO: should we bother synchronizing these, or is an off-by-one error
// acceptable every million requests or so?
long numRequests;
long numErrors;
volatile long numRequests;
volatile long numErrors;
protected NamedList initArgs = null;
protected SolrParams defaults;
protected SolrParams appends;
protected SolrParams invariants;
long totalTime = 0;
volatile long totalTime = 0;
long handlerStart = System.currentTimeMillis();
/** shorten the class references for utilities */
@ -159,7 +159,7 @@ public abstract class RequestHandlerBase implements SolrRequestHandler, SolrInfo
lst.add("requests", numRequests);
lst.add("errors", numErrors);
lst.add("avgTimePerRequest", (float) totalTime / (float) this.numRequests);
lst.add("avgRequestsPerSecond", (float) numRequests*1000 / ((float)System.currentTimeMillis()-handlerStart));
lst.add("avgRequestsPerSecond", (float) numRequests*1000 / (float)(System.currentTimeMillis()-handlerStart));
return lst;
}