use of org.eclipse.jetty.server.ConnectorStatistics in project jetty.project by eclipse.
the class StatisticsServlet method sendTextResponse.
private void sendTextResponse(HttpServletResponse response) throws IOException {
StringBuilder sb = new StringBuilder();
sb.append(_statsHandler.toStatsHTML());
sb.append("<h2>Connections:</h2>\n");
for (Connector connector : _connectors) {
sb.append("<h3>").append(connector.getClass().getName()).append("@").append(connector.hashCode()).append("</h3>");
sb.append("Protocols:");
for (String protocol : connector.getProtocols()) sb.append(protocol).append(" ");
sb.append(" <br />\n");
ConnectionStatistics connectionStats = null;
if (connector instanceof Container)
connectionStats = ((Container) connector).getBean(ConnectionStatistics.class);
if (connectionStats != null) {
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 {
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");
sb.append("Heap memory usage: ").append(_memoryBean.getHeapMemoryUsage().getUsed()).append(" bytes").append("<br />\n");
sb.append("Non-heap memory usage: ").append(_memoryBean.getNonHeapMemoryUsage().getUsed()).append(" bytes").append("<br />\n");
response.setContentType("text/html");
PrintWriter pout = response.getWriter();
pout.write(sb.toString());
}
use of org.eclipse.jetty.server.ConnectorStatistics in project killbill by killbill.
the class HttpServer method configureSslConnector.
private ServerConnector configureSslConnector(final HttpConfiguration httpConfiguration, final boolean isStatsOn, final int localSslPort, final String sslKeyStorePath, final String sslKeyStorePassword) {
// SSL Context Factory for HTTPS
final SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(sslKeyStorePath);
sslContextFactory.setKeyStorePassword(sslKeyStorePassword);
// HTTPS Configuration
final HttpConfiguration httpsConfig = new HttpConfiguration(httpConfiguration);
httpsConfig.addCustomizer(new SecureRequestCustomizer());
// HTTPS connector
final ServerConnector https = new ServerConnector(server, new SslConnectionFactory(sslContextFactory, HttpVersion.HTTP_1_1.asString()), new HttpConnectionFactory(httpsConfig));
https.setPort(localSslPort);
if (isStatsOn) {
final ConnectorStatistics stats = new ConnectorStatistics();
https.addBean(stats);
}
return https;
}
use of org.eclipse.jetty.server.ConnectorStatistics in project jetty.project by eclipse.
the class StatisticsServlet method sendXmlResponse.
private void sendXmlResponse(HttpServletResponse response) throws IOException {
StringBuilder sb = new StringBuilder();
sb.append("<statistics>\n");
sb.append(" <requests>\n");
sb.append(" <statsOnMs>").append(_statsHandler.getStatsOnMs()).append("</statsOnMs>\n");
sb.append(" <requests>").append(_statsHandler.getRequests()).append("</requests>\n");
sb.append(" <requestsActive>").append(_statsHandler.getRequestsActive()).append("</requestsActive>\n");
sb.append(" <requestsActiveMax>").append(_statsHandler.getRequestsActiveMax()).append("</requestsActiveMax>\n");
sb.append(" <requestsTimeTotal>").append(_statsHandler.getRequestTimeTotal()).append("</requestsTimeTotal>\n");
sb.append(" <requestsTimeMean>").append(_statsHandler.getRequestTimeMean()).append("</requestsTimeMean>\n");
sb.append(" <requestsTimeMax>").append(_statsHandler.getRequestTimeMax()).append("</requestsTimeMax>\n");
sb.append(" <requestsTimeStdDev>").append(_statsHandler.getRequestTimeStdDev()).append("</requestsTimeStdDev>\n");
sb.append(" <dispatched>").append(_statsHandler.getDispatched()).append("</dispatched>\n");
sb.append(" <dispatchedActive>").append(_statsHandler.getDispatchedActive()).append("</dispatchedActive>\n");
sb.append(" <dispatchedActiveMax>").append(_statsHandler.getDispatchedActiveMax()).append("</dispatchedActiveMax>\n");
sb.append(" <dispatchedTimeTotalMs>").append(_statsHandler.getDispatchedTimeTotal()).append("</dispatchedTimeTotalMs>\n");
sb.append(" <dispatchedTimeMeanMs>").append(_statsHandler.getDispatchedTimeMean()).append("</dispatchedTimeMeanMs>\n");
sb.append(" <dispatchedTimeMaxMs>").append(_statsHandler.getDispatchedTimeMax()).append("</dispatchedTimeMaxMs>\n");
sb.append(" <dispatchedTimeStdDevMs>").append(_statsHandler.getDispatchedTimeStdDev()).append("</dispatchedTimeStdDevMs>\n");
sb.append(" <asyncRequests>").append(_statsHandler.getAsyncRequests()).append("</asyncRequests>\n");
sb.append(" <requestsSuspended>").append(_statsHandler.getAsyncRequestsWaiting()).append("</requestsSuspended>\n");
sb.append(" <requestsSuspendedMax>").append(_statsHandler.getAsyncRequestsWaitingMax()).append("</requestsSuspendedMax>\n");
sb.append(" <requestsResumed>").append(_statsHandler.getAsyncDispatches()).append("</requestsResumed>\n");
sb.append(" <requestsExpired>").append(_statsHandler.getExpires()).append("</requestsExpired>\n");
sb.append(" </requests>\n");
sb.append(" <responses>\n");
sb.append(" <responses1xx>").append(_statsHandler.getResponses1xx()).append("</responses1xx>\n");
sb.append(" <responses2xx>").append(_statsHandler.getResponses2xx()).append("</responses2xx>\n");
sb.append(" <responses3xx>").append(_statsHandler.getResponses3xx()).append("</responses3xx>\n");
sb.append(" <responses4xx>").append(_statsHandler.getResponses4xx()).append("</responses4xx>\n");
sb.append(" <responses5xx>").append(_statsHandler.getResponses5xx()).append("</responses5xx>\n");
sb.append(" <responsesBytesTotal>").append(_statsHandler.getResponsesBytesTotal()).append("</responsesBytesTotal>\n");
sb.append(" </responses>\n");
sb.append(" <connections>\n");
for (Connector connector : _connectors) {
sb.append(" <connector>\n");
sb.append(" <name>").append(connector.getClass().getName()).append("@").append(connector.hashCode()).append("</name>\n");
sb.append(" <protocols>\n");
for (String protocol : connector.getProtocols()) sb.append(" <protocol>").append(protocol).append("</protocol>\n");
sb.append(" </protocols>\n");
ConnectionStatistics connectionStats = null;
if (connector instanceof AbstractConnector)
connectionStats = ((AbstractConnector) connector).getBean(ConnectionStatistics.class);
if (connectionStats != null) {
sb.append(" <statsOn>true</statsOn>\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");
}
sb.append(" </connections>\n");
sb.append(" <memory>\n");
sb.append(" <heapMemoryUsage>").append(_memoryBean.getHeapMemoryUsage().getUsed()).append("</heapMemoryUsage>\n");
sb.append(" <nonHeapMemoryUsage>").append(_memoryBean.getNonHeapMemoryUsage().getUsed()).append("</nonHeapMemoryUsage>\n");
sb.append(" </memory>\n");
sb.append("</statistics>\n");
response.setContentType("text/xml");
PrintWriter pout = response.getWriter();
pout.write(sb.toString());
}
use of org.eclipse.jetty.server.ConnectorStatistics in project qi4j-sdk by Qi4j.
the class JettyConfigurationHelper method configureServer.
static void configureServer(Server server, JettyConfiguration config) {
// Shutdown
Integer gracefullShudownTimeout = config.gracefullShutdownTimeout().get();
if (gracefullShudownTimeout != null) {
server.setStopTimeout(gracefullShudownTimeout);
}
// Low resource max idle time
Integer lowResourceMaxIdleTime = config.lowResourceMaxIdleTime().get();
if (lowResourceMaxIdleTime != null) {
LowResourceMonitor lowResourceMonitor = new LowResourceMonitor(server);
lowResourceMonitor.setLowResourcesIdleTimeout(lowResourceMaxIdleTime);
server.addBean(lowResourceMonitor);
}
// Statistics
if (config.statistics().get()) {
server.addBean(new ConnectorStatistics());
}
}
use of org.eclipse.jetty.server.ConnectorStatistics in project killbill by killbill.
the class HttpServer method configureMainConnector.
private ServerConnector configureMainConnector(final HttpConfiguration httpConfiguration, final boolean isStatsOn, final String localIp, final int localPort) {
final ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(httpConfiguration));
http.setHost(localIp);
http.setPort(localPort);
if (isStatsOn) {
final ConnectorStatistics stats = new ConnectorStatistics();
http.addBean(stats);
}
return http;
}
Aggregations