Issue #472 Use LongAdder for statistics

Improved JMX context names
This commit is contained in:
Greg Wilkins 2016-04-05 12:53:19 +10:00
parent bbb7f2188c
commit 815764c279
2 changed files with 17 additions and 1 deletions

View File

@ -29,6 +29,7 @@ import org.eclipse.jetty.deploy.providers.WebAppProvider;
import org.eclipse.jetty.http.HttpVersion;
import org.eclipse.jetty.jmx.MBeanContainer;
import org.eclipse.jetty.security.HashLoginService;
import org.eclipse.jetty.server.ConnectorStatistics;
import org.eclipse.jetty.server.DebugListener;
import org.eclipse.jetty.server.Handler;
import org.eclipse.jetty.server.HttpConfiguration;
@ -185,6 +186,7 @@ public class LikeJettyXml
StatisticsHandler stats = new StatisticsHandler();
stats.setHandler(server.getHandler());
server.setHandler(stats);
ConnectorStatistics.addToAllConnectors(server);
// === jetty-requestlog.xml ===

View File

@ -20,6 +20,7 @@ package org.eclipse.jetty.server.jmx;
import org.eclipse.jetty.jmx.ObjectMBean;
import org.eclipse.jetty.server.AbstractConnector;
import org.eclipse.jetty.server.ConnectionFactory;
import org.eclipse.jetty.util.annotation.ManagedObject;
@ManagedObject("MBean Wrapper for Connectors")
@ -31,10 +32,23 @@ public class AbstractConnectorMBean extends ObjectMBean
super(managedObject);
_connector=(AbstractConnector)managedObject;
}
@Override
public String getObjectContextBasis()
{
return String.format("%s@%x",_connector.getDefaultProtocol(),_connector.hashCode());
StringBuilder buffer = new StringBuilder();
for (ConnectionFactory f:_connector.getConnectionFactories())
{
String protocol=f.getProtocol();
if (protocol!=null)
{
if (buffer.length()>0)
buffer.append("|");
buffer.append(protocol);
}
}
return String.format("%s@%x",buffer.toString(),_connector.hashCode());
}