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

Fix formatting

上级 5e9911e5
...@@ -395,14 +395,14 @@ It is also possible to get the list of servers by using Connection.getClientInfo ...@@ -395,14 +395,14 @@ It is also possible to get the list of servers by using Connection.getClientInfo
</p> </p>
<p> <p>
The property list returned from <code>getClientInfo()</code> contains a <code>numServers</code> property that returns the The property list returned from <code>getClientInfo()</code> contains a <code>numServers</code> property that returns the
number of servers that are in the connection list. To get the actual servers, <code>getClientInfo()</code> also has number of servers that are in the connection list. To get the actual servers, <code>getClientInfo()</code> also has
properties <code>server0</code>..<code>serverX</code>, where serverX is the number of servers minus 1. properties <code>server0</code>..<code>serverX</code>, where serverX is the number of servers minus 1.
</p> </p>
<p> <p>
Example: To get the 2nd server in the connection list one uses <code>getClientInfo('server1')<code>. <b>Note:</b> The Example: To get the 2nd server in the connection list one uses <code>getClientInfo('server1')</code>.
<code>serverX</code> property only returns IP addresses and ports and not hostnames. <b>Note:</b> The <code>serverX</code> property only returns IP addresses and ports and not hostnames.
</p> </p>
<h3>Clustering Algorithm and Limitations</h3> <h3>Clustering Algorithm and Limitations</h3>
......
...@@ -18,16 +18,16 @@ Change Log ...@@ -18,16 +18,16 @@ Change Log
<h2>Next Version (unreleased)</h2> <h2>Next Version (unreleased)</h2>
<ul><li>MVStore: new utility to compress a store. <ul><li>MVStore: new utility to compress a store.
</li><li>Sequences of temporary tables (auto-increment or identity columns) </li><li>Sequences of temporary tables (auto-increment or identity columns)
were persisted unnecessarily in the database file, and were not removed were persisted unnecessarily in the database file, and were not removed
when re-opening the database. when re-opening the database.
</li><li>MVStore: an IndexOutOfBoundsException could sometimes </li><li>MVStore: an IndexOutOfBoundsException could sometimes
occur MVMap.openVersion when concurrently accessing the store. occur MVMap.openVersion when concurrently accessing the store.
</li><li>The LIRS cache now re-sizes the internal hash map if needed. </li><li>The LIRS cache now re-sizes the internal hash map if needed.
</li><li>Optionally persist session history in the H2 console. (patch from Martin Grajcar) </li><li>Optionally persist session history in the H2 console. (patch from Martin Grajcar)
<ul><li>Add client-info property to get the number of servers currently in the cluster </li><li>Add client-info property to get the number of servers currently in the cluster
and which servers that are available. (patch from Nikolaj Fogh) and which servers that are available. (patch from Nikolaj Fogh)
</li><li>Fix bug in changing encrypted DB password that kept the file handle </li><li>Fix bug in changing encrypted DB password that kept the file handle
open when the wrong password was supplied. (test case from Jens Hohmuth). open when the wrong password was supplied. (test case from Jens Hohmuth).
</li></ul> </li></ul>
......
...@@ -32,7 +32,9 @@ public class Engine implements SessionFactory { ...@@ -32,7 +32,9 @@ public class Engine implements SessionFactory {
SysProperties.DELAY_WRONG_PASSWORD_MIN; SysProperties.DELAY_WRONG_PASSWORD_MIN;
private boolean jmx; private boolean jmx;
private Engine() {} private Engine() {
// use getInstance()
}
public static Engine getInstance() { public static Engine getInstance() {
return INSTANCE; return INSTANCE;
......
...@@ -127,10 +127,11 @@ public class Session extends SessionWithState { ...@@ -127,10 +127,11 @@ public class Session extends SessionWithState {
this.currentSchemaName = Constants.SCHEMA_MAIN; this.currentSchemaName = Constants.SCHEMA_MAIN;
} }
@Override
public ArrayList<String> getClusterServers() { public ArrayList<String> getClusterServers() {
return new ArrayList<String>(); return new ArrayList<String>();
} }
public boolean setCommitOrRollbackDisabled(boolean x) { public boolean setCommitOrRollbackDisabled(boolean x) {
boolean old = commitOrRollbackDisabled; boolean old = commitOrRollbackDisabled;
commitOrRollbackDisabled = x; commitOrRollbackDisabled = x;
......
...@@ -21,10 +21,11 @@ public interface SessionInterface extends Closeable { ...@@ -21,10 +21,11 @@ public interface SessionInterface extends Closeable {
/** /**
* Get the list of the cluster servers for this session. * Get the list of the cluster servers for this session.
* *
* @return A list of "IP:PORT" strings for the cluster servers in this session. * @return A list of "ip:port" strings for the cluster servers in this
* session.
*/ */
ArrayList<String> getClusterServers(); ArrayList<String> getClusterServers();
/** /**
* Parse a command and prepare it for execution. * Parse a command and prepare it for execution.
* *
......
...@@ -95,15 +95,18 @@ public class SessionRemote extends SessionWithState implements DataHandler { ...@@ -95,15 +95,18 @@ public class SessionRemote extends SessionWithState implements DataHandler {
this.connectionInfo = ci; this.connectionInfo = ci;
} }
@Override
public ArrayList<String> getClusterServers() { public ArrayList<String> getClusterServers() {
ArrayList<String> serverList = new ArrayList<String>(); ArrayList<String> serverList = new ArrayList<String>();
for (int i = 0; i < transferList.size(); i++) { for (int i = 0; i < transferList.size(); i++) {
Transfer transfer = transferList.get(i); Transfer transfer = transferList.get(i);
serverList.add(transfer.getSocket().getInetAddress().getHostAddress().toString() + ":" + String.valueOf(transfer.getSocket().getPort())); serverList.add(transfer.getSocket().getInetAddress().
getHostAddress() + ":" +
transfer.getSocket().getPort());
} }
return serverList; return serverList;
} }
private Transfer initTransfer(ConnectionInfo ci, String db, String server) private Transfer initTransfer(ConnectionInfo ci, String db, String server)
throws IOException { throws IOException {
Socket socket = NetUtils.createSocket(server, Socket socket = NetUtils.createSocket(server,
......
...@@ -1724,7 +1724,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1724,7 +1724,7 @@ public class JdbcConnection extends TraceObject implements Connection {
try { try {
if (isDebugEnabled()) { if (isDebugEnabled()) {
debugCode("getClientInfo();"); debugCode("getClientInfo();");
} }
checkClosed(); checkClosed();
ArrayList<String> serverList = session.getClusterServers(); ArrayList<String> serverList = session.getClusterServers();
Properties p = new Properties(); Properties p = new Properties();
...@@ -1752,7 +1752,7 @@ public class JdbcConnection extends TraceObject implements Connection { ...@@ -1752,7 +1752,7 @@ public class JdbcConnection extends TraceObject implements Connection {
debugCodeCall("getClientInfo", name); debugCodeCall("getClientInfo", name);
} }
checkClosed(); checkClosed();
Properties p = getClientInfo(); Properties p = getClientInfo();
return p.getProperty(name); return p.getProperty(name);
} catch (Exception e) { } catch (Exception e) {
throw logAndConvert(e); throw logAndConvert(e);
......
...@@ -1408,7 +1408,8 @@ Returns the name of the default schema for this session." ...@@ -1408,7 +1408,8 @@ Returns the name of the default schema for this session."
"Functions (System)","SCOPE_IDENTITY"," "Functions (System)","SCOPE_IDENTITY","
SCOPE_IDENTITY() SCOPE_IDENTITY()
"," ","
Returns the last inserted identity value for this session for the current scope." Returns the last inserted identity value for this session for the current scope
(ie."
"Functions (System)","SESSION_ID"," "Functions (System)","SESSION_ID","
SESSION_ID() SESSION_ID()
"," ","
......
...@@ -48,8 +48,6 @@ import org.h2.util.Utils; ...@@ -48,8 +48,6 @@ import org.h2.util.Utils;
*/ */
public class WebServer implements Service { public class WebServer implements Service {
private static final String COMMAND_HISTORY = "commandHistory";
static final String TRANSFER = "transfer"; static final String TRANSFER = "transfer";
static final String[][] LANGUAGES = { static final String[][] LANGUAGES = {
...@@ -75,6 +73,8 @@ public class WebServer implements Service { ...@@ -75,6 +73,8 @@ public class WebServer implements Service {
{ "zh_TW", "\u4e2d\u6587 (\u7e41\u9ad4)"}, { "zh_TW", "\u4e2d\u6587 (\u7e41\u9ad4)"},
}; };
private static final String COMMAND_HISTORY = "commandHistory";
private static final String DEFAULT_LANGUAGE = "en"; private static final String DEFAULT_LANGUAGE = "en";
private static final String[] GENERIC = { private static final String[] GENERIC = {
...@@ -539,7 +539,7 @@ public class WebServer implements Service { ...@@ -539,7 +539,7 @@ public class WebServer implements Service {
commandHistoryString = ""; commandHistoryString = "";
} }
} else { } else {
commandHistoryString = null; commandHistoryString = null;
} }
} }
...@@ -549,10 +549,12 @@ public class WebServer implements Service { ...@@ -549,10 +549,12 @@ public class WebServer implements Service {
return result; return result;
} }
// Split the commandHistoryString on non-escaped semicolons and unescape it. // Split the commandHistoryString on non-escaped semicolons
// and unescape it.
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int end = 0; ; end++) { for (int end = 0;; end++) {
if (end == commandHistoryString.length() || commandHistoryString.charAt(end) == ';') { if (end == commandHistoryString.length() ||
commandHistoryString.charAt(end) == ';') {
if (sb.length() > 0) { if (sb.length() > 0) {
result.add(sb.toString()); result.add(sb.toString());
sb.delete(0, sb.length()); sb.delete(0, sb.length());
...@@ -560,16 +562,21 @@ public class WebServer implements Service { ...@@ -560,16 +562,21 @@ public class WebServer implements Service {
if (end == commandHistoryString.length()) { if (end == commandHistoryString.length()) {
break; break;
} }
} else if (commandHistoryString.charAt(end) == '\\' && end < commandHistoryString.length() - 1) { } else if (commandHistoryString.charAt(end) == '\\' &&
end < commandHistoryString.length() - 1) {
sb.append(commandHistoryString.charAt(++end)); sb.append(commandHistoryString.charAt(++end));
} else { } else {
sb.append(commandHistoryString.charAt(end)); sb.append(commandHistoryString.charAt(end));
} }
} }
return result; return result;
} }
/**
* Save the command history to the properties file.
*
* @param commandHistory the history
*/
public void saveCommandHistoryList(ArrayList<String> commandHistory) { public void saveCommandHistoryList(ArrayList<String> commandHistory) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (String s : commandHistory) { for (String s : commandHistory) {
......
...@@ -67,7 +67,8 @@ class WebSession { ...@@ -67,7 +67,8 @@ class WebSession {
WebSession(WebServer server) { WebSession(WebServer server) {
this.server = server; this.server = server;
// This must be stored in the session rather than in the server. // This must be stored in the session rather than in the server.
// Otherwise, one client could allow saving history for others (insecure). // Otherwise, one client could allow
// saving history for others (insecure).
this.commandHistory = server.getCommandHistoryList(); this.commandHistory = server.getCommandHistoryList();
} }
......
...@@ -280,12 +280,11 @@ public class TestCluster extends TestBase { ...@@ -280,12 +280,11 @@ public class TestCluster extends TestBase {
conn = getConnection(urlCluster, user, password); conn = getConnection(urlCluster, user, password);
Properties p = conn.getClientInfo(); Properties p = conn.getClientInfo();
assertEquals("2", p.getProperty("numServers"));
assertEquals("2", p.getProperty("numServers"));
assertEquals("127.0.0.1:" + port1, p.getProperty("server0")); assertEquals("127.0.0.1:" + port1, p.getProperty("server0"));
assertEquals("127.0.0.1:" + port2, p.getProperty("server1")); assertEquals("127.0.0.1:" + port2, p.getProperty("server1"));
assertEquals("2", conn.getClientInfo("numServers")); assertEquals("2", conn.getClientInfo("numServers"));
assertEquals("127.0.0.1:" + port1, conn.getClientInfo("server0")); assertEquals("127.0.0.1:" + port1, conn.getClientInfo("server0"));
assertEquals("127.0.0.1:" + port2, conn.getClientInfo("server1")); assertEquals("127.0.0.1:" + port2, conn.getClientInfo("server1"));
conn.close(); conn.close();
......
...@@ -47,7 +47,7 @@ public class TestTempTables extends TestBase { ...@@ -47,7 +47,7 @@ public class TestTempTables extends TestBase {
c2.close(); c2.close();
deleteDb("tempTables"); deleteDb("tempTables");
} }
private void testTempSequence() throws SQLException { private void testTempSequence() throws SQLException {
deleteDb("tempTables"); deleteDb("tempTables");
Connection conn = getConnection("tempTables"); Connection conn = getConnection("tempTables");
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论