dev@grizzly.java.net

Re: TCP Connections and Threading

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Tue, 22 Jul 2008 10:18:59 +0200

Hello Mark,

it's easy:

controller.getPipeline().setMaxThreads(25);


WBR,
Alexey.

On Jul 22, 2008, at 5:50 , Mark Macumber wrote:

> Hi Everyone,
>
> I was working on a very basic HTTP server using Grizzly 1.8.0 to
> stress test it to see if it could handle a certain load required for
> our project, and I got it working pretty well.
>
> It was easy to configure the amount of worker threads for processing
> etc...
>
> It was like this: (basically)
>
> SelectorThread st = new SelectorThread();
> st.setPort(port);
> st.setAdapter(new SampleAdapter());
> st.setProperty("maxThreads", 25);
>
> st.listen();
>
> Easy...
>
> Now I wanted to mimic this type of thing with TCP, to handle many
> TCP requests and process their results. I have something like the
> following:
>
> Controller controller = new Controller();
>
> TCPSelectorHandler tcpSelectorHandler = new TCPSelectorHandler();
> tcpSelectorHandler.setPort(port);
> controller.addSelectorHandler(tcpSelectorHandler);
>
> new Thread(new Runnable() {
> public void run() {
> try {
> _log.info("GBSTP TCP Server Started");
> controller.start();
> } catch (IOException e) {
> e.printStackTrace();
> }
> }
> }).start();
>
> Based on examples I saw.
>
> How exactly can I configure the amount of "worker" threads that will
> process the TCP connections? (like in the HTTP example above)
>
> I am open to many ideas here!
>
> Cheers,
> Mark