pg.ddx.io  pgsql-jdbc@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Simple connection failover support
5+ messages / 2 participants
[nested] [flat]

* Simple connection failover support
@ 2012-05-22 13:37 Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
  2012-06-01 22:00 ` Re: Simple connection failover support Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Mikko Tiihonen @ 2012-05-22 13:37 UTC (permalink / raw)
  To: pgsql-jdbc

Hi,

Here are two patches that add simple failover support to the jdbc driver.

Patch 1 converts all references to pair of host+port variables to single InetSocketAddress
Patch 2 rewrites the url parsing to support multiple host:port pairs and modifies the low level connection opening to retry once all listed addresses
I also added more cases to the unit tests to verify that I did not break any functionality.

* The connection url and connection parameters stay backwards compatible
* If there are commas in the hostname part of the url the new code will use them to split the addresses and keep them in the defined priority order
* If there is any IOException or login failure during the connection phase the code will try another listed address
* I tried to keep the code still Java 1.4 compatible

-Mikko

Attachments:

  0001-Change-String-host-int-port-to-InetSocketAddress-add.patch (text/x-patch, 0B) download

^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Simple connection failover support
  2012-05-22 13:37 Simple connection failover support Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
@ 2012-06-01 22:00 ` Dave Cramer <pg@fastcrypt.com>
  2012-06-03 17:10   ` Re: Simple connection failover support Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Dave Cramer @ 2012-06-01 22:00 UTC (permalink / raw)
  To: Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>; +Cc: pgsql-jdbc

Mikko,

I get compile errors

getHostString() is not public in java.net.InetSocketAddress; cannot be
accessed from outside package

compiling with java 6

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Tue, May 22, 2012 at 9:37 AM, Mikko Tiihonen
<mikko.tiihonen@nitorcreations.com> wrote:
> Hi,
>
> Here are two patches that add simple failover support to the jdbc driver.
>
> Patch 1 converts all references to pair of host+port variables to single
> InetSocketAddress
> Patch 2 rewrites the url parsing to support multiple host:port pairs and
> modifies the low level connection opening to retry once all listed addresses
> I also added more cases to the unit tests to verify that I did not break any
> functionality.
>
> * The connection url and connection parameters stay backwards compatible
> * If there are commas in the hostname part of the url the new code will use
> them to split the addresses and keep them in the defined priority order
> * If there is any IOException or login failure during the connection phase
> the code will try another listed address
> * I tried to keep the code still Java 1.4 compatible
>
> -Mikko
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc
>



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Simple connection failover support
  2012-05-22 13:37 Simple connection failover support Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
  2012-06-01 22:00 ` Re: Simple connection failover support Dave Cramer <pg@fastcrypt.com>
@ 2012-06-03 17:10   ` Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
  2012-06-03 17:51     ` Re: Simple connection failover support Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Mikko Tiihonen @ 2012-06-03 17:10 UTC (permalink / raw)
  To: Dave Cramer <pg@fastcrypt.com>; +Cc: pgsql-jdbc

On 06/02/2012 01:00 AM, Dave Cramer wrote:
> Mikko,
>
> I get compile errors
>
> getHostString() is not public in java.net.InetSocketAddress; cannot be
> accessed from outside package
>
> compiling with java 6

Seems I slipped one Java7 method call in. Comparing the implementations it seems
in this case the InetSocketAddress.getHostName() will result in exactly the same
result.

I had selected the getHostString method because it tried to avoid dns lookups.
But the few places where I used it we were either opening the socket or initiating
ssl on already open socket so the lookup is either needed any way or already done
respectively.

Can change the method to getHostName? Or should I send a revised patch?

-Mikko
> >
> On Tue, May 22, 2012 at 9:37 AM, Mikko Tiihonen
> <mikko.tiihonen@nitorcreations.com>  wrote:
>> Hi,
>>
>> Here are two patches that add simple failover support to the jdbc driver.
>>
>> Patch 1 converts all references to pair of host+port variables to single
>> InetSocketAddress
>> Patch 2 rewrites the url parsing to support multiple host:port pairs and
>> modifies the low level connection opening to retry once all listed addresses
>> I also added more cases to the unit tests to verify that I did not break any
>> functionality.
>>
>> * The connection url and connection parameters stay backwards compatible
>> * If there are commas in the hostname part of the url the new code will use
>> them to split the addresses and keep them in the defined priority order
>> * If there is any IOException or login failure during the connection phase
>> the code will try another listed address
>> * I tried to keep the code still Java 1.4 compatible
>>
>> -Mikko



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Simple connection failover support
  2012-05-22 13:37 Simple connection failover support Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
  2012-06-01 22:00 ` Re: Simple connection failover support Dave Cramer <pg@fastcrypt.com>
  2012-06-03 17:10   ` Re: Simple connection failover support Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
@ 2012-06-03 17:51     ` Dave Cramer <pg@fastcrypt.com>
  2012-06-04 13:00       ` Re: Simple connection failover support Dave Cramer <pg@fastcrypt.com>
  0 siblings, 1 reply; 5+ messages in thread

From: Dave Cramer @ 2012-06-03 17:51 UTC (permalink / raw)
  To: Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>; +Cc: pgsql-jdbc

Mikko,

I'll change the method,

