Search in sources :

Example 1 with Container

use of org.eclipse.jetty.util.component.Container 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("&nbsp;");
        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());
}
Also used : AbstractConnector(org.eclipse.jetty.server.AbstractConnector) Connector(org.eclipse.jetty.server.Connector) Container(org.eclipse.jetty.util.component.Container) ConnectionStatistics(org.eclipse.jetty.io.ConnectionStatistics) ConnectorStatistics(org.eclipse.jetty.server.ConnectorStatistics) AbstractConnector(org.eclipse.jetty.server.AbstractConnector) PrintWriter(java.io.PrintWriter)

Example 2 with Container

use of org.eclipse.jetty.util.component.Container in project jetty.project by eclipse.

the class MBeanContainerTest method setBeanAdded.

private void setBeanAdded() {
    managed = new Managed();
    Container container = new ContainerLifeCycle();
    mbeanContainer.beanAdded(container, managed);
    mbeanServer = mbeanContainer.getMBeanServer();
}
Also used : Container(org.eclipse.jetty.util.component.Container) ContainerLifeCycle(org.eclipse.jetty.util.component.ContainerLifeCycle) Managed(com.acme.Managed)

Example 3 with Container

use of org.eclipse.jetty.util.component.Container in project cxf by apache.

the class JettyHTTPServerEngine method addServerMBean.

private void addServerMBean() {
    if (mBeanContainer == null) {
        return;
    }
    try {
        Container container = getContainer(server);
        container.addEventListener(mBeanContainer);
        mBeanContainer.beanAdded(null, server);
    } catch (RuntimeException rex) {
        throw rex;
    } catch (Exception r) {
        throw new RuntimeException(r);
    }
}
Also used : Container(org.eclipse.jetty.util.component.Container) ServletException(javax.servlet.ServletException) UncheckedIOException(java.io.UncheckedIOException) IOException(java.io.IOException)

Aggregations

Container (org.eclipse.jetty.util.component.Container)3 Managed (com.acme.Managed)1 IOException (java.io.IOException)1 PrintWriter (java.io.PrintWriter)1 UncheckedIOException (java.io.UncheckedIOException)1 ServletException (javax.servlet.ServletException)1 ConnectionStatistics (org.eclipse.jetty.io.ConnectionStatistics)1 AbstractConnector (org.eclipse.jetty.server.AbstractConnector)1 Connector (org.eclipse.jetty.server.Connector)1 ConnectorStatistics (org.eclipse.jetty.server.ConnectorStatistics)1 ContainerLifeCycle (org.eclipse.jetty.util.component.ContainerLifeCycle)1