Salut,
Zoltan Arnold NAGY wrote:
> Hi all,
>
> I've started using grizzly in my project, and for that I have written an
> adapter
> to print out statistics.
>
> public class StatisticsAdapter extends GrizzlyAdapter {
> final Statistics statistics;
>
> public StatisticsAdapter(GrizzlyWebServer webserver) {
> statistics = webserver.getStatistics();
> statistics.startGatheringStatistics();
> }
>
> @Override
> public void service(GrizzlyRequest request, GrizzlyResponse response) {
> try {
> PrintWriter out = response.getWriter();
> out.println("number of requests since startup: " +
> statistics.getRequestStatistics().getRequestCount());
> out.println("total number of bytes received: " +
> statistics.getRequestStatistics().getBytesReceived());
> out.println("total number of bytes sent: " +
> statistics.getRequestStatistics().getBytesSent());
> out.println("--");
> } catch(IOException e) {
> e.printStackTrace();
> }
> }
> }
>
> then I add it as such:
>
> GrizzlyWebServer ws = new GrizzlyWebServer(PORT);
> ws.addGrizzlyAdapter(new StatisticsAdapter(ws), new String[] {
> "/stat" });
>
> however, it behaves strangely. lets say I download a file of size
> 15962823 from the webserver, then grab /stat with curl:
> "number of requests since startup: 1
> total number of bytes received: 0
> total number of bytes sent: 15958016"
>
> then if I do this 5 more times, then the fifth will look like (so it
> should be the sixth request totally from the server's point of view)
> number of requests since startup: 9
> total number of bytes received: 0
> total number of bytes sent: 31916032
>
> no file was downloaded from the server in the meantime, nor there were
> any requests. both number of requests and
> total number of bytes sent behaves in a totally confusing manner. and
> this is the exact same behaviour for every startup.
>
> what am I doing wrong? :-)
which version are you using? I was under the impression the stat issue
has been fixed with the latest 1.9.14, but I might be wrong. Can you
file an issue here:
https://grizzly.dev.java.net/issues/
Thanks!
-- Jeanfrancois
>
> Thanks!
>
> Zoltan
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe_at_grizzly.dev.java.net
> For additional commands, e-mail: users-help_at_grizzly.dev.java.net
>