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() ); } }
/** * Creates a Jetty low resource monitor. * * @param server * A Jetty server. * @return A Jetty low resource monitor or null. */ private LowResourceMonitor createLowResourceMonitor( org.eclipse.jetty.server.Server server ) { final int period = getLowResourceMonitorPeriod(); if( period > 0 ) { final LowResourceMonitor lowResourceMonitor = new LowResourceMonitor( server ); lowResourceMonitor.setMonitoredConnectors( Arrays.asList( server.getConnectors() ) ); lowResourceMonitor.setPeriod( period ); lowResourceMonitor.setMonitorThreads( getLowResourceMonitorThreads() ); lowResourceMonitor.setMaxConnections( getLowResourceMonitorMaxConnections() ); lowResourceMonitor.setMaxMemory( getLowResourceMonitorMaxMemory() ); lowResourceMonitor.setMaxLowResourcesTime( getLowResourceMonitorMaxTime() ); lowResourceMonitor.setLowResourcesIdleTimeout( getLowResourceMonitorIdleTimeout() ); lowResourceMonitor.setStopTimeout( getLowResourceMonitorStopTimeout() ); server.addBean( lowResourceMonitor ); return lowResourceMonitor; } return null; }
protected void configureLowResourceMonitor(Server server) { // monitor low resources LowResourceMonitor lowResourcesMonitor = new LowResourceMonitor(server); lowResourcesMonitor.setPeriod(jettyLowResourceMonitorSettings.getPeriod()); lowResourcesMonitor.setLowResourcesIdleTimeout(jettyLowResourceMonitorSettings.getIdleTimeout()); lowResourcesMonitor.setMonitorThreads(jettyLowResourceMonitorSettings.isMonitorThreads()); lowResourcesMonitor.setMaxConnections(jettyLowResourceMonitorSettings.getMaxConnections()); lowResourcesMonitor.setMaxMemory(jettyLowResourceMonitorSettings.getMaxMemory()); lowResourcesMonitor.setMaxLowResourcesTime(jettyLowResourceMonitorSettings.getMaxLowResourcesTime()); server.addBean(lowResourcesMonitor); }