dev@grizzly.java.net

Re: thread block #2 (continue)

From: Oleksiy Stashok <Oleksiy.Stashok_at_Sun.COM>
Date: Mon, 30 Nov 2009 15:32:45 +0100

Hi Rama,

ok, pls. remove all output related "ADD" code, but keep:

ExtendedThreadPool threadPool = new StatsThreadPool("MyPool", 3, 5,
-1, 30l, TimeUnit.SECONDS);
gws.getSelectorThread().setThreadPool(threadPool);

Probably the issue is in default thread pool configuration.

Thank you.

WBR,
Alexey.


On Nov 27, 2009, at 11:20 , rama.rama_at_tiscali.it wrote:

> Sorry for the high delay of the response :S
> i have changed the example
> as you suggest
>
> and guess what....
> no more lock :S
>
> please notice that
>
> 1) i haven't update GWS
> 2) i haven't update JVM
> 3) i haven't updated
> WIN :)
>
> basically i just took the old example, and add the 2 lines that
> you suggest to me :S
>
> Here, attached, the EXAMPLE with a comment on the
> line that i have added :)
> If i remove the 4 lines that have "ADD" on
> the comment, this example LOCK with
>
> ab -n 100000 -c 200 http://192.
> 168.2.143:8080/index.html
>
> Also, this is ALWAYS reproducible, at least
> on my machine.
>
> My "poor" guessing is that the threadpool
> (statsthreadpool) act different from the default one (probably is the
> threadpool that use the linkedtransferqueue?)
> and the default one is
> causing this issue...if you need some other test, i'll be glad to
> partecipate, just sorry for the delay, but in this week i have
> to
> release all the code and i am a bit busy :) (btw, i am using 1.9.16
> right now as a 'stable' version, since with my test seems to be the
> most stable, if this is of any intrest :D)
>
> Bye!
>
>
> ------------------------------------------------------------------------------------------------------------------------------------------------------
>
> public class DemoWebServer {
>
> static final AtomicInteger req = new
> AtomicInteger();
> public static void main(String args[]){
>
>
>
> GrizzlyWebServer gws = new GrizzlyWebServer();
> gws.
> addGrizzlyAdapter(new MyGrizzlyAdapter(),new String[]{"/"});
>
> gws.addAsyncFilter(new MyAsyncFilter());
> gws.
> getSelectorThread().setDisplayConfiguration(true);
> //ADD
>
> ExtendedThreadPool threadPool = new StatsThreadPool("MyPool",
> 3, 5, -1, 30l, TimeUnit.SECONDS);
> //ADD
> gws.
> getSelectorThread().setThreadPool(threadPool);
> try {
>
> gws.start();
> } catch (IOException e){
>
>
> }
> while (true) {
> int reqn = req.get();
>
> System.out.println("RE "+reqn+" MU "+(Runtime.
> getRuntime().totalMemory() -Runtime.getRuntime().freeMemory()));
>
> //ADD
> System.out.println("Tasks: " +
> threadPool.getTaskCount());
> //ADD
> System.out.
> println("ActiveCount: " + threadPool.getActiveCount());
>
> try {
> Thread.sleep(2500);
> } catch
> (Exception e) {
>
> }
> }
> }
>
>
> static class
> MyGrizzlyAdapter extends GrizzlyAdapter {
> public void service
> (GrizzlyRequest grizzlyRequest, GrizzlyResponse grizzlyResponse) {
>
> try {
> grizzlyResponse.getWriter().print
> ("Great!");
>
> req.incrementAndGet();
> } catch
> (IOException e) {
>
> }
> }
> }
>
> static class
> MyAsyncFilter implements AsyncFilter {
> private final
> ScheduledThreadPoolExecutor scheduler =
>
> new ScheduledThreadPoolExecutor(1);
>
> public boolean doFilter
> (final AsyncExecutor asyncExecutor) {
> String url =
> asyncExecutor.getProcessorTask().getRequestURI();
> scheduler.
> schedule(new Callable() {
> public Object call()
> throws Exception {
> asyncExecutor.execute();
>
> asyncExecutor.postExecute();
>
> return null;
> }
>
> }, 10, TimeUnit.MILLISECONDS);
> return false;
>
> }
> }
>
> }
>
>
> ---------------------------------------------------------------------------------------------------
>
> Hi Rama,
>
> this looks fine.
> Can you pls. do one more thing.
>
> 1) Setup
> GWS to use custom thread pool:
>
> ExtendedThreadPool threadPool
> = new StatsThreadPool("MyPool",
> 3, 5, -1, 30l, TimeUnit.SECONDS);
>
> gws.getSelectorThread().setThreadPool(threadPool);
>
> 2) And
> then from time to time (as you did for memory usage stats) log
> number
> of queued tasks:
>
> System.out.println("Tasks: " + threadPool.
> getTaskCount()");
>
> you can also add stats on current active threads
> number etc.
>
> It will be interesting to take a look at the output, when
> the server
> gets blocked.
>
> Thank you.
>
> WBR,
> Alexey.
>
>
>
>
>
> Risparmia con Tiscali Unica Light: telefono + Adsl 8 mega a soli
> 9,95 € al mese. Gratis la SIM Tiscali Mobile con 25 euro di traffico
> e Tiscali wiPhone incluso!
>
> L'offerta è valida solo se attivi entro il 03/12/09 http://abbonati.tiscali.it/telefono-adsl/prodotti/tc/unica_light/?WT.mc_id=01fw
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>