use of org.glassfish.grizzly.http.server.NetworkListener in project narayana by jbosstm.
the class SpdyEnabledHttpServer method createHttpServer.
private static HttpServer createHttpServer(final URI uri, final GrizzlyHttpContainer handler, final boolean secure, final SSLEngineConfigurator sslEngineConfigurator, final int poolSize, final boolean enableSpdy) throws ProcessingException {
final String host = (uri.getHost() == null) ? NetworkListener.DEFAULT_NETWORK_HOST : uri.getHost();
final int port = (uri.getPort() == -1) ? 80 : uri.getPort();
final HttpServer server = new HttpServer();
final NetworkListener listener = new NetworkListener("grizzly", host, port);
listener.setSecure(secure);
if (sslEngineConfigurator != null) {
listener.setSSLEngineConfig(sslEngineConfigurator);
}
if (poolSize > 0) {
TCPNIOTransport transport = listener.getTransport();
transport.getKernelThreadPoolConfig().setMaxPoolSize(poolSize);
}
if (enableSpdy) {
SpdyAddOn spdyAddOn = new SpdyAddOn(SpdyMode.NPN);
System.out.printf("SPDY: max conc. streams: %d%n", spdyAddOn.getMaxConcurrentStreams());
listener.registerAddOn(spdyAddOn);
}
listener.setSecure(secure);
server.addListener(listener);
// Map the path to the processor.
final ServerConfiguration config = server.getServerConfiguration();
if (handler != null) {
config.addHttpHandler(handler, uri.getPath());
}
config.setPassTraceRequest(true);
try {
// Start the server.
server.start();
} catch (IOException ex) {
throw new ProcessingException("IOException thrown when trying to start grizzly server", ex);
}
return server;
}
use of org.glassfish.grizzly.http.server.NetworkListener in project jaeger-client-java by jaegertracing.
the class JerseyServer method main.
public static void main(String[] args) throws Exception {
BasicConfigurator.configure();
String serviceName = serviceNameFromEnv();
JerseyServer server = new JerseyServer("0.0.0.0:8081", serviceName, Arrays.asList(new TraceBehaviorResource(), new EndToEndBehaviorResource(new EndToEndBehavior(getEvn(SAMPLING_HOST_PORT, "jaeger-agent:5778"), "crossdock-" + serviceName, senderFromEnv(getEvn(COLLECTOR_HOST_PORT, "jaeger-collector:14268"), getEvn(AGENT_HOST, "jaeger-agent")))), new HealthResource()));
server.addNetworkListener(new NetworkListener("health", "0.0.0.0", 8080));
Builder tchannelBuilder = new Builder(serviceName);
tchannelBuilder.setServerPort(8082);
new TChannelServer(tchannelBuilder, new TraceBehavior(), server.getTracer()).start();
}
use of org.glassfish.grizzly.http.server.NetworkListener in project dukescript-presenters by dukescript.
the class DynamicHTTP method initServer.
static URI initServer() throws Exception {
server = HttpServer.createSimpleServer(null, new PortRange(8080, 65535));
final WebSocketAddOn addon = new WebSocketAddOn();
for (NetworkListener listener : server.getListeners()) {
listener.registerAddOn(addon);
}
resources = new ArrayList<Resource>();
conf = server.getServerConfiguration();
final DynamicHTTP dh = new DynamicHTTP();
conf.addHttpHandler(dh, "/");
server.start();
return pageURL("http", server, "/test.html");
}
use of org.glassfish.grizzly.http.server.NetworkListener in project dukescript-presenters by dukescript.
the class DynamicHTTP method pageURL.
private static URI pageURL(String proto, HttpServer server, final String page) {
NetworkListener listener = server.getListeners().iterator().next();
int port = listener.getPort();
try {
return new URI(proto + "://localhost:" + port + page);
} catch (URISyntaxException ex) {
throw new IllegalStateException(ex);
}
}
use of org.glassfish.grizzly.http.server.NetworkListener in project graylog2-server by Graylog2.
the class JerseyService method setUp.
private HttpServer setUp(URI listenUri, SSLEngineConfigurator sslEngineConfigurator, int threadPoolSize, int selectorRunnersCount, int maxHeaderSize, boolean enableGzip, boolean enableCors, Set<Resource> additionalResources) {
final ResourceConfig resourceConfig = buildResourceConfig(enableCors, additionalResources);
final HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(listenUri, resourceConfig, sslEngineConfigurator != null, sslEngineConfigurator, false);
final NetworkListener listener = httpServer.getListener("grizzly");
listener.setMaxHttpHeaderSize(maxHeaderSize);
final ExecutorService workerThreadPoolExecutor = instrumentedExecutor("http-worker-executor", "http-worker-%d", threadPoolSize);
listener.getTransport().setWorkerThreadPool(workerThreadPoolExecutor);
// The Grizzly default value is equal to `Runtime.getRuntime().availableProcessors()` which doesn't make
// sense for Graylog because we are not mainly a web server.
// See "Selector runners count" at https://grizzly.java.net/bestpractices.html for details.
listener.getTransport().setSelectorRunnersCount(selectorRunnersCount);
listener.setDefaultErrorPageGenerator(errorPageGenerator);
if (enableGzip) {
final CompressionConfig compressionConfig = listener.getCompressionConfig();
compressionConfig.setCompressionMode(CompressionConfig.CompressionMode.ON);
compressionConfig.setCompressionMinSize(512);
}
return httpServer;
}
Aggregations