Reputation: 4673
I want to migrate my app from jetty 7 to 9. In Jetty 7 I iterated through server connectors and got all information
for (int i = 0; i < server.getConnectors().length; i++) {
long durationMax = server.getConnectors()[i].getConnectionsDurationMax();
long openMax = server.getConnectors()[i].getConnectionsOpenMax();
long requestsMax = server.getConnectors()[i].getConnectionsRequestsMax();
}
How do I do it in Jetty 9 ?
Upvotes: 0
Views: 2593
Reputation: 49462
Use org.eclipse.jetty.server.ConnectorStatistics
// Add the statistics module to the connector
ConnectorStatistics stats = new ConnectorStatistics();
connector.addBean(stats);
// Then access the information.
System.out.printf("Connector.getConnections() = %,d%n", stats.getConnections());
System.out.printf("Connector.getConnectionsOpen() = %,d%n", stats.getConnectionsOpen());
System.out.printf("Connector.getConnectionsMax() = %,d%n", stats.getConnectionsMax());
See the Javadoc for the other values that are collected and available via getters.
Stats are also available via JMX if you enable JMX.
Upvotes: 3