Class StatisticsHandler

All Implemented Interfaces:
Handler, HandlerContainer, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, Graceful, LifeCycle

@ManagedObject("Request Statistics Gathering") public class StatisticsHandler extends HandlerWrapper implements Graceful
  • Constructor Details

    • StatisticsHandler

      public StatisticsHandler()
  • Method Details

    • statsReset

      @ManagedOperation(value="resets statistics", impact="ACTION") public void 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 interface Handler
      Overrides:
      handle in class HandlerWrapper
      Parameters:
      path - The target of the request - either a URI or a name.
      baseRequest - The original unwrapped request object.
      request - The request either as the Request object or a wrapper of that request. The HttpConnection.getCurrentConnection().getHttpChannel().getRequest() method can be used access the Request object if required.
      response - The response as the Response object or a wrapper of that request. The HttpConnection.getCurrentConnection().getHttpChannel().getResponse() method can be used access the Response object if required.
      Throws:
      IOException - if unable to handle the request or response processing
      jakarta.servlet.ServletException - if unable to handle the request or response due to underlying servlet issue
    • updateResponse

      protected void updateResponse(Request request, boolean thrownError)
    • doStart

      protected void doStart() throws Exception
      Description copied from class: ContainerLifeCycle
      Starts the managed lifecycle beans in the order they were added.
      Overrides:
      doStart in class AbstractHandler
      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

      protected void doStop() throws Exception
      Description copied from class: ContainerLifeCycle
      Stops the managed lifecycle beans in the reverse order they were added.
      Overrides:
      doStop in class AbstractHandler
      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

      @ManagedAttribute("number of requests") public int getRequests()
      Returns:
      the number of requests handled by this handler since statsReset() was last called, excluding active requests
      See Also:
    • getRequestsActive

      @ManagedAttribute("number of requests currently active") public int getRequestsActive()
      Returns:
      the number of requests currently active. since statsReset() was last called.
    • getRequestsActiveMax

      @ManagedAttribute("maximum number of active requests") public int getRequestsActiveMax()
      Returns:
      the maximum number of active requests since statsReset() was last called.
    • getRequestTimeMax

      @ManagedAttribute("maximum time spend handling requests (in ms)") public long 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

      @ManagedAttribute("mean time spent handling requests (in ms)") public double 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

      @ManagedAttribute("number of dispatches") public int getDispatched()
      Returns:
      the number of dispatches seen by this handler since statsReset() was last called, excluding active dispatches
    • getDispatchedActive

      @ManagedAttribute("number of dispatches currently active") public int 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

      @ManagedAttribute("maximum time spend in dispatch handling") public long 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

      @ManagedAttribute("total number of async requests") public int getAsyncRequests()
      Returns:
      the number of requests handled by this handler since statsReset() was last called, including resumed requests
      See Also:
    • getAsyncRequestsWaiting

      @ManagedAttribute("currently waiting async requests") public int 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

      @ManagedAttribute("number of async requests requests that have expired") public int getExpires()
      Returns:
      the number of requests that expired while suspended.
      See Also:
    • getErrors

      @ManagedAttribute("number of async errors that occurred") public int getErrors()
      Returns:
      the number of async errors that occurred.
      See Also:
    • getResponses1xx

      @ManagedAttribute("number of requests with 1xx response status") public int getResponses1xx()
      Returns:
      the number of responses with a 1xx status returned by this context since statsReset() was last called.
    • getResponses2xx

      @ManagedAttribute("number of requests with 2xx response status") public int getResponses2xx()
      Returns:
      the number of responses with a 2xx status returned by this context since statsReset() was last called.
    • getResponses3xx

      @ManagedAttribute("number of requests with 3xx response status") public int getResponses3xx()
      Returns:
      the number of responses with a 3xx status returned by this context since statsReset() was last called.
    • getResponses4xx

      @ManagedAttribute("number of requests with 4xx response status") public int getResponses4xx()
      Returns:
      the number of responses with a 4xx status returned by this context since statsReset() was last called.
    • getResponses5xx

      @ManagedAttribute("number of requests with 5xx response status") public int 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 the StatisticsHandler.
    • getStatsOnMs

      @ManagedAttribute("time in milliseconds stats have been collected for") public long 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

      public String toStatsHTML()
    • shutdown

      public CompletableFuture<Void> shutdown()
      Description copied from interface: Graceful
      Shutdown the component. When this method returns, the component should not accept any new load.
      Specified by:
      shutdown in interface Graceful
      Returns:
      A future that is completed once all load on the component is completed
    • isShutdown

      public boolean isShutdown()
      Specified by:
      isShutdown in interface Graceful
      Returns:
      True if Graceful.shutdown() has been called.
    • toString

      public String toString()
      Overrides:
      toString in class AbstractLifeCycle