提交 961b5963 authored 作者: noelgrandin@gmail.com's avatar noelgrandin@gmail.com

It is now possible to control the port that the server uses by passing in an…

It is now possible to control the port that the server uses by passing in an AUTO_SERVER_PORT parameter.
上级 34b8dc02
...@@ -1189,6 +1189,10 @@ DriverManager.getConnection("jdbc:h2:/data/test;AUTO_SERVER=TRUE"); ...@@ -1189,6 +1189,10 @@ DriverManager.getConnection("jdbc:h2:/data/test;AUTO_SERVER=TRUE");
// Application 2: // Application 2:
DriverManager.getConnection("jdbc:h2:/data/test;AUTO_SERVER=TRUE"); DriverManager.getConnection("jdbc:h2:/data/test;AUTO_SERVER=TRUE");
</pre> </pre>
<p>
When using this feature, by default the server allocates a random TCP socket.
It is possible to control the port that the server uses by passing in an <code>AUTO_SERVER_PORT=9090</code> parameter.
</p>
<h2 id="page_size">Page Size</h2> <h2 id="page_size">Page Size</h2>
<p> <p>
......
...@@ -4565,6 +4565,10 @@ public class Parser { ...@@ -4565,6 +4565,10 @@ public class Parser {
readIfEqualOrTo(); readIfEqualOrTo();
read(); read();
return new NoOperation(session); return new NoOperation(session);
} else if (readIf("AUTO_SERVER_PORT")) {
readIfEqualOrTo();
read();
return new NoOperation(session);
} else if (readIf("AUTO_RECONNECT")) { } else if (readIf("AUTO_RECONNECT")) {
readIfEqualOrTo(); readIfEqualOrTo();
read(); read();
......
...@@ -98,8 +98,8 @@ public class ConnectionInfo implements Cloneable { ...@@ -98,8 +98,8 @@ public class ConnectionInfo implements Cloneable {
String[] connectionTime = { "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER", String[] connectionTime = { "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER",
"CREATE", "CACHE_TYPE", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS", "CREATE", "CACHE_TYPE", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS",
"IFEXISTS", "INIT", "PASSWORD", "RECOVER", "RECOVER_TEST", "IFEXISTS", "INIT", "PASSWORD", "RECOVER", "RECOVER_TEST",
"USER", "AUTO_SERVER", "NO_UPGRADE", "AUTO_RECONNECT", "USER", "AUTO_SERVER", "AUTO_SERVER_PORT", "NO_UPGRADE",
"OPEN_NEW", "PAGE_SIZE", "PASSWORD_HASH", "JMX" }; "AUTO_RECONNECT", "OPEN_NEW", "PAGE_SIZE", "PASSWORD_HASH", "JMX" };
for (String key : connectionTime) { for (String key : connectionTime) {
if (SysProperties.CHECK && set.contains(key)) { if (SysProperties.CHECK && set.contains(key)) {
DbException.throwInternalError(key); DbException.throwInternalError(key);
......
...@@ -152,6 +152,7 @@ public class Database implements DataHandler { ...@@ -152,6 +152,7 @@ public class Database implements DataHandler {
private int maxOperationMemory = Constants.DEFAULT_MAX_OPERATION_MEMORY; private int maxOperationMemory = Constants.DEFAULT_MAX_OPERATION_MEMORY;
private SmallLRUCache<String, String[]> lobFileListCache; private SmallLRUCache<String, String[]> lobFileListCache;
private boolean autoServerMode; private boolean autoServerMode;
private int autoServerPort;
private Server server; private Server server;
private HashMap<TableLinkConnection, TableLinkConnection> linkConnections; private HashMap<TableLinkConnection, TableLinkConnection> linkConnections;
private TempFileDeleter tempFileDeleter = TempFileDeleter.getInstance(); private TempFileDeleter tempFileDeleter = TempFileDeleter.getInstance();
...@@ -189,6 +190,7 @@ public class Database implements DataHandler { ...@@ -189,6 +190,7 @@ public class Database implements DataHandler {
String lockMethodName = ci.getProperty("FILE_LOCK", null); String lockMethodName = ci.getProperty("FILE_LOCK", null);
this.accessModeData = StringUtils.toLowerEnglish(ci.getProperty("ACCESS_MODE_DATA", "rw")); this.accessModeData = StringUtils.toLowerEnglish(ci.getProperty("ACCESS_MODE_DATA", "rw"));
this.autoServerMode = ci.getProperty("AUTO_SERVER", false); this.autoServerMode = ci.getProperty("AUTO_SERVER", false);
this.autoServerPort = ci.getProperty("AUTO_SERVER_PORT", 0);
this.cacheSize = ci.getProperty("CACHE_SIZE", Constants.CACHE_SIZE_DEFAULT); this.cacheSize = ci.getProperty("CACHE_SIZE", Constants.CACHE_SIZE_DEFAULT);
this.pageSize = ci.getProperty("PAGE_SIZE", Constants.DEFAULT_PAGE_SIZE); this.pageSize = ci.getProperty("PAGE_SIZE", Constants.DEFAULT_PAGE_SIZE);
if ("r".equals(accessModeData)) { if ("r".equals(accessModeData)) {
...@@ -662,7 +664,7 @@ public class Database implements DataHandler { ...@@ -662,7 +664,7 @@ public class Database implements DataHandler {
private void startServer(String key) { private void startServer(String key) {
try { try {
server = Server.createTcpServer( server = Server.createTcpServer(
"-tcpPort", "0", "-tcpPort", Integer.toString(autoServerPort),
"-tcpAllowOthers", "-tcpAllowOthers",
"-tcpDaemon", "-tcpDaemon",
"-key", key, databaseName); "-key", key, databaseName);
......
...@@ -35,6 +35,7 @@ public class TestAutoServer extends TestBase { ...@@ -35,6 +35,7 @@ public class TestAutoServer extends TestBase {
public void test() throws Exception { public void test() throws Exception {
testUnsupportedCombinations(); testUnsupportedCombinations();
testAutoServer(false); testAutoServer(false);
testAutoServer(true);
if (!config.big) { if (!config.big) {
int todo; int todo;
// testAutoServer(true); // testAutoServer(true);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论