提交 cb41ba40 authored 作者: Thomas Mueller's avatar Thomas Mueller

Clustering: there is now a way to detect which cluster instances are running.

上级 7b21381a
......@@ -325,6 +325,18 @@ database that failed, then restart the server that was stopped,
and re-run the <code>CreateCluster</code> tool.
</li></ul>
<h3>Detect Which Cluster Instances are Running</h3>
<p>
To find out which cluster nodes are currently running, execute the following SQL statement:
</p>
<pre>
SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME='CLUSTER'
</pre>
<p>
If the result is <code>''</code> (two single quotes), then the cluster mode is disabled. Otherwise, the list of
servers is returned, enclosed in single quote. Example: <code>'server1:9191,server2:9191'</code>.
</p>
<h3>Clustering Algorithm and Limitations</h3>
<p>
Read-only queries are only executed against the first cluster node, but all other statements are
......
......@@ -832,6 +832,7 @@ public class MetaTable extends Table {
add(rows, "property." + s, SysProperties.getStringSetting(s, ""));
}
}
add(rows, "CLUSTER", database.getCluster());
add(rows, "EXCLUSIVE", database.getExclusiveSession() == null ? "FALSE" : "TRUE");
add(rows, "MODE", database.getMode().getName());
add(rows, "MULTI_THREADED", database.isMultiThreaded() ? "1" : "0");
......
......@@ -56,7 +56,7 @@ public class TestCluster extends TestBase {
prep.setString(2, "Data" + i);
prep.executeUpdate();
}
check(conn, len);
check(conn, len, "''");
conn.close();
CreateCluster.main("-urlSource", urlNode1, "-urlTarget",
......@@ -81,13 +81,13 @@ public class TestCluster extends TestBase {
// test regular cluster connection
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
check(conn, len);
check(conn, len, "'localhost:9191,localhost:9192'");
conn.close();
// test if only one server is available at the beginning
n2.stop();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191,localhost:9192/test", user, password);
check(conn, len);
check(conn, len, "''");
conn.close();
// disable the cluster
......@@ -115,13 +115,13 @@ public class TestCluster extends TestBase {
n1 = org.h2.tools.Server.createTcpServer("-tcpPort", "9191", "-baseDir", baseDir + "/node1").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9191/test;CLUSTER=''", user, password);
check(conn, len);
check(conn, len, "''");
conn.close();
n1.stop();
n2 = org.h2.tools.Server.createTcpServer("-tcpPort", "9192", "-baseDir", baseDir + "/node2").start();
conn = DriverManager.getConnection("jdbc:h2:tcp://localhost:9192/test;CLUSTER=''", user, password);
check(conn, len);
check(conn, len, "''");
conn.createStatement().execute("SELECT * FROM A");
conn.close();
n2.stop();
......@@ -133,7 +133,7 @@ public class TestCluster extends TestBase {
DeleteDbFiles.main("-dir", baseDir + "/node2", "-quiet");
}
private void check(Connection conn, int len) throws SQLException {
private void check(Connection conn, int len, String expectedCluster) throws SQLException {
PreparedStatement prep = conn.prepareStatement("SELECT * FROM TEST WHERE ID=?");
for (int i = 0; i < len; i++) {
prep.setInt(1, i);
......@@ -142,6 +142,11 @@ public class TestCluster extends TestBase {
assertEquals("Data" + i, rs.getString(2));
assertFalse(rs.next());
}
ResultSet rs = conn.createStatement().executeQuery(
"SELECT VALUE FROM INFORMATION_SCHEMA.SETTINGS WHERE NAME='CLUSTER'");
rs.next();
String cluster = rs.getString(1);
assertEquals(expectedCluster, cluster);
}
}
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论