Class StatisticsHandler

All Implemented Interfaces:
Handler, Handler.Container, Handler.Singleton, Request.Handler, Container, Destroyable, Dumpable, Dumpable.DumpableContainer, LifeCycle, Invocable
Direct Known Subclasses:
StatisticsHandler.MinimumDataRateHandler

public class StatisticsHandler extends EventsHandler
  • Constructor Details

    • StatisticsHandler

      public StatisticsHandler()
    • StatisticsHandler

      public StatisticsHandler(Handler handler)
  • Method Details

    • 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 Handler.Abstract
      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
    • onBeforeHandling

      protected void onBeforeHandling(Request request)
      Description copied from class: EventsHandler
      Invoked just before calling the server handler tree (i.e. just before the Runnable returned from HttpChannel.onRequest(MetaData.Request) is run).

      This is the final state of the request before the handlers are called. This includes any request customization.

      Overrides:
      onBeforeHandling in class EventsHandler
      Parameters:
      request - the request object. The read(), demand(Runnable) and fail(Throwable) methods must not be called by the listener.
      See Also:
    • onAfterHandling

      protected void onAfterHandling(Request request, boolean handled, Throwable failure)
      Description copied from class: EventsHandler
      Invoked after application handling (i.e. just after the call to the Runnable returned from HttpChannel.onRequest(MetaData.Request) returns).
      Overrides:
      onAfterHandling in class EventsHandler
      Parameters:
      request - the request object. The read(), demand(Runnable) and fail(Throwable) methods must not be called by the listener.
      handled - if the server handlers handled the request
      failure - the exception thrown by the application
      See Also:
    • onRequestRead

      protected void onRequestRead(Request request, Content.Chunk chunk)
      Description copied from class: EventsHandler
      Invoked every time a request content chunk has been parsed, just before making it available to the application (i.e. from within a call to Request.read()).
      Overrides:
      onRequestRead in class EventsHandler
      Parameters:
      request - the request object. The read(), demand(Runnable) and fail(Throwable) methods must not be called by the listener.
      chunk - a potentially null request content chunk, including error and Trailers chunks. If a reference to the chunk (or its ByteBuffer) is kept, then Retainable.retain() must be called.
      See Also:
    • onResponseWrite

      protected void onResponseWrite(Request request, boolean last, ByteBuffer content)
      Description copied from class: EventsHandler
      Invoked before each response content chunk has been written (i.e. from within the any call to Response.write(boolean, ByteBuffer, Callback)).
      Overrides:
      onResponseWrite in class EventsHandler
      Parameters:
      request - the request object. The read(), demand(Runnable) and fail(Throwable) methods must not be called by the listener.
      last - indicating last write
      content - The ByteBuffer of the response content chunk (readonly).
      See Also:
    • onComplete

      protected void onComplete(Request request, int status, HttpFields headers, Throwable failure)
      Description copied from class: EventsHandler
      Invoked when the request and response processing are complete, just before the request and response will be recycled (i.e. after the Runnable return from HttpChannel.onRequest(MetaData.Request) has returned and the Callback passed to Request.Handler.handle(Request, Response, Callback) has been completed).
      Overrides:
      onComplete in class EventsHandler
      Parameters:
      request - the request object. The read(), demand(Runnable) and fail(Throwable) methods must not be called by the listener.
      status - the response status.
      headers - the immutable fields of the response object.
      failure - if there was a failure to complete.
    • dump

      public void dump(Appendable out, String indent) throws IOException
      Description copied from interface: Dumpable
      Dump this object (and children) into an Appendable using the provided indent after any new lines. The indent should not be applied to the first object dumped.
      Specified by:
      dump in interface Dumpable
      Overrides:
      dump in class ContainerLifeCycle
      Parameters:
      out - The appendable to dump to
      indent - The indent to apply after any new lines.
      Throws:
      IOException - if unable to write to Appendable
    • reset

      @ManagedOperation(value="resets the statistics", impact="ACTION") public void reset()
    • getRequests

      @Deprecated @ManagedAttribute("number of requests") public int getRequests()
      Deprecated.
      use getRequestTotal() instead.
    • getRequestTotal

      @ManagedAttribute("total number of requests") public int getRequestTotal()
    • getRequestsActive

      @ManagedAttribute("current number of active requests") public int getRequestsActive()
    • getRequestsActiveMax

      @ManagedAttribute("maximum number of active requests") public int getRequestsActiveMax()
    • getRequestTimeTotal

      @ManagedAttribute("total time spent in request execution (in ns)") public long getRequestTimeTotal()
    • getRequestTimeMax

      @ManagedAttribute("maximum request execution time (in ns)") public long getRequestTimeMax()
    • getRequestTimeMean

      @ManagedAttribute("mean request execution time (in ns)") public double getRequestTimeMean()
    • getRequestTimeStdDev

      @ManagedAttribute("standard deviation for request execution time (in ns)") public double getRequestTimeStdDev()
    • getHandleTotal

      @ManagedAttribute("total number of calls to handle()") public int getHandleTotal()
    • getHandleActive

      @ManagedAttribute("current number of requests in handle()") public int getHandleActive()
    • getHandleActiveMax

      @ManagedAttribute("maximum number of requests in handle()") public int getHandleActiveMax()
    • getHandleTimeMax

      @ManagedAttribute("maximum handle() execution time (in ns)") public long getHandleTimeMax()
    • getHandleTimeTotal

      @ManagedAttribute("total time spent in handle() execution (in ns)") public long getHandleTimeTotal()
    • getHandleTimeMean

      @ManagedAttribute("mean handle() execution time (in ns)") public double getHandleTimeMean()
    • getHandleTimeStdDev

      @ManagedAttribute("standard deviation for handle() execution time (in ns)") public double getHandleTimeStdDev()
    • getFailures

      @ManagedAttribute("number of failed requests") public int getFailures()
    • getResponses1xx

      @ManagedAttribute("number of requests with 1xx response status") public int getResponses1xx()
    • getResponses2xx

      @ManagedAttribute("number of requests with 2xx response status") public int getResponses2xx()
    • getResponses3xx

      @ManagedAttribute("number of requests with 3xx response status") public int getResponses3xx()
    • getResponses4xx

      @ManagedAttribute("number of requests with 4xx response status") public int getResponses4xx()
    • getResponses5xx

      @ManagedAttribute("number of requests with 5xx response status") public int getResponses5xx()
    • getHandlingFailures

      @ManagedAttribute("number of requests that threw an exception from handle()") public int getHandlingFailures()
    • getBytesRead

      @ManagedAttribute("bytes read count") public long getBytesRead()
    • getBytesWritten

      @ManagedAttribute("bytes written count") public long getBytesWritten()
    • getStatisticsDuration

      @ManagedAttribute("duration for which statistics have been collected") public Duration getStatisticsDuration()