Merge pull request #8548 from eclipse/jetty-12.0.x-ee10-statisticsServlet
Fix the StatisticsServlet for Jetty-12 EE10
This commit is contained in:
commit
5ccd0d7fc4
|
@ -43,8 +43,8 @@ public class StatisticsHandler extends Handler.Wrapper
|
|||
private final SampleStatistic _requestTimeStats = new SampleStatistic();
|
||||
private final SampleStatistic _handleTimeStats = new SampleStatistic();
|
||||
private final SampleStatistic _processTimeStats = new SampleStatistic();
|
||||
private final LongAdder _processThrows = new LongAdder();
|
||||
private final LongAdder _handleThrows = new LongAdder();
|
||||
private final LongAdder _processingErrors = new LongAdder();
|
||||
private final LongAdder _handlingErrors = new LongAdder();
|
||||
private final LongAdder _responses1xx = new LongAdder();
|
||||
private final LongAdder _responses2xx = new LongAdder();
|
||||
private final LongAdder _responses3xx = new LongAdder();
|
||||
|
@ -64,7 +64,7 @@ public class StatisticsHandler extends Handler.Wrapper
|
|||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
_handleThrows.increment();
|
||||
_handlingErrors.increment();
|
||||
throw t;
|
||||
}
|
||||
finally
|
||||
|
@ -84,8 +84,8 @@ public class StatisticsHandler extends Handler.Wrapper
|
|||
_requestTimeStats.reset();
|
||||
_handleTimeStats.reset();
|
||||
_processTimeStats.reset();
|
||||
_processThrows.reset();
|
||||
_handleThrows.reset();
|
||||
_processingErrors.reset();
|
||||
_handlingErrors.reset();
|
||||
_responses1xx.reset();
|
||||
_responses2xx.reset();
|
||||
_responses3xx.reset();
|
||||
|
@ -142,15 +142,15 @@ public class StatisticsHandler extends Handler.Wrapper
|
|||
}
|
||||
|
||||
@ManagedAttribute("number of requests that threw an exception during handling")
|
||||
public int getHandleThrows()
|
||||
public int getHandlingErrors()
|
||||
{
|
||||
return _handleThrows.intValue();
|
||||
return _handlingErrors.intValue();
|
||||
}
|
||||
|
||||
@ManagedAttribute("number of requests that threw an exception during processing")
|
||||
public int getProcessThrows()
|
||||
public int getProcessingErrors()
|
||||
{
|
||||
return _processThrows.intValue();
|
||||
return _processingErrors.intValue();
|
||||
}
|
||||
|
||||
@ManagedAttribute("")
|
||||
|
@ -362,7 +362,7 @@ public class StatisticsHandler extends Handler.Wrapper
|
|||
}
|
||||
catch (Throwable t)
|
||||
{
|
||||
_processThrows.increment();
|
||||
_processingErrors.increment();
|
||||
throw t;
|
||||
}
|
||||
finally
|
||||
|
|
|
@ -693,8 +693,8 @@ public class StatisticsHandlerTest
|
|||
assertEquals(0, _statsHandler.getResponses3xx());
|
||||
assertEquals(0, _statsHandler.getResponses4xx());
|
||||
assertEquals(0, _statsHandler.getResponses5xx());
|
||||
assertEquals(1, _statsHandler.getHandleThrows());
|
||||
assertEquals(0, _statsHandler.getProcessThrows());
|
||||
assertEquals(1, _statsHandler.getHandlingErrors());
|
||||
assertEquals(0, _statsHandler.getProcessingErrors());
|
||||
}
|
||||
|
||||
@Test
|
||||
|
@ -733,8 +733,8 @@ public class StatisticsHandlerTest
|
|||
assertEquals(0, _statsHandler.getResponses3xx());
|
||||
assertEquals(0, _statsHandler.getResponses4xx());
|
||||
assertEquals(1, _statsHandler.getResponses5xx());
|
||||
assertEquals(0, _statsHandler.getHandleThrows());
|
||||
assertEquals(1, _statsHandler.getProcessThrows());
|
||||
assertEquals(0, _statsHandler.getHandlingErrors());
|
||||
assertEquals(1, _statsHandler.getProcessingErrors());
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -74,7 +74,7 @@ public class StatisticsServlet extends HttpServlet
|
|||
public void init() throws ServletException
|
||||
{
|
||||
ServletContext context = getServletContext();
|
||||
ContextHandler.Context scontext = (ContextHandler.Context)context;
|
||||
ContextHandler.Context scontext = ServletContextHandler.getServletContextHandler(context).getContext();
|
||||
Server server = scontext.getContextHandler().getServer();
|
||||
|
||||
_statsHandler = server.getDescendant(StatisticsHandler.class);
|
||||
|
@ -121,7 +121,7 @@ public class StatisticsServlet extends HttpServlet
|
|||
if (Boolean.parseBoolean(request.getParameter("statsReset")))
|
||||
{
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
// TODO: _statsHandler.statsReset();
|
||||
_statsHandler.reset();
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -256,11 +256,8 @@ public class StatisticsServlet extends HttpServlet
|
|||
{
|
||||
Map<String, Object> top = new HashMap<>();
|
||||
|
||||
/*
|
||||
TODO: update to use new StatisticsHandler.
|
||||
// requests
|
||||
Map<String, Number> requests = new HashMap<>();
|
||||
requests.put("statsOnMs", _statsHandler.getStatsOnMs());
|
||||
|
||||
requests.put("requests", _statsHandler.getRequests());
|
||||
|
||||
|
@ -271,21 +268,21 @@ public class StatisticsServlet extends HttpServlet
|
|||
requests.put("requestsTimeMax", _statsHandler.getRequestTimeMax());
|
||||
requests.put("requestsTimeStdDev", _statsHandler.getRequestTimeStdDev());
|
||||
|
||||
requests.put("dispatched", _statsHandler.getDispatched());
|
||||
requests.put("dispatchedActive", _statsHandler.getDispatchedActive());
|
||||
requests.put("dispatchedActiveMax", _statsHandler.getDispatchedActiveMax());
|
||||
requests.put("dispatchedTimeTotal", _statsHandler.getDispatchedTimeTotal());
|
||||
requests.put("dispatchedTimeMean", _statsHandler.getDispatchedTimeMean());
|
||||
requests.put("dispatchedTimeMax", _statsHandler.getDispatchedTimeMax());
|
||||
requests.put("dispatchedTimeStdDev", _statsHandler.getDispatchedTimeStdDev());
|
||||
requests.put("handlings", _statsHandler.getHandlings());
|
||||
requests.put("handlingThrows", _statsHandler.getHandlingErrors());
|
||||
requests.put("handlingTimeTotal", _statsHandler.getHandlingTimeTotal());
|
||||
requests.put("handlingTimeMax", _statsHandler.getHandlingTimeMax());
|
||||
requests.put("handlingTimeMean", _statsHandler.getHandlingTimeMean());
|
||||
requests.put("handlingTimeStdDev", _statsHandler.getHandlingTimeStdDev());
|
||||
|
||||
requests.put("asyncRequests", _statsHandler.getAsyncRequests());
|
||||
requests.put("requestsSuspended", _statsHandler.getAsyncDispatches());
|
||||
requests.put("requestsSuspendedMax", _statsHandler.getAsyncRequestsWaiting());
|
||||
requests.put("requestsResumed", _statsHandler.getAsyncRequestsWaitingMax());
|
||||
requests.put("requestsExpired", _statsHandler.getExpires());
|
||||
|
||||
requests.put("errors", _statsHandler.getErrors());
|
||||
requests.put("processings", _statsHandler.getProcessings());
|
||||
requests.put("processingsActive", _statsHandler.getProcessingsActive());
|
||||
requests.put("processingsMax", _statsHandler.getProcessingsMax());
|
||||
requests.put("processingErrors", _statsHandler.getProcessingErrors());
|
||||
requests.put("processingTimeTotal", _statsHandler.getProcessingTimeTotal());
|
||||
requests.put("processingTimeMax", _statsHandler.getProcessingTimeMax());
|
||||
requests.put("processingTimeMean", _statsHandler.getProcessingTimeMean());
|
||||
requests.put("processingTimeStdDev", _statsHandler.getProcessingTimeStdDev());
|
||||
|
||||
top.put("requests", requests);
|
||||
|
||||
|
@ -296,9 +293,7 @@ public class StatisticsServlet extends HttpServlet
|
|||
responses.put("responses3xx", _statsHandler.getResponses3xx());
|
||||
responses.put("responses4xx", _statsHandler.getResponses4xx());
|
||||
responses.put("responses5xx", _statsHandler.getResponses5xx());
|
||||
responses.put("responsesBytesTotal", _statsHandler.getResponsesBytesTotal());
|
||||
top.put("responses", responses);
|
||||
*/
|
||||
|
||||
// connections
|
||||
List<Object> connections = new ArrayList<>();
|
||||
|
|
|
@ -39,7 +39,6 @@ import org.eclipse.jetty.server.handler.StatisticsHandler;
|
|||
import org.eclipse.jetty.util.ajax.JSON;
|
||||
import org.junit.jupiter.api.AfterEach;
|
||||
import org.junit.jupiter.api.BeforeEach;
|
||||
import org.junit.jupiter.api.Disabled;
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.params.ParameterizedTest;
|
||||
import org.junit.jupiter.params.provider.Arguments;
|
||||
|
@ -55,7 +54,6 @@ import static org.hamcrest.Matchers.not;
|
|||
import static org.junit.jupiter.api.Assertions.assertEquals;
|
||||
import static org.junit.jupiter.api.Assertions.assertNotNull;
|
||||
|
||||
@Disabled
|
||||
public class StatisticsServletTest
|
||||
{
|
||||
private Server _server;
|
||||
|
|
Loading…
Reference in New Issue