Thanks

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Sun, Jun 3, 2012 at 1:10 PM, Mikko Tiihonen
<mikko.tiihonen@nitorcreations.com> wrote:
> On 06/02/2012 01:00 AM, Dave Cramer wrote:
>>
>> Mikko,
>>
>> I get compile errors
>>
>> getHostString() is not public in java.net.InetSocketAddress; cannot be
>> accessed from outside package
>>
>> compiling with java 6
>
>
> Seems I slipped one Java7 method call in. Comparing the implementations it
> seems
> in this case the InetSocketAddress.getHostName() will result in exactly the
> same
> result.
>
> I had selected the getHostString method because it tried to avoid dns
> lookups.
> But the few places where I used it we were either opening the socket or
> initiating
> ssl on already open socket so the lookup is either needed any way or already
> done
> respectively.
>
> Can change the method to getHostName? Or should I send a revised patch?
>
> -Mikko
>
>> >
>> On Tue, May 22, 2012 at 9:37 AM, Mikko Tiihonen
>> <mikko.tiihonen@nitorcreations.com>  wrote:
>>>
>>> Hi,
>>>
>>> Here are two patches that add simple failover support to the jdbc driver.
>>>
>>> Patch 1 converts all references to pair of host+port variables to single
>>> InetSocketAddress
>>> Patch 2 rewrites the url parsing to support multiple host:port pairs and
>>> modifies the low level connection opening to retry once all listed
>>> addresses
>>> I also added more cases to the unit tests to verify that I did not break
>>> any
>>> functionality.
>>>
>>> * The connection url and connection parameters stay backwards compatible
>>> * If there are commas in the hostname part of the url the new code will
>>> use
>>> them to split the addresses and keep them in the defined priority order
>>> * If there is any IOException or login failure during the connection
>>> phase
>>> the code will try another listed address
>>> * I tried to keep the code still Java 1.4 compatible
>>>
>>> -Mikko
>
>
> --
> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 5+ messages in thread

* Re: Simple connection failover support
  2012-05-22 13:37 Simple connection failover support Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
  2012-06-01 22:00 ` Re: Simple connection failover support Dave Cramer <pg@fastcrypt.com>
  2012-06-03 17:10   ` Re: Simple connection failover support Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
  2012-06-03 17:51     ` Re: Simple connection failover support Dave Cramer <pg@fastcrypt.com>
@ 2012-06-04 13:00       ` Dave Cramer <pg@fastcrypt.com>
  0 siblings, 0 replies; 5+ messages in thread

From: Dave Cramer @ 2012-06-04 13:00 UTC (permalink / raw)
  To: Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>; +Cc: pgsql-jdbc

Mikko,

I've committed and pushed this.

Thanks

Dave Cramer

dave.cramer(at)credativ(dot)ca
http://www.credativ.ca


On Sun, Jun 3, 2012 at 1:51 PM, Dave Cramer <pg@fastcrypt.com> wrote:
> Mikko,
>
> I'll change the method,
>
> Thanks
>
> Dave Cramer
>
> dave.cramer(at)credativ(dot)ca
> http://www.credativ.ca
>
>
> On Sun, Jun 3, 2012 at 1:10 PM, Mikko Tiihonen
> <mikko.tiihonen@nitorcreations.com> wrote:
>> On 06/02/2012 01:00 AM, Dave Cramer wrote:
>>>
>>> Mikko,
>>>
>>> I get compile errors
>>>
>>> getHostString() is not public in java.net.InetSocketAddress; cannot be
>>> accessed from outside package
>>>
>>> compiling with java 6
>>
>>
>> Seems I slipped one Java7 method call in. Comparing the implementations it
>> seems
>> in this case the InetSocketAddress.getHostName() will result in exactly the
>> same
>> result.
>>
>> I had selected the getHostString method because it tried to avoid dns
>> lookups.
>> But the few places where I used it we were either opening the socket or
>> initiating
>> ssl on already open socket so the lookup is either needed any way or already
>> done
>> respectively.
>>
>> Can change the method to getHostName? Or should I send a revised patch?
>>
>> -Mikko
>>
>>> >
>>> On Tue, May 22, 2012 at 9:37 AM, Mikko Tiihonen
>>> <mikko.tiihonen@nitorcreations.com>  wrote:
>>>>
>>>> Hi,
>>>>
>>>> Here are two patches that add simple failover support to the jdbc driver.
>>>>
>>>> Patch 1 converts all references to pair of host+port variables to single
>>>> InetSocketAddress
>>>> Patch 2 rewrites the url parsing to support multiple host:port pairs and
>>>> modifies the low level connection opening to retry once all listed
>>>> addresses
>>>> I also added more cases to the unit tests to verify that I did not break
>>>> any
>>>> functionality.
>>>>
>>>> * The connection url and connection parameters stay backwards compatible
>>>> * If there are commas in the hostname part of the url the new code will
>>>> use
>>>> them to split the addresses and keep them in the defined priority order
>>>> * If there is any IOException or login failure during the connection
>>>> phase
>>>> the code will try another listed address
>>>> * I tried to keep the code still Java 1.4 compatible
>>>>
>>>> -Mikko
>>
>>
>> --
>> Sent via pgsql-jdbc mailing list (pgsql-jdbc@postgresql.org)
>> To make changes to your subscription:
>> http://www.postgresql.org/mailpref/pgsql-jdbc



^ permalink  raw  reply  [nested|flat] 5+ messages in thread


end of thread, other threads:[~2012-06-04 13:00 UTC | newest]

Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2012-05-22 13:37 Simple connection failover support Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
2012-06-01 22:00 ` Dave Cramer <pg@fastcrypt.com>
2012-06-03 17:10   ` Mikko Tiihonen <mikko.tiihonen@nitorcreations.com>
2012-06-03 17:51     ` Dave Cramer <pg@fastcrypt.com>
2012-06-04 13:00       ` Dave Cramer <pg@fastcrypt.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox