301089 Improve statistics available in StatisticsHandler and AbstractConnector
git-svn-id: svn+ssh://dev.eclipse.org/svnroot/rt/org.eclipse.jetty/jetty/trunk@1235 7e9141cc-0065-0410-87d8-b60c137991c4
This commit is contained in:
parent
e0511cce7b
commit
8ea3b1b770
|
@ -20,6 +20,7 @@ jetty-7.0.2-SNAPSHOT
|
|||
+ 300178 HttpClients opens too many connections that are immediately closed
|
||||
+ 300733 Jars from lib/ext are not visible for my web application
|
||||
+ 300933 AbstractConnector uses concurrent objects for stats
|
||||
+ 301089 Improve statistics available in StatisticsHandler and AbstractConnector
|
||||
|
||||
jetty-7.0.1.v20091125 25 November 2009
|
||||
+ 274251 DefaultServlet supports exact match mode.
|
||||
|
|
|
@ -6,18 +6,20 @@ requestsActive: Number of requests currently active since statsReset() called.
|
|||
requestsActiveMax: Maximum number of active requests since statsReset() called.
|
||||
requestTimeMax: Maximum time in milliseconds of request handling since statsReset() called.
|
||||
requestTimeTotal: Total time in milliseconds of all request handling since statsReset() called.
|
||||
requestTimeMean: Mean of time in milliseconds of request handling since statsReset() called.
|
||||
requestTimeStdDev: Standard deviation of time in milliseconds of request handling since statsReset() called.
|
||||
dispatched: Number of dispatches since statsReset() called.
|
||||
dispatchedActive: Number of dispatches currently active since statsReset() called.
|
||||
dispatchedActiveMax: Maximum number of active dispatches since statsReset() called.
|
||||
dispatchedTimeMax: Maximum time in milliseconds of dispatched handling since statsReset() called.
|
||||
dispatchedTimeTotal: Total time in milliseconds of all dispatched handling since statsReset() called.
|
||||
dispatchedTimeMean: Mean of time in milliseconds of dispatch handling since statsReset() called.
|
||||
dispatchedTimeStdDev: Standard deviation of time in milliseconds of dispatch handling since statsReset() called.
|
||||
suspends: Number of requests suspended since statsReset() called.
|
||||
suspendsActive: Number of dispatches currently active since statsReset() called.
|
||||
suspendsActiveMax: Maximum number of active dispatches since statsReset() called.
|
||||
resumes: Number of requests resumed since statsReset() called.
|
||||
expires: Number of requests expired since statsReset() called.
|
||||
requestTimeAverage: Average time in milliseconds of request handling since statsReset() called.
|
||||
dispatchedTimeAverage: Average time in milliseconds of dispatch handling since statsReset() called.
|
||||
responses1xx: Number of responses with a 1xx status since statsReset() called.
|
||||
responses2xx: Number of responses with a 2xx status since statsReset() called.
|
||||
responses3xx: Number of responses with a 3xx status since statsReset() called.
|
||||
|
|
|
@ -18,3 +18,16 @@ integralPort: Port to use for integral redirections.
|
|||
integralScheme: Scheme to use for integral redirections.
|
||||
lowResourcesConnections: The number of connections, which if exceeded represents low resources
|
||||
lowResourcesMaxIdleTime: The period in ms that a connection may be idle when the connector has low resources, before it is closed.
|
||||
statsOnMs: Time in milliseconds statistics have been collected for.
|
||||
statsReset(): Resets statistics.
|
||||
requests: Number of requests since statsReset() called.
|
||||
connections: Number of connections since statsReset() called.
|
||||
connectionsOpen: Number of open connections since statsReset() called.
|
||||
connectionsOpenMax: Maximum number of open connections since statsReset() called.
|
||||
connectionsRequestsMax: Maximum number of requests per connection since statsReset() called.
|
||||
connectionsRequestMean: Mean of number of requests per connection since statsReset() called.
|
||||
connectionsRequestStdDev: Standard deviation of number of requests per connection since statsReset() called.
|
||||
connectionsDurationTotal: Total amount of time in milliseconds connections were open since statsReset() called.
|
||||
connectionsDurationMax: Maximum amount of time in milliseconds a connection was open since statsReset() called.
|
||||
connectionsDurationMean: Mean of amount of time in milliseconds a connection was open since statsReset() called.
|
||||
connectionsDurationStdDev: Standard deviation of amount of time in milliseconds a connection was open since statsReset() called.
|
||||
|
|
|
@ -17,7 +17,6 @@ import java.io.IOException;
|
|||
import java.net.InetAddress;
|
||||
import java.net.Socket;
|
||||
import java.net.UnknownHostException;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import java.util.concurrent.atomic.AtomicLong;
|
||||
|
||||
import javax.servlet.ServletRequest;
|
||||
|
@ -31,6 +30,8 @@ import org.eclipse.jetty.io.ByteArrayBuffer;
|
|||
import org.eclipse.jetty.io.Connection;
|
||||
import org.eclipse.jetty.io.EndPoint;
|
||||
import org.eclipse.jetty.io.EofException;
|
||||
import org.eclipse.jetty.server.ServerStats.CounterStats;
|
||||
import org.eclipse.jetty.server.ServerStats.MeasuredStats;
|
||||
import org.eclipse.jetty.util.component.LifeCycle;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.thread.ThreadPool;
|
||||
|
@ -79,17 +80,9 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
|
||||
private final AtomicLong _statsStartedAt = new AtomicLong(-1L);
|
||||
|
||||
private final AtomicInteger _requests = new AtomicInteger(); // total number of requests made to the server
|
||||
private final AtomicInteger _connections = new AtomicInteger(); // total number of connections made to server
|
||||
|
||||
private final AtomicInteger _connectionsOpen = new AtomicInteger(); // number of connections currently open
|
||||
private final AtomicInteger _connectionsOpenMax = new AtomicInteger(); // max number of connections open simultaneously
|
||||
|
||||
private final AtomicLong _connectionsDurationMax = new AtomicLong(); // max duration of a connection
|
||||
private final AtomicLong _connectionsDurationTotal = new AtomicLong(); // total duration of all connection
|
||||
|
||||
private final AtomicInteger _connectionsRequestsMax = new AtomicInteger(); // max requests per connection
|
||||
|
||||
private final CounterStats _connectionStats = new CounterStats(); // connections to server
|
||||
private final MeasuredStats _requestStats = new MeasuredStats(); // requests per connection
|
||||
private final MeasuredStats _connectionDurationStats = new MeasuredStats(); // duration of a connection
|
||||
|
||||
/* ------------------------------------------------------------------------------- */
|
||||
/**
|
||||
|
@ -524,8 +517,6 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/* ------------------------------------------------------------ */
|
||||
/*
|
||||
* @see org.eclipse.jetty.server.Connector#getConfidentialPort()
|
||||
|
@ -842,7 +833,7 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
*/
|
||||
public int getRequests()
|
||||
{
|
||||
return _requests.get();
|
||||
return (int)_requestStats.getTotal();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -851,7 +842,7 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
*/
|
||||
public long getConnectionsDurationTotal()
|
||||
{
|
||||
return _connectionsDurationTotal.get();
|
||||
return _connectionDurationStats.getTotal();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -859,59 +850,64 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
* @return Number of connections accepted by the server since
|
||||
* statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public int getConnections() {return _connections.get();}
|
||||
public int getConnections() {return (int)_connectionStats.getTotal();}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Number of connections currently open that were opened
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public int getConnectionsOpen() {return _connectionsOpen.get();}
|
||||
public int getConnectionsOpen() {return (int)_connectionStats.getCurrent();}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Maximum number of connections opened simultaneously
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public int getConnectionsOpenMax() {return _connectionsOpenMax.get();}
|
||||
public int getConnectionsOpenMax() {return (int) _connectionStats.getMax();}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Average duration in milliseconds of open connections
|
||||
* @return Mean duration in milliseconds of open connections
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public long getConnectionsDurationAve()
|
||||
{
|
||||
int connections = getConnections();
|
||||
|
||||
return (connections==0) ? 0 : (getConnectionsDurationTotal()/connections);
|
||||
}
|
||||
public double getConnectionsDurationMean() { return _connectionDurationStats.getMean();}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Maximum duration in milliseconds of an open connection
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public long getConnectionsDurationMax() {return _connectionsDurationMax.get();}
|
||||
public long getConnectionsDurationMax() {return _connectionDurationStats.getMax();}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Average number of requests per connection
|
||||
* @return Standard deviation of duration in milliseconds of
|
||||
* open connections since statsReset() called. Undefined if
|
||||
* setStatsOn(false).
|
||||
*/
|
||||
public double getConnectionsDurationStdDev() { return _connectionDurationStats.getStdDev();}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Mean number of requests per connection
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public int getConnectionsRequestsAve()
|
||||
{
|
||||
int connections = getConnections();
|
||||
|
||||
return (connections==0) ? 0: (getRequests()/connections);
|
||||
}
|
||||
public double getConnectionsRequestsMean() { return _requestStats.getMean(); }
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Maximum number of requests per connection
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public int getConnectionsRequestsMax() {return _connectionsRequestsMax.get();}
|
||||
public int getConnectionsRequestsMax() {return (int)_requestStats.getMax();}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Standard deviation of number of requests per connection
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public double getConnectionsRequestsStdDev() { return _requestStats.getStdDev(); }
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Reset statistics.
|
||||
|
@ -920,17 +916,9 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
{
|
||||
updateNotEqual(_statsStartedAt, -1, System.currentTimeMillis());
|
||||
|
||||
_connections.set(0);
|
||||
|
||||
_connectionsOpenMax.set(_connectionsOpen.get());
|
||||
_connectionsOpen.set(0);
|
||||
|
||||
_connectionsDurationMax.set(0);
|
||||
_connectionsDurationTotal.set(0);
|
||||
|
||||
_requests.set(0);
|
||||
|
||||
_connectionsRequestsMax.set(0);
|
||||
_requestStats.reset();
|
||||
_connectionStats.reset();
|
||||
_connectionDurationStats.reset();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -971,13 +959,13 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
if (_statsStartedAt.get()==-1)
|
||||
return;
|
||||
|
||||
updateMax(_connectionsOpenMax, _connectionsOpen.incrementAndGet());
|
||||
_connectionStats.increment();
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
protected void connectionUpgraded(Connection oldConnection, Connection newConnection)
|
||||
{
|
||||
_requests.addAndGet((oldConnection instanceof HttpConnection)?((HttpConnection)oldConnection).getRequests():0);
|
||||
_requestStats.set((oldConnection instanceof HttpConnection)?((HttpConnection)oldConnection).getRequests():0);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -989,14 +977,9 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
long duration = System.currentTimeMillis() - connection.getTimeStamp();
|
||||
int requests = (connection instanceof HttpConnection) ? ((HttpConnection)connection).getRequests() : 0;
|
||||
|
||||
_requests.addAndGet(requests);
|
||||
_connections.incrementAndGet();
|
||||
_connectionsOpen.decrementAndGet();
|
||||
_connectionsDurationTotal.addAndGet(duration);
|
||||
|
||||
updateMax(_connectionsDurationMax, duration);
|
||||
updateMax(_connectionsRequestsMax, requests);
|
||||
|
||||
_requestStats.set(requests);
|
||||
_connectionStats.decrement();
|
||||
_connectionDurationStats.set(duration);
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
|
@ -1057,28 +1040,4 @@ public abstract class AbstractConnector extends HttpBuffers implements Connector
|
|||
oldValue = valueHolder.get();
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private void updateMax(AtomicInteger valueHolder, int value)
|
||||
{
|
||||
int oldValue = valueHolder.get();
|
||||
while (value > oldValue)
|
||||
{
|
||||
if (valueHolder.compareAndSet(oldValue, value))
|
||||
break;
|
||||
oldValue = valueHolder.get();
|
||||
}
|
||||
}
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
private void updateMax(AtomicLong valueHolder, long value)
|
||||
{
|
||||
long oldValue = valueHolder.get();
|
||||
while (value > oldValue)
|
||||
{
|
||||
if (valueHolder.compareAndSet(oldValue, value))
|
||||
break;
|
||||
oldValue = valueHolder.get();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -275,13 +275,6 @@ public interface Connector extends LifeCycle
|
|||
*/
|
||||
public int getConnectionsOpenMax() ;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Average duration in milliseconds of open connections
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public long getConnectionsDurationAve() ;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Maximum duration in milliseconds of an open connection
|
||||
|
@ -291,10 +284,32 @@ public interface Connector extends LifeCycle
|
|||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Average number of requests per connection
|
||||
* @return Mean duration in milliseconds of open connections
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public int getConnectionsRequestsAve() ;
|
||||
public double getConnectionsDurationMean() ;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Standard deviation of duration in milliseconds of
|
||||
* open connections since statsReset() called. Undefined if
|
||||
* setStatsOn(false).
|
||||
*/
|
||||
public double getConnectionsDurationStdDev() ;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Mean number of requests per connection
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public double getConnectionsRequestsMean() ;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
* @return Standard Deviation of number of requests per connection
|
||||
* since statsReset() called. Undefined if setStatsOn(false).
|
||||
*/
|
||||
public double getConnectionsRequestsStdDev() ;
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/**
|
||||
|
@ -303,8 +318,6 @@ public interface Connector extends LifeCycle
|
|||
*/
|
||||
public int getConnectionsRequestsMax();
|
||||
|
||||
|
||||
|
||||
/* ------------------------------------------------------------ */
|
||||
/** Reset statistics.
|
||||
*/
|
||||
|
|
|
@ -26,26 +26,19 @@ import org.eclipse.jetty.continuation.ContinuationListener;
|
|||
import org.eclipse.jetty.server.AsyncContinuation;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Response;
|
||||
import org.eclipse.jetty.server.ServerStats.CounterStats;
|
||||
import org.eclipse.jetty.server.ServerStats.MeasuredStats;
|
||||
|
||||
public class StatisticsHandler extends HandlerWrapper
|
||||
{
|
||||
private final AtomicLong _statsStartedAt = new AtomicLong();
|
||||
|
||||
private final AtomicInteger _requests = new AtomicInteger();
|
||||
private final AtomicInteger _requestsActive = new AtomicInteger();
|
||||
private final AtomicInteger _requestsActiveMax = new AtomicInteger();
|
||||
private final AtomicLong _requestTimeMax = new AtomicLong();
|
||||
private final AtomicLong _requestTimeTotal = new AtomicLong();
|
||||
private final CounterStats _requestStats = new CounterStats();
|
||||
private final MeasuredStats _requestTimeStats = new MeasuredStats();
|
||||
private final CounterStats _dispatchedStats = new CounterStats();
|
||||
private final MeasuredStats _dispatchedTimeStats = new MeasuredStats();
|
||||
private final CounterStats _suspendStats = new CounterStats();
|
||||
|
||||
private final AtomicInteger _dispatched = new AtomicInteger();
|
||||
private final AtomicInteger _dispatchedActive = new AtomicInteger();
|
||||
private final AtomicInteger _dispatchedActiveMax = new AtomicInteger();
|
||||
private final AtomicLong _dispatchedTimeMax = new AtomicLong();
|
||||
private final AtomicLong _dispatchedTimeTotal = new AtomicLong();
|
||||
|
||||
private final AtomicInteger _suspends = new AtomicInteger();
|
||||
private final AtomicInteger _suspendsActive = new AtomicInteger();
|
||||
private final AtomicInteger _suspendsActiveMax = new AtomicInteger();
|
||||
private final AtomicInteger _resumes = new AtomicInteger();
|
||||
private final AtomicInteger _expires = new AtomicInteger();
|
||||
|
||||
|
@ -63,13 +56,13 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
final Request request = ((AsyncContinuation)continuation).getBaseRequest();
|
||||
final long elapsed = System.currentTimeMillis()-request.getTimeStamp();
|
||||
|
||||
_requestsActive.decrementAndGet();
|
||||
_requests.incrementAndGet();
|
||||
updateMax(_requestTimeMax, elapsed);
|
||||
_requestTimeTotal.addAndGet(elapsed);
|
||||
_requestStats.decrement();
|
||||
_requestTimeStats.set(elapsed);
|
||||
|
||||
updateResponse(request);
|
||||
|
||||
if (!continuation.isResumed())
|
||||
_suspendsActive.decrementAndGet();
|
||||
_suspendStats.decrement();
|
||||
}
|
||||
|
||||
public void onTimeout(Continuation continuation)
|
||||
|
@ -85,21 +78,12 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
{
|
||||
_statsStartedAt.set(System.currentTimeMillis());
|
||||
|
||||
_requests.set(0);
|
||||
_requestsActive.set(0);
|
||||
_requestsActiveMax.set(0);
|
||||
_requestTimeMax.set(0L);
|
||||
_requestTimeTotal.set(0L);
|
||||
_requestStats.reset();
|
||||
_requestTimeStats.reset();
|
||||
_dispatchedStats.reset();
|
||||
_dispatchedTimeStats.reset();
|
||||
_suspendStats.reset();
|
||||
|
||||
_dispatched.set(0);
|
||||
_dispatchedActive.set(0);
|
||||
_dispatchedActiveMax.set(0);
|
||||
_dispatchedTimeMax.set(0L);
|
||||
_dispatchedTimeTotal.set(0L);
|
||||
|
||||
_suspends.set(0);
|
||||
_suspendsActive.set(0);
|
||||
_suspendsActiveMax.set(0);
|
||||
_resumes.set(0);
|
||||
_expires.set(0);
|
||||
_responses1xx.set(0);
|
||||
|
@ -110,46 +94,24 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
_responsesTotalBytes.set(0L);
|
||||
}
|
||||
|
||||
private void updateMax(AtomicInteger valueHolder, int value)
|
||||
{
|
||||
int oldValue = valueHolder.get();
|
||||
while (value > oldValue)
|
||||
{
|
||||
if (valueHolder.compareAndSet(oldValue, value))
|
||||
break;
|
||||
oldValue = valueHolder.get();
|
||||
}
|
||||
}
|
||||
|
||||
private void updateMax(AtomicLong valueHolder, long value)
|
||||
{
|
||||
long oldValue = valueHolder.get();
|
||||
while (value > oldValue)
|
||||
{
|
||||
if (valueHolder.compareAndSet(oldValue, value))
|
||||
break;
|
||||
oldValue = valueHolder.get();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void handle(String path, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
|
||||
{
|
||||
updateMax(_dispatchedActiveMax, _dispatchedActive.incrementAndGet());
|
||||
_dispatchedStats.increment();
|
||||
|
||||
final long start;
|
||||
AsyncContinuation continuation = request.getAsyncContinuation();
|
||||
if (continuation.isInitial())
|
||||
{
|
||||
// new request
|
||||
updateMax(_requestsActiveMax, _requestsActive.incrementAndGet());
|
||||
_requestStats.increment();
|
||||
start = request.getTimeStamp();
|
||||
}
|
||||
else
|
||||
{
|
||||
// resumed request
|
||||
start = System.currentTimeMillis();
|
||||
_suspendsActive.decrementAndGet();
|
||||
_suspendStats.decrement();
|
||||
if (continuation.isResumed())
|
||||
_resumes.incrementAndGet();
|
||||
}
|
||||
|
@ -163,26 +125,19 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
final long now = System.currentTimeMillis();
|
||||
final long dispatched=now-start;
|
||||
|
||||
_dispatchedActive.decrementAndGet();
|
||||
_dispatched.incrementAndGet();
|
||||
|
||||
_dispatchedTimeTotal.addAndGet(dispatched);
|
||||
updateMax(_dispatchedTimeMax, dispatched);
|
||||
_dispatchedStats.decrement();
|
||||
_dispatchedTimeStats.set(dispatched);
|
||||
|
||||
if (continuation.isSuspended())
|
||||
{
|
||||
if (continuation.isInitial())
|
||||
continuation.addContinuationListener(_onCompletion);
|
||||
_suspends.incrementAndGet();
|
||||
updateMax(_suspendsActiveMax, _suspendsActive.incrementAndGet());
|
||||
_suspendStats.increment();
|
||||
}
|
||||
else if (continuation.isInitial())
|
||||
{
|
||||
_requestsActive.decrementAndGet();
|
||||
_requests.incrementAndGet();
|
||||
|
||||
updateMax(_requestTimeMax, dispatched);
|
||||
_requestTimeTotal.addAndGet(dispatched);
|
||||
_requestStats.decrement();
|
||||
_requestTimeStats.set(dispatched);
|
||||
updateResponse(request);
|
||||
}
|
||||
// else onCompletion will handle it.
|
||||
|
@ -230,7 +185,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getRequests()
|
||||
{
|
||||
return _requests.get();
|
||||
return (int)_requestStats.getTotal();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -239,7 +194,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getRequestsActive()
|
||||
{
|
||||
return _requestsActive.get();
|
||||
return (int)_requestStats.getCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -248,7 +203,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getRequestsActiveMax()
|
||||
{
|
||||
return _requestsActiveMax.get();
|
||||
return (int)_requestStats.getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -257,7 +212,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public long getRequestTimeMax()
|
||||
{
|
||||
return _requestTimeMax.get();
|
||||
return _requestTimeStats.getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -266,19 +221,29 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public long getRequestTimeTotal()
|
||||
{
|
||||
return _requestTimeTotal.get();
|
||||
return _requestTimeStats.getTotal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the average time (in milliseconds) of request handling
|
||||
* @return the mean time (in milliseconds) of request handling
|
||||
* since {@link #statsReset()} was last called.
|
||||
* @see #getRequestTimeTotal()
|
||||
* @see #getRequests()
|
||||
*/
|
||||
public long getRequestTimeAverage()
|
||||
public double getRequestTimeMean()
|
||||
{
|
||||
int requests = getRequests();
|
||||
return requests == 0 ? 0 : getRequestTimeTotal() / requests;
|
||||
return _requestTimeStats.getMean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the standard deviation of time (in milliseconds) of request handling
|
||||
* since {@link #statsReset()} was last called.
|
||||
* @see #getRequestTimeTotal()
|
||||
* @see #getRequests()
|
||||
*/
|
||||
public double getRequestTimeStdDev()
|
||||
{
|
||||
return _requestTimeStats.getStdDev();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -288,7 +253,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getDispatched()
|
||||
{
|
||||
return _dispatched.get();
|
||||
return (int)_dispatchedStats.getTotal();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -298,7 +263,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getDispatchedActive()
|
||||
{
|
||||
return _dispatchedActive.get();
|
||||
return (int)_dispatchedStats.getCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -308,7 +273,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getDispatchedActiveMax()
|
||||
{
|
||||
return _dispatchedActiveMax.get();
|
||||
return (int)_dispatchedStats.getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -317,7 +282,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public long getDispatchedTimeMax()
|
||||
{
|
||||
return _dispatchedTimeMax.get();
|
||||
return _dispatchedTimeStats.getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -326,21 +291,30 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public long getDispatchedTimeTotal()
|
||||
{
|
||||
return _dispatchedTimeTotal.get();
|
||||
return _dispatchedTimeStats.getTotal();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the average time (in milliseconds) of request handling
|
||||
* @return the mean time (in milliseconds) of request handling
|
||||
* since {@link #statsReset()} was last called.
|
||||
* @see #getRequestTimeTotal()
|
||||
* @see #getRequests()
|
||||
*/
|
||||
public long getDispatchedTimeAverage()
|
||||
public double getDispatchedTimeMean()
|
||||
{
|
||||
int requests = getDispatched();
|
||||
return requests == 0 ? 0 : getDispatchedTimeTotal() / requests;
|
||||
return _dispatchedTimeStats.getMean();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the standard deviation of time (in milliseconds) of request handling
|
||||
* since {@link #statsReset()} was last called.
|
||||
* @see #getRequestTimeTotal()
|
||||
* @see #getRequests()
|
||||
*/
|
||||
public double getDispatchedTimeStdDev()
|
||||
{
|
||||
return _dispatchedTimeStats.getStdDev();
|
||||
}
|
||||
|
||||
/**
|
||||
* @return the number of requests handled by this handler
|
||||
|
@ -350,7 +324,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getSuspends()
|
||||
{
|
||||
return _suspends.get();
|
||||
return (int)_suspendStats.getTotal();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -359,7 +333,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getSuspendsActive()
|
||||
{
|
||||
return _suspendsActive.get();
|
||||
return (int)_suspendStats.getCurrent();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -368,7 +342,7 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
*/
|
||||
public int getSuspendsActiveMax()
|
||||
{
|
||||
return _suspendsActiveMax.get();
|
||||
return (int)_suspendStats.getMax();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -462,8 +436,9 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
sb.append("Active requests: ").append(getRequestsActive()).append("<br />\n");
|
||||
sb.append("Max active requests: ").append(getRequestsActiveMax()).append("<br />\n");
|
||||
sb.append("Total requests time: ").append(getRequestTimeTotal()).append("<br />\n");
|
||||
sb.append("Average request time: ").append(getRequestTimeAverage()).append("<br />\n");
|
||||
sb.append("Mean request time: ").append(getRequestTimeMean()).append("<br />\n");
|
||||
sb.append("Max request time: ").append(getRequestTimeMax()).append("<br />\n");
|
||||
sb.append("Request time standard deviation: ").append(getRequestTimeStdDev()).append("<br />\n");
|
||||
|
||||
|
||||
sb.append("<h2>Dispatches:</h2>\n");
|
||||
|
@ -471,8 +446,9 @@ public class StatisticsHandler extends HandlerWrapper
|
|||
sb.append("Active dispatched: ").append(getDispatchedActive()).append("<br />\n");
|
||||
sb.append("Max active dispatched: ").append(getDispatchedActiveMax()).append("<br />\n");
|
||||
sb.append("Total dispatched time: ").append(getDispatchedTimeTotal()).append("<br />\n");
|
||||
sb.append("Average dispatched time: ").append(getDispatchedTimeAverage()).append("<br />\n");
|
||||
sb.append("Mean dispatched time: ").append(getDispatchedTimeMean()).append("<br />\n");
|
||||
sb.append("Max dispatched time: ").append(getDispatchedTimeMax()).append("<br />\n");
|
||||
sb.append("Dispatched time standard deviation: ").append(getDispatchedTimeStdDev()).append("<br />\n");
|
||||
|
||||
|
||||
sb.append("Total requests suspended: ").append(getSuspends()).append("<br />\n");
|
||||
|
|
|
@ -314,10 +314,10 @@ public class StatisticsHandlerTest extends TestCase
|
|||
|
||||
assertTrue(_statsHandler.getRequestTimeTotal()>=30);
|
||||
assertEquals(_statsHandler.getRequestTimeTotal(),_statsHandler.getRequestTimeMax());
|
||||
assertEquals(_statsHandler.getRequestTimeTotal(),_statsHandler.getRequestTimeAverage());
|
||||
assertEquals(_statsHandler.getRequestTimeTotal()*1.0,_statsHandler.getRequestTimeMean());
|
||||
|
||||
assertTrue(_statsHandler.getDispatchedTimeTotal()>=20);
|
||||
assertTrue(_statsHandler.getDispatchedTimeAverage()+10<=_statsHandler.getDispatchedTimeTotal());
|
||||
assertTrue(_statsHandler.getDispatchedTimeMean()+10<=_statsHandler.getDispatchedTimeTotal());
|
||||
assertTrue(_statsHandler.getDispatchedTimeMax()+10<=_statsHandler.getDispatchedTimeTotal());
|
||||
|
||||
}
|
||||
|
@ -433,10 +433,10 @@ public class StatisticsHandlerTest extends TestCase
|
|||
|
||||
assertTrue(_statsHandler.getRequestTimeTotal()>=30);
|
||||
assertEquals(_statsHandler.getRequestTimeTotal(),_statsHandler.getRequestTimeMax());
|
||||
assertEquals(_statsHandler.getRequestTimeTotal(),_statsHandler.getRequestTimeAverage());
|
||||
assertEquals(_statsHandler.getRequestTimeTotal()*1.0,_statsHandler.getRequestTimeMean());
|
||||
|
||||
assertTrue(_statsHandler.getDispatchedTimeTotal()>=20);
|
||||
assertTrue(_statsHandler.getDispatchedTimeAverage()+10<=_statsHandler.getDispatchedTimeTotal());
|
||||
assertTrue(_statsHandler.getDispatchedTimeMean()+10<=_statsHandler.getDispatchedTimeTotal());
|
||||
assertTrue(_statsHandler.getDispatchedTimeMax()+10<=_statsHandler.getDispatchedTimeTotal());
|
||||
|
||||
}
|
||||
|
@ -540,12 +540,12 @@ public class StatisticsHandlerTest extends TestCase
|
|||
|
||||
assertTrue(_statsHandler.getRequestTimeTotal()>=20);
|
||||
assertEquals(_statsHandler.getRequestTimeTotal(),_statsHandler.getRequestTimeMax());
|
||||
assertEquals(_statsHandler.getRequestTimeTotal(),_statsHandler.getRequestTimeAverage());
|
||||
assertEquals(_statsHandler.getRequestTimeTotal()*1.0,_statsHandler.getRequestTimeMean());
|
||||
|
||||
assertTrue(_statsHandler.getDispatchedTimeTotal()>=10);
|
||||
assertTrue(_statsHandler.getDispatchedTimeTotal()<_statsHandler.getRequestTimeTotal());
|
||||
assertEquals(_statsHandler.getDispatchedTimeTotal(),_statsHandler.getDispatchedTimeMax());
|
||||
assertEquals(_statsHandler.getDispatchedTimeTotal(),_statsHandler.getDispatchedTimeAverage());
|
||||
assertEquals(_statsHandler.getDispatchedTimeTotal()*1.0,_statsHandler.getDispatchedTimeMean());
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -116,15 +116,17 @@ public class StatisticsServlet extends HttpServlet
|
|||
sb.append(" <requestsActive>").append(_statsHandler.getRequestsActive()).append("</requestsActive>\n");
|
||||
sb.append(" <requestsActiveMax>").append(_statsHandler.getRequestsActiveMax()).append("</requestsActiveMax>\n");
|
||||
sb.append(" <requestsTimeTotal>").append(_statsHandler.getRequestTimeTotal()).append("</requestsTimeTotal>\n");
|
||||
sb.append(" <requestsTimeAverage>").append(_statsHandler.getRequestTimeAverage()).append("</requestsTimeAverage>\n");
|
||||
sb.append(" <requestsTimeMean>").append(_statsHandler.getRequestTimeMean()).append("</requestsTimeMean>\n");
|
||||
sb.append(" <requestsTimeMax>").append(_statsHandler.getRequestTimeMax()).append("</requestsTimeMax>\n");
|
||||
sb.append(" <requestsTimeStdDev>").append(_statsHandler.getRequestTimeStdDev()).append("</requestsTimeStdDev>\n");
|
||||
|
||||
sb.append(" <dispatched>").append(_statsHandler.getDispatched()).append("</dispatched>\n");
|
||||
sb.append(" <dispatchedActive>").append(_statsHandler.getDispatchedActive()).append("</dispatchedActive>\n");
|
||||
sb.append(" <dispatchedActiveMax>").append(_statsHandler.getDispatchedActiveMax()).append("</dispatchedActiveMax>\n");
|
||||
sb.append(" <dispatchedTimeTotal>").append(_statsHandler.getDispatchedTimeTotal()).append("</dispatchedTimeTotal>\n");
|
||||
sb.append(" <dispatchedTimeAverage>").append(_statsHandler.getDispatchedTimeAverage()).append("</dispatchedTimeAverage>\n");
|
||||
sb.append(" <dispatchedTimeMean").append(_statsHandler.getDispatchedTimeMean()).append("</dispatchedTimeMean>\n");
|
||||
sb.append(" <dispatchedTimeMax>").append(_statsHandler.getDispatchedTimeMax()).append("</dispatchedTimeMax>\n");
|
||||
sb.append(" <dispatchedTimeStdDev").append(_statsHandler.getDispatchedTimeStdDev()).append("</dispatchedTimeStdDev>\n");
|
||||
|
||||
sb.append(" <requestsSuspended>").append(_statsHandler.getSuspends()).append("</requestsSuspended>\n");
|
||||
sb.append(" <requestsExpired>").append(_statsHandler.getExpires()).append("</requestsExpired>\n");
|
||||
|
@ -153,11 +155,13 @@ public class StatisticsServlet extends HttpServlet
|
|||
sb.append(" <connectionsOpen>").append(connector.getConnectionsOpen()).append("</connectionsOpen>\n");
|
||||
sb.append(" <connectionsOpenMax>").append(connector.getConnectionsOpenMax()).append("</connectionsOpenMax>\n");
|
||||
sb.append(" <connectionsDurationTotal>").append(connector.getConnectionsDurationTotal()).append("</connectionsDurationTotal>\n");
|
||||
sb.append(" <connectionsDurationAve>").append(connector.getConnectionsDurationAve()).append("</connectionsDurationAve>\n");
|
||||
sb.append(" <connectionsDurationMean>").append(connector.getConnectionsDurationMean()).append("</connectionsDurationMean>\n");
|
||||
sb.append(" <connectionsDurationMax>").append(connector.getConnectionsDurationMax()).append("</connectionsDurationMax>\n");
|
||||
sb.append(" <connectionsDurationStdDev>").append(connector.getConnectionsDurationStdDev()).append("</connectionsDurationStdDev>\n");
|
||||
sb.append(" <requests>").append(connector.getRequests()).append("</requests>\n");
|
||||
sb.append(" <connectionsRequestsAve>").append(connector.getConnectionsRequestsAve()).append("</connectionsRequestsAve>\n");
|
||||
sb.append(" <connectionsRequestsMean>").append(connector.getConnectionsRequestsMean()).append("</connectionsRequestsMean>\n");
|
||||
sb.append(" <connectionsRequestsMax>").append(connector.getConnectionsRequestsMax()).append("</connectionsRequestsMax>\n");
|
||||
sb.append(" <connectionsRequestsStdDev>").append(connector.getConnectionsRequestsStdDev()).append("</connectionsRequestsStdDev>\n");
|
||||
}
|
||||
sb.append(" </connector>\n");
|
||||
}
|
||||
|
@ -192,11 +196,13 @@ public class StatisticsServlet extends HttpServlet
|
|||
sb.append("Current connections open: ").append(connector.getConnectionsOpen());
|
||||
sb.append("Max concurrent connections open: ").append(connector.getConnectionsOpenMax()).append("<br />\n");
|
||||
sb.append("Total connections duration: ").append(connector.getConnectionsDurationTotal()).append("<br />\n");
|
||||
sb.append("Average connection duration: ").append(connector.getConnectionsDurationAve()).append("<br />\n");
|
||||
sb.append("Mean connection duration: ").append(connector.getConnectionsDurationMean()).append("<br />\n");
|
||||
sb.append("Max connection duration: ").append(connector.getConnectionsDurationMax()).append("<br />\n");
|
||||
sb.append("Connection duration standard deviation: ").append(connector.getConnectionsDurationStdDev()).append("<br />\n");
|
||||
sb.append("Total requests: ").append(connector.getRequests()).append("<br />\n");
|
||||
sb.append("Average requests per connection: ").append(connector.getConnectionsRequestsAve()).append("<br />\n");
|
||||
sb.append("Mean requests per connection: ").append(connector.getConnectionsRequestsMean()).append("<br />\n");
|
||||
sb.append("Max requests per connection: ").append(connector.getConnectionsRequestsMax()).append("<br />\n");
|
||||
sb.append("Requests per connection standard deviation: ").append(connector.getConnectionsRequestsStdDev()).append("<br />\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue