Java 类org.eclipse.jetty.server.ConnectorStatistics 实例源码

项目:OHMS    文件:ServerNodeConnector.java   
public void setServer( Server server )
{
    this.server = server;

    // server.setHandler(new StatisticsHandler());
    ConnectorStatistics stats = server.getBean( ConnectorStatistics.class );

    try
    {
        stats.start();
    }
    catch ( Exception e )
    {
        logger.error( "cont start stats connector", e );
    }
}
项目:polygene-java    文件:JettyConfigurationHelper.java   
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() );
    }
}
项目:bigdataviewer-server    文件:ManagerHandler.java   
public ManagerHandler(
        final String baseURL,
        final Server server,
        final ConnectorStatistics connectorStats,
        final StatisticsHandler statHandler,
        final ContextHandlerCollection handlers,
        final String thumbnailsDirectoryName )
                throws IOException, URISyntaxException
{
    this.baseURL = baseURL;
    this.server = server;
    this.handlers = handlers;
    this.statHandler = statHandler;
    this.connectorStats = connectorStats;
    this.thumbnailsDirectoryName = thumbnailsDirectoryName;
    setContextPath( "/" + Constants.MANAGER_CONTEXT_NAME );
}
项目:OHMS    文件:ComponentEventRestServiceTest.java   
private Server initMocks( String status )
{
    ServerNodeConnector serverNodeConnector = ServerNodeConnector.getInstance();
    Server server = Mockito.mock( Server.class );
    serverNodeConnector.setServer( server );
    connectorStatistics = Mockito.mock( ConnectorStatistics.class );
    Mockito.when( serverNodeConnector.getServer().getBean( ConnectorStatistics.class ) ).thenReturn( connectorStatistics );
    Mockito.when( connectorStatistics.getState() ).thenReturn( status );
    return server;
}
项目:beyondj    文件:JettyHttpServer.java   
public List<ConnectorStatistics> getStatisticsConnectors() {
    return statisticsConnectors;
}
项目:beyondj    文件:JettyHttpServer.java   
public void setStatisticsConnectors(List<ConnectorStatistics> statisticsConnectors) {
    this.statisticsConnectors = statisticsConnectors;
}
项目:beyondj    文件:JettyLauncher.java   
private MetricsMessageCollection collectMetrics() {

        List<ConnectorStatistics> connectors = jettyHttpServer.getStatisticsConnectors();
        MetricsMessageCollection collection = new MetricsMessageCollection();

        for (ConnectorStatistics connector : connectors) {
            ConnectorStatistics statisticsConnector = (ConnectorStatistics) connector;
            MetricsMessage metricsMessage = new MetricsMessage();
            metricsMessage.setServerId(IpAddresssUtil.getLocalHostAddress().toString());
            metricsMessage.setLocationInCluster(options.getLocationInCluster());
            metricsMessage.setTargetEndpoint(options.getBundleInstanceId());
            metricsMessage.setContext(options.getContextPath());
            collection.getMessages().add(metricsMessage);
            int connections = statisticsConnector.getConnections();
            addMetric(metricsMessage, CONNECTIONS, connections);
            long connectionDurationMax = statisticsConnector.getConnectionDurationMax();
            addMetric(metricsMessage, CONNECTION_DURATION_MAX, connectionDurationMax);
            double connectionDurationMean = statisticsConnector.getConnectionDurationMean();
            addMetric(metricsMessage, CONNECTION_DURATION_MEAN, connectionDurationMean);
            double connectionDurationStdDev = statisticsConnector.getConnectionDurationStdDev();
            addMetric(metricsMessage, CONNECTION_DURATION_STD_DEV, connectionDurationStdDev);
            int messagesIn = statisticsConnector.getMessagesIn();
            addMetric(metricsMessage, MESSAGES_IN, messagesIn);
            int messagesInPerConnectionMax = statisticsConnector.getMessagesInPerConnectionMax();
            addMetric(metricsMessage, MESSAGES_IN_PER_CONNECTION_MAX, messagesInPerConnectionMax);
            double messagesInPerConnectionMean = statisticsConnector.getMessagesInPerConnectionMean();
            addMetric(metricsMessage, MESSAGES_IN_PER_CONNECTION_MEAN, messagesInPerConnectionMean);
            double messagesInPerConnectionStdDev = statisticsConnector.getMessagesInPerConnectionStdDev();
            addMetric(metricsMessage, MESSAGES_IN_PER_CONNECTION_STD_DEV, messagesInPerConnectionStdDev);
            int connectionsOpen = statisticsConnector.getConnectionsOpen();
            addMetric(metricsMessage, CONNECTIONS_OPEN, connectionsOpen);
            int connectionsOpenMax = statisticsConnector.getConnectionsOpenMax();
            addMetric(metricsMessage, CONNECTIONS_OPEN_MAX, connectionsOpenMax);
            int messagesOut = statisticsConnector.getMessagesOut();
            addMetric(metricsMessage, MESSAGES_OUT, messagesOut);
            int messagesOutPerConnectionMax = statisticsConnector.getMessagesOutPerConnectionMax();
            addMetric(metricsMessage, MESSAGES_OUT_PER_CONNECTION_MAX, messagesOutPerConnectionMax);
            double messagesOutPerConnectionMean = statisticsConnector.getMessagesOutPerConnectionMean();
            addMetric(metricsMessage, MESSAGES_OUT_PER_CONNECTION_MEAN, messagesOutPerConnectionMean);
            double messagesOutPerConnectionStdDev = statisticsConnector.getMessagesOutPerConnectionStdDev();
            addMetric(metricsMessage, MESSAGES_OUT_PER_CONNECTION_STD_DEV, messagesOutPerConnectionStdDev);
            long startedMillis = statisticsConnector.getStartedMillis();
            addMetric(metricsMessage, STARTED_MILLIS, startedMillis);
            int messagesInPerSecond = statisticsConnector.getMessagesInPerSecond();
            addMetric(metricsMessage, MESSAGES_IN_PER_SECOND, messagesInPerSecond);
            int messagesOutPerSecond = statisticsConnector.getMessagesOutPerSecond();
            addMetric(metricsMessage, MESSAGES_OUT_PER_SECOND, messagesOutPerSecond);

            DateTime dateTime = new DateTime();
            final GregorianCalendar calendar = new GregorianCalendar(dateTime.getZone().toTimeZone());
            calendar.setTimeInMillis(dateTime.getMillis());
            metricsMessage.setDateTimeCreated(new XMLGregorianCalendarImpl(calendar));

/*
            if (options.isEnableProfiling()) {
                //Thread pool stats
                try {
                    ThreadPoolStats stats = getThreadPoolStats();
                    addMetric(metricsMessage, REQUESTS_PER_SECOND_RETIREMENT_RATE, stats.getRequestPerSecondRetirementRate());
                    addMetric(metricsMessage, AVERAGE_SERVICE_TIME, stats.getAverageServiceTime());
                    addMetric(metricsMessage, AVERAGET_TIME_WAITING_IN_POOL, stats.getAverageTimeWaitingInPool());
                    addMetric(metricsMessage, AVERAGET_RESPONSE_TIME, stats.getAverageResponseTime());
                    addMetric(metricsMessage, ESTIMATED_AVERAGE_NUMBER_OF_ACTIVE_REQUESTS, stats.getEstimatedAverageNumberOfActiveRequests());
                    addMetric(metricsMessage, RATION_OF_DEAD_TIME_TO_RESPONSE_TIME, stats.getRatioOfDeadTimeToResponseTime());
                    addMetric(metricsMessage, AVERAGE_NUMBER_OF_ACTIVE_REQUESTS, stats.getAverageNumberOfActiveRequests());
                } catch (Exception e) {
                    //do nothing
                }
            }
*/
        }
        return collection;
    }
