Testing Clustered H2 Nodes

29 views
Skip to first unread message

Max Bridgewater

unread,
Nov 19, 2009, 10:52:08 AM11/19/09
to h2-da...@googlegroups.com
Hi,

I had some troubles testing a H2 cluster. Let's say I have two nodes running on localhost ports 8000 and 8001. I can connect to the cluster as a whole using the URL: tcp://localhost:8000,localhost:8001/test.

What I couldn't figure out is a simple way to verify that each node in the cluster properly executed an update query initiated from any of them. That is, if I send an insert statement from localhost:8000, how do I check from a test case that localhost:8001 also received and executed this insert statement?

Here are my attempts:

1) Tried to connect to each node separately using the URLs tcp://localhost:8000 and tcp://localhost:8001. This doesn't work; the error message is that the node is part of a cluster and I cannot connect to it in isolation.

2) Tried to switch the node's addresses in the cluster URL; That is, using the following URLs to query each database: tcp://localhost:8000,localhost:8001/test  and tcp://localhost:8001,localhost:8000/test. The rational in this case is that since read queries are performed on the first node of the URL, tcp://localhost:8001,localhost:8000/test would in essence be equivalent to tcp://localhost:8001/test and tcp://localhost:8000,localhost:8001/test would be equivalent to tcp://localhost:8000/test. Unfortunately, it didn't work either. I'm not allowed to connect to the cluster with one URL when I already connected to it with the other one.

Now my question:
1) Is there something I am missing?
1) Is there any solution/workaround to this problem?
2) Why not allow connecting to a cluster member in isolation?

Thanks,
Merkel

Merkel

unread,
Nov 19, 2009, 1:53:21 PM11/19/09
to H2 Database
Solution found; Append ";CLUSTER=''" to individual database URLs to be
able to connect to it in isolation instead of connecting to the
cluster.

On Nov 19, 10:52 am, Max Bridgewater <max.bridgewa...@gmail.com>
wrote:

Thomas Mueller

unread,
Nov 21, 2009, 5:46:11 AM11/21/09
to h2-da...@googlegroups.com
Hi,

> verify that each node in the cluster properly executed an update query initiated from any of them

The JDBC driver connects to all cluster instances and update statement
are sent to both cluster instances from the JDBC driver. The two
cluster instances don't actually have a direct connection (no cluster
interconnect). Currently there is no way to check if the update was
sent to both or only one of them.

> Solution found; Append ";CLUSTER=''" to individual database URLs to be
> able to connect to it in isolation instead of connecting to the
> cluster.

This will disable the cluster mode.

This is slightly related to your problem: I have added a feature that
lets you detect if one cluster node is stopped or not:

http://www.h2database.com/html/advanced.html#clustering "Detect Which
Cluster Instances are Running"

Regards,
Thomas
Reply all
Reply to author
Forward
0 new messages