X-Original-To: pgsql-jdbc-postgresql.org@postgresql.org Received: from localhost (mx1.hub.org [200.46.208.251]) by postgresql.org (Postfix) with ESMTP id C60699FA465 for ; Tue, 12 Sep 2006 11:32:27 -0300 (ADT) Received: from postgresql.org ([200.46.204.71]) by localhost (mx1.hub.org [200.46.208.251]) (amavisd-new, port 10024) with ESMTP id 47795-04 for ; Tue, 12 Sep 2006 11:32:18 -0300 (ADT) X-Greylist: domain auto-whitelisted by SQLgrey- Received: from ciao.gmane.org (main.gmane.org [80.91.229.2]) by postgresql.org (Postfix) with ESMTP id 19CF49FA433 for ; Tue, 12 Sep 2006 11:32:18 -0300 (ADT) Received: from list by ciao.gmane.org with local (Exim 4.43) id 1GN9Ir-0003EQ-F0 for pgsql-jdbc@postgresql.org; Tue, 12 Sep 2006 16:31:57 +0200 Received: from 83.145.96.118 ([83.145.96.118]) by main.gmane.org with esmtp (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 12 Sep 2006 16:31:57 +0200 Received: from Marc.Herbert by 83.145.96.118 with local (Gmexim 0.1 (Debian)) id 1AlnuQ-0007hv-00 for ; Tue, 12 Sep 2006 16:31:57 +0200 X-Injected-Via-Gmane: http://gmane.org/ To: pgsql-jdbc@postgresql.org From: Marc Herbert Subject: Re: about monitoring the input stream Date: Tue, 12 Sep 2006 16:31:40 +0200 Lines: 22 Message-ID: References: <200609111859.51271.acardona@ini.phys.ethz.ch> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@sea.gmane.org X-Gmane-NNTP-Posting-Host: 83.145.96.118 User-Agent: Gnus/5.1007 (Gnus v5.10.7) XEmacs/21.4 (Jumbo Shrimp, linux) Cancel-Lock: sha1:/Cx0ZSOoNJM6LTH/Lfbwy2Jk7es= X-Virus-Scanned: Maia Mailguard 1.0.1 X-Spam-Status: No, hits=1.683 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, RCVD_NUMERIC_HELO, SPF_HELO_PASS, SPF_PASS X-Spam-Level: * X-Archive-Number: 200609/45 X-Sequence-Number: 15763 Albert Cardona writes: > Following up from > http://archives.postgresql.org/pgsql-jdbc/2006-07/msg00052.php > I wonder if anything has been done on the subject of monitoring the amount of > bytes since the last query? > > Finally I've digged into the code and put my hands through reflection on the > InputStream encapsulated in the PGStream. Problem is, the stream is emptied > frequently and I can't find the class responsible for reading it out, so my > readings of the available() bytes (in a monitoring thread) underestimate > tremendously the amount of bytes actually piped. Why don't you decorate the InputStream with some simple CountingInputStream of yours, just like Oliver suggested? Something very similar to: private java.io.DataOutputStream#incCount() If you are lazy you could even extend BufferInputStream; like this you have just two read methods to override.