I'm using jetty 9.1.0, embedded, and would like to set both port and ThreadPool. I see a constructor for each, but don't see how to use one of those, and then any way to set the other.
doing this
Server server = new Server(9090);
or
Server server = new Server(new QueuedThreadPool(100, 10));
but there's no setPort or setThreadPool on Server.
In HTTP/1.1, a destination holds a pool of connections (controlled by maxConnectionsPerDestination, by default 64). So if you send requests in a tight loop, assuming connection establishment takes zero time, you can have at most 64 (on the network) + 1024 (queued) outstanding requests. The next one will be rejected.
JETTY_HOME implies the path where jetty is installed and defined as JETTY_HOME on your environment variables. Too see the varible (path of the directory); based on your OS run echo %JETTY_HOME% for Windows; or echo $JETTY_HOME for Unix on your command line / terminal.
Jetty has a single ThreadPool, for all operations. A Thread is a Thread is a Thread. There is no distinction between selector / acceptor / requests / async processing / async read / async write / websocket / proxy / client / etc. At last count, in Jetty 9.4.
QueuedThreadPool threadPool = new QueuedThreadPool();
threadPool.setMaxThreads(500);
Server server = new Server(threadPool);
ServerConnector http = new ServerConnector(server, new HttpConnectionFactory(http_config));
http.setPort(81);
server.addConnector(http);
I can't test it right know, but I assume you can
a) Use a configuration file and load it
or
b) Use the QueuedThreadPool and do the following:
SelectChannelConnector connector = new SelectChannelConnector();
connector.setPort(9090);
server.addConnector(connector);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With