Re: about monitoring the input stream

From: Mark Lewis <mark(dot)lewis(at)mir3(dot)com>
To: Albert Cardona <acardona(at)ini(dot)phys(dot)ethz(dot)ch>
Cc: pgsql-jdbc(at)postgresql(dot)org
Subject: Re: about monitoring the input stream
Date: 2006-09-13 16:45:59
Message-ID: 1158165959.9657.1259.camel@archimedes
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-jdbc

If you're trying to add diagnostic data collection to all sockets you
could provide a custom SocketFactory implementation which returned
wrappers around Sockets that return CountingInputStream objects instead
of regular InputStream objects to the getInputStream() method.

I don't think that the PG JDBC driver allows you to specify a custom
socketFactory, but you could always set the default system socket
factory. If you do other network operations in the same JVM, your
factory could be smart enough to ignore sockets that don't connect to
your PG server/port.

-- Mark Lewis

On Wed, 2006-09-13 at 18:09 +0200, Albert Cardona wrote:
> Marc,
>
> > 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.
>
>
> The idea is not to modify the driver one bit in benefit of uncontroversial
> deployment of my application (TrakEM2 at
> http://www.ini.unizh.ch/~acardona/trackem2.html ). If java was lisp I would
> simply alter the register to replace the InputStream, but it isn't and/or I
> don't know how to use reflection to that extent (I don't know what would
> happen was I to replace the InputStream using reflection once a connection
> has been created).
>
> Therefore I ask for suggestions on how to monitor the downloading rate ...
> If there aren't any, well, tough luck! I'll have to live with it.
>
> Albert
>
>
>
>
> ---------------------------(end of broadcast)---------------------------
> TIP 5: don't forget to increase your free space map settings

In response to

Browse pgsql-jdbc by date

  From Date Subject
Next Message Enrique Rodríguez Lasterra 2006-09-13 17:02:25 PreparedStatement and CreateTable
Previous Message Albert Cardona 2006-09-13 16:09:54 Re: about monitoring the input stream