本文整理匯總了Java中org.eclipse.jetty.server.nio.SelectChannelConnector.setMaxIdleTime方法的典型用法代碼示例。如果您正苦於以下問題:Java SelectChannelConnector.setMaxIdleTime方法的具體用法?Java SelectChannelConnector.setMaxIdleTime怎麽用?Java SelectChannelConnector.setMaxIdleTime使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類org.eclipse.jetty.server.nio.SelectChannelConnector
的用法示例。
在下文中一共展示了SelectChannelConnector.setMaxIdleTime方法的9個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Java代碼示例。
示例1: init
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
* Method used to initialize and start the SSE server
*/
public static void init()
{
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(8070);
connector.setAcceptors(3);
connector.setThreadPool(new QueuedThreadPool(50));
connector.setMaxIdleTime(72*60*60*1000);
connector.setAcceptQueueSize(50000);
connector.setRequestBufferSize(50000);
connector.setResponseBufferSize(50000);
server.setConnectors(new Connector[] { connector });
ServletContextHandler context = new ServletContextHandler(
ServletContextHandler.SESSIONS);
context.setContextPath("/");
//context.setResourceBase(System.getProperty("java.io.tmpdir"));
ServletHolder requestServletHolder = new ServletHolder(EventServer.class);
context.addServlet(requestServletHolder, "/response");
ServletHolder notificationServletHolder = new ServletHolder(NotificationServer.class);
context.addServlet(notificationServletHolder, "/notification");
server.setHandler(context);
context.addEventListener(new ConfigureService());
context.addEventListener(new NotificationService());
try {
server.start();
LOG.info("Server Started");
server.join();
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
示例2: start
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@Override
public void start(final int port, final Serializer serializer) throws Exception {
Thread thread = new Thread(new Runnable() {
@Override
public void run() {
server = new Server();
server.setThreadPool(new ExecutorThreadPool(200, 200, 30000)); // 非阻塞
// connector
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
connector.setMaxIdleTime(30000);
server.setConnectors(new Connector[] { connector });
// handler
HandlerCollection handlerc =new HandlerCollection();
handlerc.setHandlers(new Handler[]{new JettyServerHandler(serializer)});
server.setHandler(handlerc);
try {
server.start();
logger.info(">>>>>>>>>>> xxl-rpc server start success, netcon={}, port={}", JettyServer.class.getName(), port);
server.join();
} catch (Exception e) {
logger.error("", e);
} finally {
server.destroy();
}
}
});
thread.setDaemon(true);
thread.start();
}
示例3: main
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
* Entry point of Ephyra. Initializes the engine and starts the web service interface.
*
* @param args command line arguments are ignored
*/
public static void main(String[] args) throws Exception {
// enable output of status and error messages
MsgPrinter.enableStatusMsgs(true);
MsgPrinter.enableErrorMsgs(true);
// set log file and enable logging
Logger.setLogfile("log/OpenEphyra");
Logger.enableLogging(true);
String addr = "localhost";
int port = 8080;
if (args.length > 1) {
addr = args[0];
port = Integer.parseInt(args[1]);
}
int NTHREADS = Integer.parseInt(System.getenv("THREADS"));
Server server = new Server();
SelectChannelConnector con1 = new SelectChannelConnector();
con1.setHost(addr);
con1.setPort(port);
con1.setThreadPool(new QueuedThreadPool(NTHREADS));
con1.setMaxIdleTime(30000);
con1.setRequestHeaderSize(8192);
server.setConnectors(new Connector[]{con1});
server.setHandler(new OpenEphyraServer());
server.start();
server.join();
}
示例4: createServer
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
/**
* Creates a Server that exposes the TestClient1 services via http and https
*
* @return the Server instance
*/
@Override
protected Server createServer() {
// Need this CredentialsSourceFactory in our config to enable our test of basic auth
// with our httpInvoker-echoServiceSecure
registerTestCredentialsSourceFactory();
ConfigConstants configConstants = new ConfigConstants();
Server server = new Server();
SelectChannelConnector connector0 = new SelectChannelConnector();
connector0.setPort(configConstants.SERVER_HTTP_PORT);
connector0.setMaxIdleTime(30000);
connector0.setRequestHeaderSize(8192);
SslSelectChannelConnector ssl_connector = new SslSelectChannelConnector();
ssl_connector.setPort(configConstants.SERVER_HTTPS_PORT);
SslContextFactory cf = ssl_connector.getSslContextFactory();
cf.setKeyStore(configConstants.KEYSTORE_PATH);
cf.setKeyStorePassword(configConstants.KEYSTORE_PASS);
cf.setKeyManagerPassword(configConstants.KEYSTORE_PASS);
server.setConnectors(new Connector[]{connector0, ssl_connector});
URL webRoot = getClass().getClassLoader().getResource(configConstants.WEB_ROOT);
String location = webRoot.getPath();
LOG.debug("#####################################");
LOG.debug("#");
LOG.debug("# Starting Client1 using following web root " + location);
LOG.debug("#");
LOG.debug("#####################################");
WebAppContext context = new WebAppContext();
context.setResourceBase(location);
context.setContextPath(configConstants.CONTEXT);
HandlerCollection handlers = new HandlerCollection();
handlers.addHandler(context);
server.setHandler(handlers);
server.setDumpAfterStart(true);
//server.setDumpBeforeStop(true);
return server;
}
示例5: deployWebApp
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private void deployWebApp() {
try {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
connector.setHost(getHost());
connector.setPort(getPort());
if (isHttpsEnabled()) {
connector.setConfidentialPort(getHttpsPort());
}
server.addConnector(connector);
if (isHttpsEnabled()) {
SslSocketConnector sslConnector = new SslSocketConnector();
sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setHost(getHost());
sslConnector.setPort(getHttpsPort());
sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
server.addConnector(sslConnector);
}
WebAppContext context = new WebAppContext();
context.setTempDirectory(getJettyDirectory());
context.setContextPath(getContextPath());
context.setWar(getWar());
if (isHttpsEnabled()) {
ConstraintMapping constraintMapping = new ConstraintMapping();
Constraint constraint = new Constraint();
constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
constraintMapping.setPathSpec("/");
constraintMapping.setConstraint(constraint);
ConstraintSecurityHandler csh = (ConstraintSecurityHandler) context.getSecurityHandler();
csh.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
}
server.setHandler(context);
server.start();
System.err.println("FutureSonic running on: " + getUrl());
if (isHttpsEnabled()) {
System.err.println(" and: " + getHttpsUrl());
}
} catch (Throwable x) {
x.printStackTrace();
exception = x;
}
}
示例6: deployWebApp
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
@SuppressWarnings("deprecation")
private void deployWebApp() {
try {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
connector.setHost(getHost());
connector.setPort(getPort());
if (isHttpsEnabled()) {
connector.setConfidentialPort(getHttpsPort());
}
server.addConnector(connector);
if (isHttpsEnabled()) {
SslSocketConnector sslConnector = new SslSocketConnector();
SslContextFactory sslContextFactory = sslConnector.getSslContextFactory();
sslContextFactory = sslConnector.getSslContextFactory();
sslContextFactory.setExcludeCipherSuites(
new String[] {
"SSL_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_RSA_WITH_DES_CBC_SHA",
"SSL_DHE_DSS_WITH_DES_CBC_SHA",
"SSL_RSA_EXPORT_WITH_RC4_40_MD5",
"SSL_RSA_EXPORT_WITH_DES40_CBC_SHA",
"SSL_DHE_RSA_EXPORT_WITH_DES40_CBC_SHA",
"SSL_DHE_DSS_EXPORT_WITH_DES40_CBC_SHA"
});
sslContextFactory.addExcludeProtocols(new String[]{"SSLv3","SSLv2Hello"});
sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setHost(getHost());
sslConnector.setPort(getHttpsPort());
sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
server.addConnector(sslConnector);
}
WebAppContext context = new WebAppContext();
context.setTempDirectory(getJettyDirectory());
context.setContextPath(getContextPath());
context.setWar(getWar());
context.setOverrideDescriptor("/web-jetty.xml");
if (isHttpsEnabled()) {
// Allow non-https for streaming and cover art (for Chromecast, UPnP etc)
((ConstraintSecurityHandler) context.getSecurityHandler()).setConstraintMappings(new ConstraintMapping[]{
createConstraintMapping("/stream", Constraint.DC_NONE),
createConstraintMapping("/coverArt.view", Constraint.DC_NONE),
createConstraintMapping("/", Constraint.DC_CONFIDENTIAL)
});
}
server.setHandler(context);
server.start();
System.err.println("Madsonic running on: " + getUrl());
if (isHttpsEnabled()) {
System.err.println(" and: " + getHttpsUrl());
}
} catch (Throwable x) {
x.printStackTrace();
exception = x;
}
}
示例7: main
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public static void main(String[] args) throws Exception {
Server server = new Server();
// traditional blocking IO and threading model, used if NIO not available
// SocketConnector connector = new SocketConnector();
// efficient NIO buffers with a non-blocking threading model, required for WebSockets
SelectChannelConnector connector = new SelectChannelConnector();
// Set some timeout options to make debugging easier.
connector.setMaxIdleTime(3600000);
connector.setSoLingerTime(-1);
connector.setPort(8080);
server.addConnector(connector);
/*
Resource keystore = Resource.newClassPathResource("/keystore");
if (keystore != null && keystore.exists()) {
connector.setConfidentialPort(8443);
SslContextFactory factory = new SslContextFactory();
factory.setKeyStoreResource(keystore);
factory.setKeyStorePassword("jettyjetty");
factory.setTrustStoreResource(keystore);
factory.setKeyManagerPassword("jettyjetty");
SslSocketConnector sslConnector = new SslSocketConnector(factory);
sslConnector.setMaxIdleTime(3600000);
sslConnector.setPort(8443);
sslConnector.setAcceptors(4);
server.addConnector(sslConnector);
System.out.println("SSL access to the quickstart has been enabled on port 8443");
System.out.println("You can access the application using SSL on https://localhost:8443");
System.out.println();
}
*/
String includeJarPattern =
".*/.*jsp-api-[^/]*\\.jar$|.*/.*jsp-[^/]*\\.jar$|.*/.*taglibs[^/]*\\.jar$";
ResourceCollection resources = new ResourceCollection(new String[] {
"src/main/webapp", "target/gwt-webapp"
});
WebAppContext webCtx = new WebAppContext();
webCtx.setServer(server);
webCtx.setContextPath("/");
// webCtx.setDescriptor("src/test/resources/web/test-web.xml");
webCtx.setBaseResource(resources);
webCtx.setAttribute("org.eclipse.jetty.server.webapp.ContainerIncludeJarPattern",
includeJarPattern);
server.setHandler(webCtx);
// BrowserListener gwtBrowserListener = new BrowserListener(null, "0.0.0.0",
// 9997, null);
try {
System.out.println(">>> STARTING EMBEDDED JETTY SERVER, PRESS ANY KEY TO STOP");
server.start();
System.in.read();
System.out.println(">>> STOPPING EMBEDDED JETTY SERVER");
server.stop();
server.join();
} catch (Exception e) {
e.printStackTrace();
System.exit(1);
}
}
示例8: deployWebApp
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
private void deployWebApp() {
try {
Server server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
connector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
connector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
connector.setHost(getHost());
connector.setPort(getPort());
if (isHttpsEnabled()) {
connector.setConfidentialPort(getHttpsPort());
}
server.addConnector(connector);
if (isHttpsEnabled()) {
SslSocketConnector sslConnector = new SslSocketConnector();
sslConnector.setMaxIdleTime(MAX_IDLE_TIME_MILLIS);
sslConnector.setRequestHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setResponseHeaderSize(HEADER_BUFFER_SIZE);
sslConnector.setHost(getHost());
sslConnector.setPort(getHttpsPort());
sslConnector.setKeystore(System.getProperty("subsonic.ssl.keystore", getClass().getResource("/subsonic.keystore").toExternalForm()));
sslConnector.setPassword(System.getProperty("subsonic.ssl.password", "subsonic"));
server.addConnector(sslConnector);
}
WebAppContext context = new WebAppContext();
context.setTempDirectory(getJettyDirectory());
context.setContextPath(getContextPath());
context.setWar(getWar());
if (isHttpsEnabled()) {
ConstraintMapping constraintMapping = new ConstraintMapping();
Constraint constraint = new Constraint();
constraint.setDataConstraint(Constraint.DC_CONFIDENTIAL);
constraintMapping.setPathSpec("/");
constraintMapping.setConstraint(constraint);
ConstraintSecurityHandler csh = (ConstraintSecurityHandler) context.getSecurityHandler();
csh.setConstraintMappings(new ConstraintMapping[]{constraintMapping});
}
server.setHandler(context);
server.start();
System.err.println("Madsonic running on: " + getUrl());
if (isHttpsEnabled()) {
System.err.println(" and: " + getHttpsUrl());
}
} catch (Throwable x) {
x.printStackTrace();
exception = x;
}
}
示例9: run
import org.eclipse.jetty.server.nio.SelectChannelConnector; //導入方法依賴的package包/類
public void run() {
Runtime.getRuntime().addShutdownHook(new ShutdownHook());
final AppConfig config = AppConfig.getInstance();
final int listenerthreads = config.getInt("server.listenerthreads", 2);
final org.eclipse.jetty.server.Server server = new org.eclipse.jetty.server.Server();
final SelectChannelConnector connector = new SelectChannelConnector();
final QueuedThreadPool qtp = new QueuedThreadPool();
qtp.setName("JettyWorkerPool");
qtp.setMinThreads(5);
qtp.setMaxThreads(config.getInt("server.worker", 20));
connector.setThreadPool(qtp);
connector.setHost(config.getString("server.bind", "0.0.0.0"));
connector.setPort(config.getInt("server.port", 8080));
connector.setMaxIdleTime(120000);
connector.setLowResourcesMaxIdleTime(60000);
connector.setLowResourcesConnections(20000);
connector.setAcceptQueueSize(5000);
connector.setName("pushrouter");
server.setConnectors(new Connector[]{(Connector) connector});
final ServletContextHandler schandler = new ServletContextHandler(ServletContextHandler.NO_SESSIONS);
schandler.setContextPath("/");
final ServletHolder cholder = schandler.addServlet("net.zyclonite.pushrouter.StreamServlet", "/stream/*");
cholder.setInitParameter("listenerthreads", String.valueOf(listenerthreads));
cholder.setAsyncSupported(true);
final RequestLogHandler requestLogHandler = new RequestLogHandler();
if (config.getBoolean("server.accesslogs", false)) {
final NCSARequestLog requestLog = new NCSARequestLog(config.getString("server.logdir", "./") + "web-yyyy_mm_dd.request.log");
requestLog.setRetainDays(90);
requestLog.setAppend(true);
requestLog.setExtended(false);
requestLog.setLogTimeZone("GMT");
requestLogHandler.setRequestLog(requestLog);
}
final HandlerCollection handlers = new HandlerCollection();
handlers.setHandlers(new Handler[]{schandler, new DefaultHandler(), requestLogHandler});
server.setHandler(handlers);
try {
server.start();
LOG.info("PushRouter started");
} catch (Exception ex) {
LOG.error("PushRouter could not be started");
}
}