dev@grizzly.java.net

Re: get statistics

From: Jeanfrancois Arcand <Jeanfrancois.Arcand_at_Sun.COM>
Date: Fri, 09 Jan 2009 15:08:08 -0500

Salut,

which version are you using? I suspect this is a regression because of
the ExecutorServices changes. Let me take a look ASAP.

A+

-- jeanfrancois

rama wrote:
> i have some difficult while trying to get stats
> from a grizzlywebserver.
>
> Here is a snippet of the code.
>
> This code throw a nullpointer on the
> stats.getThreadPoolStatistics().getCountQueued());
> and return 0 for all the other req.
>
> btw, i have copy this piece of code somewhere on grizzly blog, but i
> can't remember where :)
>
>
> ----snippet--
>
> public static void main(String args[]) {
> GrizzlyWebServer ws = new GrizzlyWebServer(8080,
> 40,"/Users/ramarama/html");
>
> ScheduledThreadPoolExecutor ste =
> new ScheduledThreadPoolExecutor(1);
>
> final Statistics stats = ws.getStatistics();
> stats.startGatheringStatistics();
>
> ste.scheduleAtFixedRate(new Runnable() {
> public void run() {
> try {
> System.out.println("Current connected users: " +
>
> stats.getKeepAliveStatistics().getCountConnections());
> System.out.println("How many requests since
> startup:" +
>
> stats.getRequestStatistics().getRequestCount());
> System.out.println("How many connection we queued
> because of all " +
> "thread were busy: " +
>
> stats.getThreadPoolStatistics().getCountQueued());
> } catch (Exception e) {
> System.out.println(e);
> }
> return;
> }
> }, 0, 1,TimeUnit.SECONDS);
> System.out.println("Grizzly WebServer listening on port 8080");
> try {
> ws.start();
> } catch (IOException e) {
> // TODO Auto-generated catch block
> e.printStackTrace();
> }
>
> }
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: dev-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: dev-help_at_grizzly.dev.java.net
>