项目:bigdataviewer-server    文件:BigDataServer.java   
public static void main( final String[] args ) throws Exception
{
    System.setProperty( "org.eclipse.jetty.util.log.class", "org.eclipse.jetty.util.log.StdErrLog" );

    final Parameters params = processOptions( args, getDefaultParameters() );
    if ( params == null )
        return;

    final String thumbnailsDirectoryName = getThumbnailDirectoryPath( params );

    // Threadpool for multiple connections
    final Server server = new Server( new QueuedThreadPool( 200, 8 ) );

    // ServerConnector configuration
    final ServerConnector connector = new ServerConnector( server );
    connector.setHost( params.getHostname() );
    connector.setPort( params.getPort() );
    LOG.info( "Set connectors: " + connector );
    server.setConnectors( new Connector[] { connector } );
    final String baseURL = "http://" + server.getURI().getHost() + ":" + params.getPort();

    // Handler initialization
    final HandlerCollection handlers = new HandlerCollection();

    final ContextHandlerCollection datasetHandlers = createHandlers( baseURL, params.getDatasets(), thumbnailsDirectoryName );
    handlers.addHandler( datasetHandlers );
    handlers.addHandler( new JsonDatasetListHandler( server, datasetHandlers ) );

    Handler handler = handlers;
    if ( params.enableManagerContext() )
    {
        // Add Statistics bean to the connector
        final ConnectorStatistics connectorStats = new ConnectorStatistics();
        connector.addBean( connectorStats );

        // create StatisticsHandler wrapper and ManagerHandler
        final StatisticsHandler statHandler = new StatisticsHandler();
        handlers.addHandler( new ManagerHandler( baseURL, server, connectorStats, statHandler, datasetHandlers, thumbnailsDirectoryName ) );
        statHandler.setHandler( handlers );
        handler = statHandler;
    }

    LOG.info( "Set handler: " + handler );
    server.setHandler( handler );
    LOG.info( "Server Base URL: " + baseURL );
    LOG.info( "BigDataServer starting" );
    server.start();
    server.join();
}