Fixes #131 - Improve Connector Statistic names and values.
Removed references to deprecated ConnectorStatistic in favor of ConnectionStatistics.
This commit is contained in:
parent
464dd0667a
commit
cb89ea8466
|
@ -72,10 +72,10 @@ This example comes from within `jetty-http.xml`.
|
|||
<Set name="host"><Property name="jetty.host" /></Set>
|
||||
<Set name="port"><Property name="jetty.http.port" default="8080" /></Set>
|
||||
<Set name="idleTimeout">30000</Set>
|
||||
<!-- Enable Connector Statistics -->
|
||||
<!-- Enable Connection Statistics -->
|
||||
<Call name="addBean">
|
||||
<Arg>
|
||||
<New id="ConnectorStatistics" class="org.eclipse.jetty.server.ConnectorStatistics"/>
|
||||
<New id="ConnectionStatistics" class="org.eclipse.jetty.io.ConnectionStatistics"/>
|
||||
</Arg>
|
||||
</Call>
|
||||
</New>
|
||||
|
|
|
@ -27,13 +27,13 @@ import java.util.Collections;
|
|||
import java.util.List;
|
||||
import java.util.Locale;
|
||||
|
||||
import org.eclipse.jetty.io.ConnectionStatistics;
|
||||
import org.eclipse.jetty.security.ConstraintMapping;
|
||||
import org.eclipse.jetty.security.ConstraintSecurityHandler;
|
||||
import org.eclipse.jetty.security.HashLoginService;
|
||||
import org.eclipse.jetty.security.authentication.BasicAuthenticator;
|
||||
import org.eclipse.jetty.server.AbstractConnector;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.ConnectorStatistics;
|
||||
import org.eclipse.jetty.server.Handler;
|
||||
import org.eclipse.jetty.server.NCSARequestLog;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -395,15 +395,15 @@ public class Runner
|
|||
connector.setHost(host);
|
||||
_server.addConnector(connector);
|
||||
if (_enableStats)
|
||||
connector.addBean(new ConnectorStatistics());
|
||||
connector.addBean(new ConnectionStatistics());
|
||||
}
|
||||
else
|
||||
{
|
||||
if (_enableStats)
|
||||
{
|
||||
for (Connector connector : connectors)
|
||||
for (Connector connector : connectors)
|
||||
{
|
||||
((AbstractConnector) connector).addBean(new ConnectorStatistics());
|
||||
((AbstractConnector) connector).addBean(new ConnectionStatistics());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,266 +0,0 @@
|
|||
//
|
||||
// ========================================================================
|
||||
// Copyright (c) 1995-2016 Mort Bay Consulting Pty. Ltd.
|
||||
// ------------------------------------------------------------------------
|
||||
// All rights reserved. This program and the accompanying materials
|
||||
// are made available under the terms of the Eclipse Public License v1.0
|
||||
// and Apache License v2.0 which accompanies this distribution.
|
||||
//
|
||||
// The Eclipse Public License is available at
|
||||
// http://www.eclipse.org/legal/epl-v10.html
|
||||
//
|
||||
// The Apache License v2.0 is available at
|
||||
// http://www.opensource.org/licenses/apache2.0.php
|
||||
//
|
||||
// You may elect to redistribute this code under either of these licenses.
|
||||
// ========================================================================
|
||||
//
|
||||
|
||||
package org.eclipse.jetty.server;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.PrintWriter;
|
||||
import java.net.Socket;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.CyclicBarrier;
|
||||
|
||||
import javax.servlet.ServletException;
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.handler.AbstractHandler;
|
||||
import org.eclipse.jetty.server.handler.HandlerWrapper;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
import org.junit.After;
|
||||
import org.junit.AfterClass;
|
||||
import org.junit.Before;
|
||||
import org.junit.BeforeClass;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
|
||||
@Ignore("Ignored while refactoring the connection events and statistics")
|
||||
public class ConnectorStatisticsTest
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(ConnectorStatisticsTest.class);
|
||||
|
||||
private static Server _server;
|
||||
private static ConnectorStatistics _statistics;
|
||||
private static AbstractNetworkConnector _connector;
|
||||
private static CyclicBarrier _connect;
|
||||
private static CountDownLatch _closed;
|
||||
|
||||
private Socket[] _socket;
|
||||
private PrintWriter[] _out;
|
||||
private BufferedReader[] _in;
|
||||
|
||||
@BeforeClass
|
||||
public static void initClass() throws Exception
|
||||
{
|
||||
_connect = new CyclicBarrier(2);
|
||||
|
||||
_server = new Server();
|
||||
_connector = new ServerConnector(_server);
|
||||
_statistics = new ConnectorStatistics();
|
||||
_connector.addBean(_statistics);
|
||||
_server.addConnector(_connector);
|
||||
|
||||
HandlerWrapper wrapper = new HandlerWrapper()
|
||||
{
|
||||
@Override
|
||||
public void handle(String path, Request request, HttpServletRequest httpRequest, HttpServletResponse httpResponse) throws IOException, ServletException
|
||||
{
|
||||
try
|
||||
{
|
||||
_connect.await();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
LOG.debug(ex);
|
||||
}
|
||||
finally
|
||||
{
|
||||
super.handle(path, request, httpRequest, httpResponse);
|
||||
}
|
||||
}
|
||||
};
|
||||
_server.setHandler(wrapper);
|
||||
|
||||
Handler handler = new AbstractHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(String target, Request baseRequest, HttpServletRequest request, HttpServletResponse response)
|
||||
throws IOException, ServletException
|
||||
{
|
||||
try{Thread.sleep(1);} catch(Exception e){}
|
||||
baseRequest.setHandled(true);
|
||||
PrintWriter out = response.getWriter();
|
||||
out.write("Server response\n");
|
||||
out.close();
|
||||
|
||||
response.setStatus(HttpServletResponse.SC_OK);
|
||||
}
|
||||
};
|
||||
wrapper.setHandler(handler);
|
||||
|
||||
_server.start();
|
||||
}
|
||||
|
||||
@AfterClass
|
||||
public static void destroy() throws Exception
|
||||
{
|
||||
_server.stop();
|
||||
_server.join();
|
||||
}
|
||||
|
||||
@Before
|
||||
public void init() throws Exception
|
||||
{
|
||||
_statistics.reset();
|
||||
}
|
||||
|
||||
@After
|
||||
public void tini() throws Exception
|
||||
{
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testSingleRequest() throws Exception
|
||||
{
|
||||
doInit(1);
|
||||
|
||||
sendRequest(1, 1);
|
||||
|
||||
doClose(1);
|
||||
|
||||
assertEquals(1, _statistics.getConnections());
|
||||
assertEquals(0, _statistics.getConnectionsOpen());
|
||||
assertEquals(1, _statistics.getConnectionsOpenMax());
|
||||
assertTrue(_statistics.getConnectionsOpen() <= _statistics.getConnectionsOpenMax());
|
||||
|
||||
assertTrue(_statistics.getConnectionDurationMean() > 0);
|
||||
assertTrue(_statistics.getConnectionDurationMax() > 0);
|
||||
assertTrue(_statistics.getConnectionDurationMean() <= _statistics.getConnectionDurationMax());
|
||||
|
||||
assertEquals(1, _statistics.getMessagesIn());
|
||||
assertEquals(1.0, _statistics.getMessagesInPerConnectionMean(), 0.01);
|
||||
assertEquals(1, _statistics.getMessagesInPerConnectionMax());
|
||||
assertTrue(_statistics.getMessagesInPerConnectionMean() <= _statistics.getMessagesInPerConnectionMax());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleRequests() throws Exception
|
||||
{
|
||||
doInit(1);
|
||||
|
||||
sendRequest(1, 1);
|
||||
|
||||
sendRequest(1, 1);
|
||||
|
||||
doClose(1);
|
||||
|
||||
assertEquals(1, _statistics.getConnections());
|
||||
assertEquals(0, _statistics.getConnectionsOpen());
|
||||
assertEquals(1, _statistics.getConnectionsOpenMax());
|
||||
assertTrue(_statistics.getConnectionsOpen() <= _statistics.getConnectionsOpenMax());
|
||||
|
||||
assertTrue(_statistics.getConnectionDurationMean() > 0);
|
||||
assertTrue(_statistics.getConnectionDurationMax() > 0);
|
||||
assertTrue(_statistics.getConnectionDurationMean() <= _statistics.getConnectionDurationMax());
|
||||
|
||||
assertEquals(2, _statistics.getMessagesIn());
|
||||
assertEquals(2.0, _statistics.getMessagesInPerConnectionMean(), 0.01);
|
||||
assertEquals(2, _statistics.getMessagesInPerConnectionMax());
|
||||
assertTrue(_statistics.getMessagesInPerConnectionMean() <= _statistics.getMessagesInPerConnectionMax());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testMultipleConnections() throws Exception
|
||||
{
|
||||
doInit(3);
|
||||
|
||||
sendRequest(1, 1); // request 1 connection 1
|
||||
|
||||
sendRequest(2, 2); // request 1 connection 2
|
||||
|
||||
sendRequest(3, 3); // request 1 connection 3
|
||||
|
||||
sendRequest(2, 3); // request 2 connection 2
|
||||
|
||||
sendRequest(3, 3); // request 2 connection 3
|
||||
|
||||
sendRequest(3, 3); // request 3 connection 3
|
||||
|
||||
doClose(3);
|
||||
|
||||
assertEquals(3, _statistics.getConnections());
|
||||
assertEquals(0, _statistics.getConnectionsOpen());
|
||||
assertEquals(3, _statistics.getConnectionsOpenMax());
|
||||
assertTrue(_statistics.getConnectionsOpen() <= _statistics.getConnectionsOpenMax());
|
||||
|
||||
assertTrue(_statistics.getConnectionDurationMean() > 0);
|
||||
assertTrue(_statistics.getConnectionDurationMax() > 0);
|
||||
assertTrue(_statistics.getConnectionDurationMean() <= _statistics.getConnectionDurationMax());
|
||||
|
||||
assertEquals(6, _statistics.getMessagesIn());
|
||||
assertEquals(2.0, _statistics.getMessagesInPerConnectionMean(), 0.01);
|
||||
assertEquals(3, _statistics.getMessagesInPerConnectionMax());
|
||||
assertTrue(_statistics.getMessagesInPerConnectionMean() <= _statistics.getMessagesInPerConnectionMax());
|
||||
}
|
||||
|
||||
protected void doInit(int count)
|
||||
{
|
||||
_socket = new Socket[count];
|
||||
_out = new PrintWriter[count];
|
||||
_in = new BufferedReader[count];
|
||||
|
||||
_closed = new CountDownLatch(count);
|
||||
}
|
||||
|
||||
private void doClose(int count) throws Exception
|
||||
{
|
||||
for (int idx=0; idx < count; idx++)
|
||||
{
|
||||
if (_socket[idx] != null)
|
||||
{
|
||||
_socket[idx].close();
|
||||
}
|
||||
}
|
||||
|
||||
_closed.await();
|
||||
}
|
||||
|
||||
private void sendRequest(int id, int count) throws Exception
|
||||
{
|
||||
int idx = id - 1;
|
||||
|
||||
if (idx < 0)
|
||||
throw new IllegalArgumentException("Connection ID <= 0");
|
||||
|
||||
_socket[idx] = _socket[idx] == null ? new Socket("localhost", _connector.getLocalPort()) : _socket[idx];
|
||||
_out[idx] = _out[idx] == null ? new PrintWriter(_socket[idx].getOutputStream(), true) : _out[idx];
|
||||
_in[idx] = _in[idx] == null ? new BufferedReader(new InputStreamReader(_socket[idx].getInputStream())) : _in[idx];
|
||||
|
||||
_connect.reset();
|
||||
|
||||
_out[idx].write("GET / HTTP/1.1\r\nHost: localhost\r\n\r\n");
|
||||
_out[idx].flush();
|
||||
|
||||
_connect.await();
|
||||
|
||||
assertEquals(count, _statistics.getConnectionsOpen());
|
||||
|
||||
String line=_in[idx].readLine();
|
||||
while(line!=null)
|
||||
{
|
||||
if ("Server response".equals(line))
|
||||
break;
|
||||
line=_in[idx].readLine();
|
||||
}
|
||||
}
|
||||
}
|
|
@ -18,12 +18,6 @@
|
|||
|
||||
package org.eclipse.jetty.server.handler;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.CyclicBarrier;
|
||||
|
@ -37,7 +31,7 @@ import javax.servlet.ServletException;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.server.ConnectorStatistics;
|
||||
import org.eclipse.jetty.io.ConnectionStatistics;
|
||||
import org.eclipse.jetty.server.LocalConnector;
|
||||
import org.eclipse.jetty.server.Request;
|
||||
import org.eclipse.jetty.server.Server;
|
||||
|
@ -45,10 +39,16 @@ import org.junit.After;
|
|||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.Matchers.greaterThanOrEqualTo;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class StatisticsHandlerTest
|
||||
{
|
||||
private Server _server;
|
||||
private ConnectorStatistics _statistics;
|
||||
private ConnectionStatistics _statistics;
|
||||
private LocalConnector _connector;
|
||||
private LatchHandler _latchHandler;
|
||||
private StatisticsHandler _statsHandler;
|
||||
|
@ -59,7 +59,7 @@ public class StatisticsHandlerTest
|
|||
_server = new Server();
|
||||
|
||||
_connector = new LocalConnector(_server);
|
||||
_statistics = new ConnectorStatistics();
|
||||
_statistics = new ConnectionStatistics();
|
||||
_connector.addBean(_statistics);
|
||||
_server.addConnector(_connector);
|
||||
|
||||
|
@ -110,7 +110,7 @@ public class StatisticsHandlerTest
|
|||
|
||||
barrier[0].await();
|
||||
|
||||
assertEquals(1, _statistics.getConnectionsOpen());
|
||||
assertEquals(1, _statistics.getConnections());
|
||||
|
||||
assertEquals(1, _statsHandler.getRequests());
|
||||
assertEquals(1, _statsHandler.getRequestsActive());
|
||||
|
@ -145,7 +145,7 @@ public class StatisticsHandlerTest
|
|||
|
||||
barrier[0].await();
|
||||
|
||||
assertEquals(2, _statistics.getConnectionsOpen());
|
||||
assertEquals(2, _statistics.getConnections());
|
||||
|
||||
assertEquals(2, _statsHandler.getRequests());
|
||||
assertEquals(1, _statsHandler.getRequestsActive());
|
||||
|
@ -208,7 +208,7 @@ public class StatisticsHandlerTest
|
|||
|
||||
barrier[0].await();
|
||||
|
||||
assertEquals(2, _statistics.getConnectionsOpen());
|
||||
assertEquals(2, _statistics.getConnections());
|
||||
|
||||
assertEquals(2, _statsHandler.getRequests());
|
||||
assertEquals(2, _statsHandler.getRequestsActive());
|
||||
|
@ -282,7 +282,7 @@ public class StatisticsHandlerTest
|
|||
|
||||
barrier[0].await();
|
||||
|
||||
assertEquals(1, _statistics.getConnectionsOpen());
|
||||
assertEquals(1, _statistics.getConnections());
|
||||
assertEquals(1, _statsHandler.getRequests());
|
||||
assertEquals(1, _statsHandler.getRequestsActive());
|
||||
assertEquals(1, _statsHandler.getDispatched());
|
||||
|
@ -336,7 +336,7 @@ public class StatisticsHandlerTest
|
|||
|
||||
barrier[0].await(); // entered app handler
|
||||
|
||||
assertEquals(1, _statistics.getConnectionsOpen());
|
||||
assertEquals(1, _statistics.getConnections());
|
||||
assertEquals(1, _statsHandler.getRequests());
|
||||
assertEquals(1, _statsHandler.getRequestsActive());
|
||||
assertEquals(2, _statsHandler.getDispatched());
|
||||
|
@ -416,7 +416,7 @@ public class StatisticsHandlerTest
|
|||
|
||||
barrier[0].await();
|
||||
|
||||
assertEquals(1, _statistics.getConnectionsOpen());
|
||||
assertEquals(1, _statistics.getConnections());
|
||||
assertEquals(1, _statsHandler.getRequests());
|
||||
assertEquals(1, _statsHandler.getRequestsActive());
|
||||
assertEquals(1, _statsHandler.getDispatched());
|
||||
|
@ -532,7 +532,7 @@ public class StatisticsHandlerTest
|
|||
|
||||
barrier[0].await();
|
||||
|
||||
assertEquals(1, _statistics.getConnectionsOpen());
|
||||
assertEquals(1, _statistics.getConnections());
|
||||
assertEquals(1, _statsHandler.getRequests());
|
||||
assertEquals(1, _statsHandler.getRequestsActive());
|
||||
assertEquals(1, _statsHandler.getDispatched());
|
||||
|
|
|
@ -31,6 +31,7 @@ import javax.servlet.http.HttpServlet;
|
|||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.servlet.http.HttpServletResponse;
|
||||
|
||||
import org.eclipse.jetty.io.ConnectionStatistics;
|
||||
import org.eclipse.jetty.server.AbstractConnector;
|
||||
import org.eclipse.jetty.server.Connector;
|
||||
import org.eclipse.jetty.server.ConnectorStatistics;
|
||||
|
@ -38,14 +39,10 @@ import org.eclipse.jetty.server.Handler;
|
|||
import org.eclipse.jetty.server.Server;
|
||||
import org.eclipse.jetty.server.handler.ContextHandler;
|
||||
import org.eclipse.jetty.server.handler.StatisticsHandler;
|
||||
import org.eclipse.jetty.util.component.Container;
|
||||
import org.eclipse.jetty.util.log.Log;
|
||||
import org.eclipse.jetty.util.log.Logger;
|
||||
|
||||
/**
|
||||
* StatisticsServlet
|
||||
*
|
||||
*
|
||||
*/
|
||||
public class StatisticsServlet extends HttpServlet
|
||||
{
|
||||
private static final Logger LOG = Log.getLogger(StatisticsServlet.class);
|
||||
|
@ -55,11 +52,6 @@ public class StatisticsServlet extends HttpServlet
|
|||
private MemoryMXBean _memoryBean;
|
||||
private Connector[] _connectors;
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see javax.servlet.GenericServlet#init()
|
||||
*/
|
||||
public void init() throws ServletException
|
||||
{
|
||||
ServletContext context = getServletContext();
|
||||
|
@ -87,21 +79,11 @@ public class StatisticsServlet extends HttpServlet
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see javax.servlet.http.HttpServlet#doPost(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
*/
|
||||
public void doPost(HttpServletRequest sreq, HttpServletResponse sres) throws ServletException, IOException
|
||||
{
|
||||
doGet(sreq, sres);
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @see javax.servlet.http.HttpServlet#doGet(javax.servlet.http.HttpServletRequest, javax.servlet.http.HttpServletResponse)
|
||||
*/
|
||||
protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException
|
||||
{
|
||||
if (_statsHandler == null)
|
||||
|
@ -131,7 +113,6 @@ public class StatisticsServlet extends HttpServlet
|
|||
{
|
||||
sendTextResponse(resp);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private boolean isLoopbackAddress(String address)
|
||||
|
@ -199,24 +180,45 @@ public class StatisticsServlet extends HttpServlet
|
|||
sb.append(" <protocol>").append(protocol).append("</protocol>\n");
|
||||
sb.append(" </protocols>\n");
|
||||
|
||||
ConnectorStatistics connectorStats = null;
|
||||
|
||||
ConnectionStatistics connectionStats = null;
|
||||
if (connector instanceof AbstractConnector)
|
||||
connectorStats = ((AbstractConnector)connector).getBean(ConnectorStatistics.class);
|
||||
if (connectorStats == null)
|
||||
sb.append(" <statsOn>false</statsOn>\n");
|
||||
else
|
||||
connectionStats = ((AbstractConnector)connector).getBean(ConnectionStatistics.class);
|
||||
if (connectionStats != null)
|
||||
{
|
||||
sb.append(" <statsOn>true</statsOn>\n");
|
||||
sb.append(" <connections>").append(connectorStats.getConnections()).append("</connections>\n");
|
||||
sb.append(" <connectionsOpen>").append(connectorStats.getConnectionsOpen()).append("</connectionsOpen>\n");
|
||||
sb.append(" <connectionsOpenMax>").append(connectorStats.getConnectionsOpenMax()).append("</connectionsOpenMax>\n");
|
||||
sb.append(" <connectionsDurationMean>").append(connectorStats.getConnectionDurationMean()).append("</connectionsDurationMean>\n");
|
||||
sb.append(" <connectionsDurationMax>").append(connectorStats.getConnectionDurationMax()).append("</connectionsDurationMax>\n");
|
||||
sb.append(" <connectionsDurationStdDev>").append(connectorStats.getConnectionDurationStdDev()).append("</connectionsDurationStdDev>\n");
|
||||
sb.append(" <messagesIn>").append(connectorStats.getMessagesIn()).append("</messagesIn>\n");
|
||||
sb.append(" <messagesOut>").append(connectorStats.getMessagesIn()).append("</messagesOut>\n");
|
||||
sb.append(" <elapsedMs>").append(connectorStats.getStartedMillis()).append("</elapsedMs>\n");
|
||||
sb.append(" <connections>").append(connectionStats.getConnectionsTotal()).append("</connections>\n");
|
||||
sb.append(" <connectionsOpen>").append(connectionStats.getConnections()).append("</connectionsOpen>\n");
|
||||
sb.append(" <connectionsOpenMax>").append(connectionStats.getConnectionsMax()).append("</connectionsOpenMax>\n");
|
||||
sb.append(" <connectionsDurationMean>").append(connectionStats.getConnectionDurationMean()).append("</connectionsDurationMean>\n");
|
||||
sb.append(" <connectionsDurationMax>").append(connectionStats.getConnectionDurationMax()).append("</connectionsDurationMax>\n");
|
||||
sb.append(" <connectionsDurationStdDev>").append(connectionStats.getConnectionDurationStdDev()).append("</connectionsDurationStdDev>\n");
|
||||
sb.append(" <bytesIn>").append(connectionStats.getReceivedBytes()).append("</bytesIn>\n");
|
||||
sb.append(" <bytesOut>").append(connectionStats.getSentBytes()).append("</connectorStats>\n");
|
||||
sb.append(" <messagesIn>").append(connectionStats.getReceivedMessages()).append("</messagesIn>\n");
|
||||
sb.append(" <messagesOut>").append(connectionStats.getSentMessages()).append("</messagesOut>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
ConnectorStatistics connectorStats = null;
|
||||
if (connector instanceof AbstractConnector)
|
||||
connectorStats = ((AbstractConnector)connector).getBean(ConnectorStatistics.class);
|
||||
if (connectorStats != null)
|
||||
{
|
||||
sb.append(" <statsOn>true</statsOn>\n");
|
||||
sb.append(" <connections>").append(connectorStats.getConnections()).append("</connections>\n");
|
||||
sb.append(" <connectionsOpen>").append(connectorStats.getConnectionsOpen()).append("</connectionsOpen>\n");
|
||||
sb.append(" <connectionsOpenMax>").append(connectorStats.getConnectionsOpenMax()).append("</connectionsOpenMax>\n");
|
||||
sb.append(" <connectionsDurationMean>").append(connectorStats.getConnectionDurationMean()).append("</connectionsDurationMean>\n");
|
||||
sb.append(" <connectionsDurationMax>").append(connectorStats.getConnectionDurationMax()).append("</connectionsDurationMax>\n");
|
||||
sb.append(" <connectionsDurationStdDev>").append(connectorStats.getConnectionDurationStdDev()).append("</connectionsDurationStdDev>\n");
|
||||
sb.append(" <messagesIn>").append(connectorStats.getMessagesIn()).append("</messagesIn>\n");
|
||||
sb.append(" <messagesOut>").append(connectorStats.getMessagesIn()).append("</messagesOut>\n");
|
||||
sb.append(" <elapsedMs>").append(connectorStats.getStartedMillis()).append("</elapsedMs>\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append(" <statsOn>false</statsOn>\n");
|
||||
}
|
||||
}
|
||||
sb.append(" </connector>\n");
|
||||
}
|
||||
|
@ -234,12 +236,6 @@ public class StatisticsServlet extends HttpServlet
|
|||
pout.write(sb.toString());
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* @param response
|
||||
* @throws IOException
|
||||
*/
|
||||
private void sendTextResponse(HttpServletResponse response) throws IOException
|
||||
{
|
||||
StringBuilder sb = new StringBuilder();
|
||||
|
@ -254,28 +250,44 @@ public class StatisticsServlet extends HttpServlet
|
|||
sb.append(protocol).append(" ");
|
||||
sb.append(" <br />\n");
|
||||
|
||||
ConnectorStatistics connectorStats = null;
|
||||
|
||||
if (connector instanceof AbstractConnector)
|
||||
connectorStats = ((AbstractConnector)connector).getBean(ConnectorStatistics.class);
|
||||
|
||||
if (connectorStats != null)
|
||||
ConnectionStatistics connectionStats = null;
|
||||
if (connector instanceof Container)
|
||||
connectionStats = ((Container)connector).getBean(ConnectionStatistics.class);
|
||||
if (connectionStats != null)
|
||||
{
|
||||
sb.append("Statistics gathering started ").append(connectorStats.getStartedMillis()).append("ms ago").append("<br />\n");
|
||||
sb.append("Total connections: ").append(connectorStats.getConnections()).append("<br />\n");
|
||||
sb.append("Current connections open: ").append(connectorStats.getConnectionsOpen()).append("<br />\n");;
|
||||
sb.append("Max concurrent connections open: ").append(connectorStats.getConnectionsOpenMax()).append("<br />\n");
|
||||
sb.append("Mean connection duration: ").append(connectorStats.getConnectionDurationMean()).append("<br />\n");
|
||||
sb.append("Max connection duration: ").append(connectorStats.getConnectionDurationMax()).append("<br />\n");
|
||||
sb.append("Connection duration standard deviation: ").append(connectorStats.getConnectionDurationStdDev()).append("<br />\n");
|
||||
sb.append("Total messages in: ").append(connectorStats.getMessagesIn()).append("<br />\n");
|
||||
sb.append("Total messages out: ").append(connectorStats.getMessagesOut()).append("<br />\n");
|
||||
sb.append("Total connections: ").append(connectionStats.getConnectionsTotal()).append("<br />\n");
|
||||
sb.append("Current connections open: ").append(connectionStats.getConnections()).append("<br />\n");
|
||||
sb.append("Max concurrent connections open: ").append(connectionStats.getConnectionsMax()).append("<br />\n");
|
||||
sb.append("Mean connection duration: ").append(connectionStats.getConnectionDurationMean()).append("<br />\n");
|
||||
sb.append("Max connection duration: ").append(connectionStats.getConnectionDurationMax()).append("<br />\n");
|
||||
sb.append("Connection duration standard deviation: ").append(connectionStats.getConnectionDurationStdDev()).append("<br />\n");
|
||||
sb.append("Total bytes received: ").append(connectionStats.getReceivedBytes()).append("<br />\n");
|
||||
sb.append("Total bytes sent: ").append(connectionStats.getSentBytes()).append("<br />\n");
|
||||
sb.append("Total messages received: ").append(connectionStats.getReceivedMessages()).append("<br />\n");
|
||||
sb.append("Total messages sent: ").append(connectionStats.getSentMessages()).append("<br />\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("Statistics gathering off.\n");
|
||||
ConnectorStatistics connectorStats = null;
|
||||
if (connector instanceof AbstractConnector)
|
||||
connectorStats = ((AbstractConnector)connector).getBean(ConnectorStatistics.class);
|
||||
if (connectorStats != null)
|
||||
{
|
||||
sb.append("Statistics gathering started ").append(connectorStats.getStartedMillis()).append("ms ago").append("<br />\n");
|
||||
sb.append("Total connections: ").append(connectorStats.getConnections()).append("<br />\n");
|
||||
sb.append("Current connections open: ").append(connectorStats.getConnectionsOpen()).append("<br />\n");
|
||||
sb.append("Max concurrent connections open: ").append(connectorStats.getConnectionsOpenMax()).append("<br />\n");
|
||||
sb.append("Mean connection duration: ").append(connectorStats.getConnectionDurationMean()).append("<br />\n");
|
||||
sb.append("Max connection duration: ").append(connectorStats.getConnectionDurationMax()).append("<br />\n");
|
||||
sb.append("Connection duration standard deviation: ").append(connectorStats.getConnectionDurationStdDev()).append("<br />\n");
|
||||
sb.append("Total messages in: ").append(connectorStats.getMessagesIn()).append("<br />\n");
|
||||
sb.append("Total messages out: ").append(connectorStats.getMessagesOut()).append("<br />\n");
|
||||
}
|
||||
else
|
||||
{
|
||||
sb.append("Statistics gathering off.\n");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
sb.append("<h2>Memory:</h2>\n");
|
||||
|
@ -285,6 +297,5 @@ public class StatisticsServlet extends HttpServlet
|
|||
response.setContentType("text/html");
|
||||
PrintWriter pout = response.getWriter();
|
||||
pout.write(sb.toString());
|
||||
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue