use of org.glassfish.grizzly.http.CompressionConfig in project graylog2-server by Graylog2.
the class JerseyService method setUp.
private HttpServer setUp(String namePrefix, URI listenUri, SSLEngineConfigurator sslEngineConfigurator, int threadPoolSize, int selectorRunnersCount, int maxInitialLineLength, int maxHeaderSize, boolean enableGzip, boolean enableCors, Set<Resource> additionalResources, String[] controllerPackages) throws GeneralSecurityException, IOException {
final ResourceConfig resourceConfig = buildResourceConfig(enableCors, additionalResources, controllerPackages);
final HttpServer httpServer = GrizzlyHttpServerFactory.createHttpServer(listenUri, resourceConfig, sslEngineConfigurator != null, sslEngineConfigurator, false);
final NetworkListener listener = httpServer.getListener("grizzly");
listener.setMaxHttpHeaderSize(maxInitialLineLength);
listener.setMaxRequestHeaders(maxHeaderSize);
final ExecutorService workerThreadPoolExecutor = instrumentedExecutor(namePrefix + "-worker-executor", namePrefix + "-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