users@jersey.java.net

[Jersey] Re: It's very hard to increase the number of worker threads in Jersey-Grizzly module.

From: George Cao <matrix3456_at_gmail.com>
Date: Fri, 1 Jun 2012 11:00:28 +0800

These solutions work, but need developers learn by themselves. And usually
there are many conceptions new to the developers, this make the situation
worse.

To figure out the solution, beside googling, one need to understand these
and how they work. And this is poorly documented.

I saw some Builders, Factories class , but they are hidden in depth, not
exposed to developers. I just feel not good and worried about if i can
solve problems in the future as soon as possible.

2012/5/31 Oleksiy Stashok <oleksiy.stashok_at_oracle.com>

> Oh, if server has been started - then we have to reconfigure the active
> worker thread pool.
>
> ---------------------------------------------------
> // create HTTP server
> HttpServer server = GrizzlyServerFactory.createHttpServer(....);
>
> // create the thread pool configuration
> ThreadPoolConfig config = ThreadPoolConfig.newConfig().
> setPoolName("mypool").
> setCorePoolSize(10).
> setMaxPoolSize(300);
>
> // reconfigure the thread pool
> NetworkListener listener = httpServer.getListeners().iterator().next();
> GrizzlyExecutorService threadPool = (GrizzlyExecutorService)
> listener.getTransport().getWorkerThreadPool();
> threadPool.reconfigure(config);
>
>
> WBR,
> Alexey.
>
>
> On 05/31/2012 11:18 AM, mbuesch_at_gmail.com wrote:
>
> That doesn't work, after the Server is started:
>
> I checked with this example:
>
> int testPort = AvailablePortFinder.getNextAvailable(1024);
> HttpServer server =
> GrizzlyServerFactory.createHttpServer("http://localhost:" <http://localhost:> + testPort,
> new DefaultResourceConfig(Resource.class));
>
> // create the thread pool configuration
> ThreadPoolConfig config = createThreadConfig(poolName);
>
> // assign the thread pool
> NetworkListener listener =
> server.getListeners().iterator().next();
> log.info("NetworListener Name " + listener.getName());
> final TCPNIOTransport tcpnioTransport =
> listener.getTransport();
> tcpnioTransport.setWorkerThreadPoolConfig(config);
> final ThreadPoolConfig real =
> tcpnioTransport.getWorkerThreadPoolConfig();
> if (config.getCorePoolSize() != real.getCorePoolSize())log.info("CorePoolSize is not set. Should be :" +
> config.getCorePoolSize() + " but is :" + real.getCorePoolSize());
> if (config.getMaxPoolSize() != real.getMaxPoolSize())log.info("MaxPoolSize is not set. Should be :" +
> config.getMaxPoolSize() + " but is :" + real.getMaxPoolSize());
>
>
>