Package org.eclipse.jetty.server.handler
Class StatisticsHandler
java.lang.Object
org.eclipse.jetty.util.component.AbstractLifeCycle
org.eclipse.jetty.util.component.ContainerLifeCycle
org.eclipse.jetty.server.handler.AbstractHandler
org.eclipse.jetty.server.handler.AbstractHandlerContainer
org.eclipse.jetty.server.handler.HandlerWrapper
org.eclipse.jetty.server.handler.StatisticsHandler
- All Implemented Interfaces:
Handler
,HandlerContainer
,Container
,Destroyable
,Dumpable
,Dumpable.DumpableContainer
,Graceful
,LifeCycle
@ManagedObject("Request Statistics Gathering")
public class StatisticsHandler
extends HandlerWrapper
implements Graceful
-
Nested Class Summary
Nested classes/interfaces inherited from class org.eclipse.jetty.server.handler.AbstractHandler
AbstractHandler.ErrorDispatchHandler
Nested classes/interfaces inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
AbstractLifeCycle.AbstractLifeCycleListener, AbstractLifeCycle.StopException
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Container
Container.InheritedListener, Container.Listener
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Dumpable
Dumpable.DumpableContainer
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.Graceful
Graceful.Shutdown, Graceful.ThrowingRunnable
Nested classes/interfaces inherited from interface org.eclipse.jetty.util.component.LifeCycle
LifeCycle.Listener
-
Field Summary
Fields inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
_handler
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected void
doStart()
Starts the managed lifecycle beans in the order they were added.protected void
doStop()
Stops the managed lifecycle beans in the reverse order they were added.int
int
int
int
int
int
int
long
double
double
long
int
int
boolean
int
int
int
long
double
double
long
int
int
int
int
int
long
int
long
void
handle
(String path, Request baseRequest, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) Handle a request.boolean
void
setGracefulShutdownWaitsForRequests
(boolean gracefulShutdownWaitsForRequests) Set whether the graceful shutdown should wait for all requests to complete including async requests which are not currently dispatched, or whether it should only wait for all the actively dispatched requests to complete.shutdown()
Shutdown the component.void
Resets the current request statistics.toString()
protected void
updateResponse
(Request request, boolean thrownError) Methods inherited from class org.eclipse.jetty.server.handler.HandlerWrapper
destroy, expandChildren, getHandler, getHandlers, insertHandler, setHandler
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandlerContainer
expandHandler, findContainerOf, getChildHandlerByClass, getChildHandlers, getChildHandlersByClass, setServer
Methods inherited from class org.eclipse.jetty.server.handler.AbstractHandler
doError, getServer
Methods inherited from class org.eclipse.jetty.util.component.ContainerLifeCycle
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dumpObjects, dumpStdErr, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, start, stop, unmanage, updateBean, updateBean, updateBeans, updateBeans
Methods inherited from class org.eclipse.jetty.util.component.AbstractLifeCycle
getEventListeners, getState, getState, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, setEventListeners, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.eclipse.jetty.util.component.Container
getCachedBeans, getEventListeners
Methods inherited from interface org.eclipse.jetty.util.component.Dumpable.DumpableContainer
isDumpable
Methods inherited from interface org.eclipse.jetty.util.component.LifeCycle
addEventListener, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeEventListener, start, stop
-
Constructor Details
-
StatisticsHandler
public StatisticsHandler()
-
-
Method Details
-
statsReset
Resets the current request statistics. -
handle
public void handle(String path, Request baseRequest, jakarta.servlet.http.HttpServletRequest request, jakarta.servlet.http.HttpServletResponse response) throws IOException, jakarta.servlet.ServletException Description copied from interface:Handler
Handle a request.- Specified by:
handle
in interfaceHandler
- Overrides:
handle
in classHandlerWrapper
- Parameters:
path
- The target of the request - either a URI or a name.baseRequest
- The original unwrapped request object.request
- The request either as theRequest
object or a wrapper of that request. The
method can be used access the Request object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getRequest()
response
- The response as theResponse
object or a wrapper of that request. The
method can be used access the Response object if required.HttpConnection.getCurrentConnection()
.getHttpChannel()
.getResponse()
- Throws:
IOException
- if unable to handle the request or response processingjakarta.servlet.ServletException
- if unable to handle the request or response due to underlying servlet issue
-
updateResponse
-
doStart
Description copied from class:ContainerLifeCycle
Starts the managed lifecycle beans in the order they were added.- Overrides:
doStart
in classAbstractHandler
- Throws:
AbstractLifeCycle.StopException
- If thrown, the lifecycle will immediately be stopped.Exception
- If there was a problem starting. Will cause a transition to FAILED state
-
doStop
Description copied from class:ContainerLifeCycle
Stops the managed lifecycle beans in the reverse order they were added.- Overrides:
doStop
in classAbstractHandler
- Throws:
Exception
- If there was a problem stopping. Will cause a transition to FAILED state
-
setGracefulShutdownWaitsForRequests
public void setGracefulShutdownWaitsForRequests(boolean gracefulShutdownWaitsForRequests) Set whether the graceful shutdown should wait for all requests to complete including async requests which are not currently dispatched, or whether it should only wait for all the actively dispatched requests to complete.- Parameters:
gracefulShutdownWaitsForRequests
- true to wait for async requests on graceful shutdown.
-
getGracefulShutdownWaitsForRequests
@ManagedAttribute("if graceful shutdown will wait for all requests") public boolean getGracefulShutdownWaitsForRequests()- Returns:
- whether the graceful shutdown will wait for all requests to complete including async requests which are not currently dispatched, or whether it will only wait for all the actively dispatched requests to complete.
- See Also:
-
getRequests
- Returns:
- the number of requests handled by this handler
since
statsReset()
was last called, excluding active requests - See Also:
-
getRequestsActive
- Returns:
- the number of requests currently active.
since
statsReset()
was last called.
-
getRequestsActiveMax
- Returns:
- the maximum number of active requests
since
statsReset()
was last called.
-
getRequestTimeMax
- Returns:
- the maximum time (in milliseconds) of request handling
since
statsReset()
was last called.
-
getRequestTimeTotal
@ManagedAttribute("total time spend in all request handling (in ms)") public long getRequestTimeTotal()- Returns:
- the total time (in milliseconds) of requests handling
since
statsReset()
was last called.
-
getRequestTimeMean
- Returns:
- the mean time (in milliseconds) of request handling
since
statsReset()
was last called. - See Also:
-
getRequestTimeStdDev
@ManagedAttribute("standard deviation for request handling (in ms)") public double getRequestTimeStdDev()- Returns:
- the standard deviation of time (in milliseconds) of request handling
since
statsReset()
was last called. - See Also:
-
getDispatched
- Returns:
- the number of dispatches seen by this handler
since
statsReset()
was last called, excluding active dispatches
-
getDispatchedActive
- Returns:
- the number of dispatches currently in this handler
since
statsReset()
was last called, including resumed requests
-
getDispatchedActiveMax
@ManagedAttribute("maximum number of active dispatches being handled") public int getDispatchedActiveMax()- Returns:
- the max number of dispatches currently in this handler
since
statsReset()
was last called, including resumed requests
-
getDispatchedTimeMax
- Returns:
- the maximum time (in milliseconds) of request dispatch
since
statsReset()
was last called.
-
getDispatchedTimeTotal
@ManagedAttribute("total time spent in dispatch handling (in ms)") public long getDispatchedTimeTotal()- Returns:
- the total time (in milliseconds) of requests handling
since
statsReset()
was last called.
-
getDispatchedTimeMean
@ManagedAttribute("mean time spent in dispatch handling (in ms)") public double getDispatchedTimeMean()- Returns:
- the mean time (in milliseconds) of request handling
since
statsReset()
was last called. - See Also:
-
getDispatchedTimeStdDev
@ManagedAttribute("standard deviation for dispatch handling (in ms)") public double getDispatchedTimeStdDev()- Returns:
- the standard deviation of time (in milliseconds) of request handling
since
statsReset()
was last called. - See Also:
-
getAsyncRequests
- Returns:
- the number of requests handled by this handler
since
statsReset()
was last called, including resumed requests - See Also:
-
getAsyncRequestsWaiting
- Returns:
- the number of requests currently suspended.
since
statsReset()
was last called.
-
getAsyncRequestsWaitingMax
@ManagedAttribute("maximum number of waiting async requests") public int getAsyncRequestsWaitingMax()- Returns:
- the maximum number of current suspended requests
since
statsReset()
was last called.
-
getAsyncDispatches
@ManagedAttribute("number of requested that have been asynchronously dispatched") public int getAsyncDispatches()- Returns:
- the number of requests that have been asynchronously dispatched
-
getExpires
- Returns:
- the number of requests that expired while suspended.
- See Also:
-
getErrors
- Returns:
- the number of async errors that occurred.
- See Also:
-
getResponses1xx
- Returns:
- the number of responses with a 1xx status returned by this context
since
statsReset()
was last called.
-
getResponses2xx
- Returns:
- the number of responses with a 2xx status returned by this context
since
statsReset()
was last called.
-
getResponses3xx
- Returns:
- the number of responses with a 3xx status returned by this context
since
statsReset()
was last called.
-
getResponses4xx
- Returns:
- the number of responses with a 4xx status returned by this context
since
statsReset()
was last called.
-
getResponses5xx
- Returns:
- the number of responses with a 5xx status returned by this context
since
statsReset()
was last called.
-
getResponsesThrown
@ManagedAttribute("number of requests that threw an exception during handling") public int getResponsesThrown()- Returns:
- the number of requests that threw an exception during handling
since
statsReset()
was last called. These may have resulted in some error responses which were unrecorded by theStatisticsHandler
.
-
getStatsOnMs
- Returns:
- the milliseconds since the statistics were started with
statsReset()
.
-
getResponsesBytesTotal
@ManagedAttribute("total number of bytes across all responses") public long getResponsesBytesTotal()- Returns:
- the total bytes of content sent in responses
-
toStatsHTML
-
shutdown
Description copied from interface:Graceful
Shutdown the component. When this method returns, the component should not accept any new load. -
isShutdown
public boolean isShutdown()- Specified by:
isShutdown
in interfaceGraceful
- Returns:
- True if
Graceful.shutdown()
has been called.
-
toString
- Overrides:
toString
in classAbstractLifeCycle
-