use of org.eclipse.jetty.server.nio.SelectChannelConnector in project storm by apache.
the class UIHelpers method jettyCreateServer.
/**
* Construct a Jetty Server instance.
*/
public static Server jettyCreateServer(Integer port, String host, Integer httpsPort) {
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(Utils.getInt(port, 80));
connector.setHost(host);
connector.setMaxIdleTime(200000);
Server server = new Server();
server.addConnector(connector);
server.setSendDateHeader(true);
if (httpsPort != null && httpsPort > 0) {
removeNonSslConnector(server);
}
return server;
}
use of org.eclipse.jetty.server.nio.SelectChannelConnector in project hive by apache.
the class HttpServer method createChannelConnector.
/**
* Create a channel connector for "http/https" requests
*/
Connector createChannelConnector(int queueSize, Builder b) {
SelectChannelConnector connector;
if (!b.useSSL) {
connector = new SelectChannelConnector();
} else {
SslContextFactory sslContextFactory = new SslContextFactory();
sslContextFactory.setKeyStorePath(b.keyStorePath);
Set<String> excludedSSLProtocols = Sets.newHashSet(Splitter.on(",").trimResults().omitEmptyStrings().split(Strings.nullToEmpty(b.conf.getVar(ConfVars.HIVE_SSL_PROTOCOL_BLACKLIST))));
sslContextFactory.addExcludeProtocols(excludedSSLProtocols.toArray(new String[excludedSSLProtocols.size()]));
sslContextFactory.setKeyStorePassword(b.keyStorePassword);
connector = new SslSelectChannelConnector(sslContextFactory);
}
connector.setLowResourcesMaxIdleTime(10000);
connector.setAcceptQueueSize(queueSize);
connector.setResolveNames(false);
connector.setUseDirectBuffers(false);
connector.setRequestHeaderSize(1024 * 64);
connector.setReuseAddress(true);
return connector;
}
use of org.eclipse.jetty.server.nio.SelectChannelConnector in project lucida by claritylab.
the class OpenEphyraServer method main.
/**
* 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();
}
use of org.eclipse.jetty.server.nio.SelectChannelConnector in project hazelcast by hazelcast.
the class JettyServer method buildJetty.
private void buildJetty(int port, String sourceDir, String webXmlFile) throws Exception {
server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
server.addConnector(connector);
WebAppContext context = new WebAppContext();
context.setResourceBase(sourceDir);
context.setDescriptor(sourceDir + "/WEB-INF/" + webXmlFile);
context.setLogUrlOnStart(true);
context.setContextPath("/");
context.setParentLoaderPriority(true);
server.setHandler(context);
server.start();
}
use of org.eclipse.jetty.server.nio.SelectChannelConnector in project jfinal by jfinal.
the class JettyServer method doStart.
private void doStart() {
if (!available(port)) {
throw new IllegalStateException("port: " + port + " already in use!");
}
deleteSessionData();
System.out.println("Starting JFinal " + Const.JFINAL_VERSION);
server = new Server();
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(port);
server.addConnector(connector);
webApp = new WebAppContext();
// 在启动过程中允许抛出异常终止启动并退出 JVM
webApp.setThrowUnavailableOnStartupException(true);
webApp.setContextPath(context);
// webApp.setWar(webAppDir);
webApp.setResourceBase(webAppDir);
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.dirAllowed", "false");
// webApp.setInitParams(Collections.singletonMap("org.mortbay.jetty.servlet.Default.useFileMappedBuffer", "false"));
webApp.setInitParameter("org.eclipse.jetty.servlet.Default.useFileMappedBuffer", "false");
persistSession(webApp);
server.setHandler(webApp);
changeClassLoader(webApp);
// configureScanner
if (scanIntervalSeconds > 0) {
Scanner scanner = new Scanner(PathKit.getRootClassPath(), scanIntervalSeconds) {
public void onChange() {
try {
System.err.println("\nLoading changes ......");
webApp.stop();
JFinalClassLoader loader = new JFinalClassLoader(webApp, getClassPath());
webApp.setClassLoader(loader);
webApp.start();
System.err.println("Loading complete.");
} catch (Exception e) {
System.err.println("Error reconfiguring/restarting webapp after change in watched files");
LogKit.error(e.getMessage(), e);
}
}
};
System.out.println("Starting scanner at interval of " + scanIntervalSeconds + " seconds.");
scanner.start();
}
try {
System.out.println("Starting web server on port: " + port);
server.start();
System.out.println("Starting Complete. Welcome To The JFinal World :)");
server.join();
} catch (Exception e) {
LogKit.error(e.getMessage(), e);
System.exit(100);
}
return;
}
Aggregations