Web Server forum
Back To The Forum Home!Search!Private Messaging System

This is Interesting: Free IT Magazines Now Free shipping to   
Web Server Talk Web Server Talk > Free Databases support forum > Free MySQL support > MySQL Java > Connector/J with MySQL Cluster




  Last Thread   Next Thread Next
  Show Printable Version Email this Page Subscribe to this Thread      Post New Thread    Post A Reply      

    Connector/J with mysql Cluster  
Karl


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-25-05 10:45 PM

------=_NextPart_000_0019_01C51B45.CCF3CBB0
Content-Type: text/plain;
charset="us-ascii"
Content-Transfer-Encoding: 7bit

Hi - I'm using mysql Cluster, and trying to get connector/J (tried
v3.1.6 and 3.1.7) to round-robin the database requests.  I'm currently
testing with 2 databases, so I'd like to have request one go to db1, the
next to db2, back to db1, etc.

I've got failOverReadOnly set to false, autoReconnect true, and
roundRobinLoadBalance true.

Currently what happens is all request go to the first database node in
the connection url.  If that node is taken offline, the next request
fails, after which all requests go to the 2nd database node.

If I bring the first database node back online, all requests still go to
the 2nd node.  Which brings me to another question - is there a way to
configure the driver to periodically check an 'offline' node to see if
it has come back online?


I'm using JBoss, the datasource definition file is below:

<?xml version="1.0" encoding="UTF-8"?>
<datasources>
<local-tx-datasource>
<jndi-name>MySQLDS</jndi-name>
<connection-url>jdbc:mysql://192.168.0.7:3306,192.168.0.8:3306/testdb</c
onnection-url>
<driver-class>com.mysql.jdbc.Driver</driver-class>

<connection-property name="failOverReadOnly">false</connection-property>
<connection-property name="autoReconnect">true</connection-property>
<connection-property
name="roundRobinLoadBalance">true</connection-property>

<user-name>testuser</user-name>
<password>testpw</password>

<!-- corresponding type-mapping in the standardjbosscmp-jdbc.xml
(optional) -->
<metadata>
<type-mapping>mySQL</type-mapping>
</metadata>
</local-tx-datasource>
</datasources>

Best Regards,
Karl

------=_NextPart_000_0019_01C51B45.CCF3CBB0--






[ Post a follow-up to this message ]



    Re: Connector/J with mysql Cluster  
Mark Matthews


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-25-05 10:45 PM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Karl wrote:
> Hi - I'm using mysql Cluster, and trying to get connector/J (tried
> v3.1.6 and 3.1.7) to round-robin the database requests.  I'm currently
> testing with 2 databases, so I'd like to have request one go to db1, the
> next to db2, back to db1, etc.
>
> I've got failOverReadOnly set to false, autoReconnect true, and
> roundRobinLoadBalance true.

Karl,

The load balancing happens at connection creation..The connection is
'pinned' to the node it connected to unless that node goes offline. JDBC
isn't really setup as an API to handle load balancing each query for a
given connection across a cluster due to it's stateful nature.

> Currently what happens is all request go to the first database node in
> the connection url.  If that node is taken offline, the next request
> fails, after which all requests go to the 2nd database node.
>
> If I bring the first database node back online, all requests still go to
> the 2nd node.  Which brings me to another question - is there a way to
> configure the driver to periodically check an 'offline' node to see if
> it has come back online?

It should fall back to the first node it was connected to after either
'queriesBeforeRetryMaster' (default 50) or 'secondsBeforeRetryMaster'
(default 30) expires.

However, I'd tell you that if you'd be better off (and future proofing
yourself), to throw dead connections away and reconnect, as we're going
to deprecate autoReconnect in Connector/J 3.2, and it's going away
probably in 3.3...There's really no reliable and fully transparent way
to make it work with a client/server database.

If you leave autoReconnect=true for now to cover the case where the
'next' node in the round-robin is down, so the driver connects to the
next node, and instead of trying to recover the current connection after
a communications exception is thrown (SQLState that start with '08'),
instead close it, you'll be using the 'new' model we'll be promoting
with Connector/J 3.2 and later.

-Mark

- --
Mark Matthews
MySQL AB, Software Development Manager - Connectivity
www.mysql.com

MySQL User Conference (Santa Clara CA, 18-21 April 2005)
Early registration until February 28: http://www.mysqluc.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

 iD8DBQFCH6fntvXNTca6JD8RAkNaAJ0YyvZvolwa
6PozjhWz3ckLLF62uQCguYw0
VBPPSMnoxZv54Y13vKaUwE0=
=tLxo
-----END PGP SIGNATURE-----

--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/java?unsub=m....
edu.tw






[ Post a follow-up to this message ]



    RE: Connector/J with mysql Cluster  
Karl


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-26-05 01:45 AM

Mark - thank you for the information!

> Karl wrote: 
currently[vbcol=seagreen] 
[vbcol=seagreen] 
[vbcol=seagreen]
> Karl,

>The load balancing happens at connection creation..The connection is
'pinned' to the node it connected to unless that  > node goes offline.
JDBC isn't really setup as an API to handle load balancing each query
for a given connection
> across a cluster due to it's stateful nature.

Does this mean that connections in a connection pool will be distributed
across the different databases that are in the connection url?

Best Regards,
Karl


--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/java?unsub=m....
edu.tw






[ Post a follow-up to this message ]



    Re: Connector/J with mysql Cluster  
Mark Matthews


View Ip Address Report This Message To A Moderator Edit/Delete Message


 
02-26-05 01:45 AM

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Karl wrote:
[snip] 
>
> 
>
> 'pinned' to the node it connected to unless that  > node goes offline.
> JDBC isn't really setup as an API to handle load balancing each query
> for a given connection
> 
>
>
> Does this mean that connections in a connection pool will be distributed
> across the different databases that are in the connection url?
>
> Best Regards,
> Karl
>
>

Karl,

Yup, you're correct. I'd have a longer answer for you, but it's
a Friday evening where I'm at ;)

-Mark

- --
Mark Matthews
MySQL AB, Software Development Manager - Connectivity
www.mysql.com

MySQL User Conference (Santa Clara CA, 18-21 April 2005)
Early registration until February 28: http://www.mysqluc.com/
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (GNU/Linux)
Comment: Using GnuPG with Thunderbird - http://enigmail.mozdev.org

iD8DBQFCH74EtvXNTca6JD8RAgqlAJ4rt/CC7ycgjJi+pdcufwfNXguQlQCcDU85
GHEv4+ZCQ+VwHYPnLZuomq8=
=CmBO
-----END PGP SIGNATURE-----

--
MySQL Java Mailing List
For list archives: http://lists.mysql.com/java
To unsubscribe:    http://lists.mysql.com/java?unsub=m....
edu.tw






[ Post a follow-up to this message ]



    Sponsored Links  




 





   All times are GMT. The time now is 12:59 AM.      Post New Thread    Post A Reply      
  Last Thread   Next Thread Next


Most Popular forums 

Forum Jump:
Rate This Thread:

Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is OFF
vB code is ON
Smilies are ON
[IMG] code is OFF
 

Back To The Top
Home | Usercp | Faq | Register