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();
}
}