|
@@ -1,11 +1,16 @@
|
|
|
package org.glassfish.grizzly.bm;
|
|
|
|
|
|
-import org.glassfish.grizzly.Grizzly;
|
|
|
+import org.glassfish.grizzly.filterchain.FilterChainBuilder;
|
|
|
+import org.glassfish.grizzly.http.server.AddOn;
|
|
|
+import org.glassfish.grizzly.http.server.FileCacheFilter;
|
|
|
import org.glassfish.grizzly.http.server.HttpServer;
|
|
|
import org.glassfish.grizzly.http.server.NetworkListener;
|
|
|
import org.glassfish.grizzly.http.server.RequestExecutorProvider;
|
|
|
+import org.glassfish.grizzly.http.server.util.HttpPipelineOptAddOn;
|
|
|
import org.glassfish.grizzly.http.util.HeaderValue;
|
|
|
+import org.glassfish.grizzly.memory.PooledMemoryManager;
|
|
|
import org.glassfish.grizzly.nio.transport.TCPNIOTransport;
|
|
|
+import org.glassfish.grizzly.utils.IdleTimeoutFilter;
|
|
|
|
|
|
/**
|
|
|
* HttpServer
|
|
@@ -32,10 +37,21 @@ public class Server {
|
|
|
transport.setWorkerThreadPoolConfig(null);
|
|
|
transport.setSelectorRunnersCount(Runtime.getRuntime().availableProcessors() * 2);
|
|
|
|
|
|
+ // set PooledMemoryManager
|
|
|
+ transport.setMemoryManager(new PooledMemoryManager());
|
|
|
+
|
|
|
// always keep-alive
|
|
|
networkListener.getKeepAlive().setIdleTimeoutInSeconds(-1);
|
|
|
networkListener.getKeepAlive().setMaxRequestsCount(-1);
|
|
|
|
|
|
+ // disable transaction timeout
|
|
|
+ networkListener.setTransactionTimeout(-1);
|
|
|
+
|
|
|
+ // remove the features we don't need
|
|
|
+ networkListener.registerAddOn(new SimplifyAddOn());
|
|
|
+ // add HTTP pipeline optimization
|
|
|
+ networkListener.registerAddOn(new HttpPipelineOptAddOn());
|
|
|
+
|
|
|
// disable file-cache
|
|
|
networkListener.getFileCache().setEnabled(false);
|
|
|
|
|
@@ -59,4 +75,21 @@ public class Server {
|
|
|
httpServer.shutdown();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private static class SimplifyAddOn implements AddOn {
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void setup(final NetworkListener networkListener,
|
|
|
+ final FilterChainBuilder builder) {
|
|
|
+ final int fcIdx = builder.indexOfType(FileCacheFilter.class);
|
|
|
+ if (fcIdx != -1) {
|
|
|
+ builder.remove(fcIdx);
|
|
|
+ }
|
|
|
+
|
|
|
+ final int itIdx = builder.indexOfType(IdleTimeoutFilter.class);
|
|
|
+ if (itIdx != -1) {
|
|
|
+ builder.remove(itIdx);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|