提交 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");
// Application 2:
DriverManager.getConnection("jdbc:h2:/data/test;AUTO_SERVER=TRUE");
</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>
<p>
......
......@@ -4565,6 +4565,10 @@ public class Parser {
readIfEqualOrTo();
read();
return new NoOperation(session);
} else if (readIf("AUTO_SERVER_PORT")) {
readIfEqualOrTo();
read();
return new NoOperation(session);
} else if (readIf("AUTO_RECONNECT")) {
readIfEqualOrTo();
read();
......
......@@ -98,8 +98,8 @@ public class ConnectionInfo implements Cloneable {
String[] connectionTime = { "ACCESS_MODE_DATA", "AUTOCOMMIT", "CIPHER",
"CREATE", "CACHE_TYPE", "FILE_LOCK", "IGNORE_UNKNOWN_SETTINGS",
"IFEXISTS", "INIT", "PASSWORD", "RECOVER", "RECOVER_TEST",
"USER", "AUTO_SERVER", "NO_UPGRADE", "AUTO_RECONNECT",
"OPEN_NEW", "PAGE_SIZE", "PASSWORD_HASH", "JMX" };
"USER", "AUTO_SERVER", "AUTO_SERVER_PORT", "NO_UPGRADE",
"AUTO_RECONNECT", "OPEN_NEW", "PAGE_SIZE", "PASSWORD_HASH", "JMX" };
for (String key : connectionTime) {
if (SysProperties.CHECK && set.contains(key)) {
DbException.throwInternalError(key);
......
......@@ -152,6 +152,7 @@ public class Database implements DataHandler {
private int maxOperationMemory = Constants.DEFAULT_MAX_OPERATION_MEMORY;
private SmallLRUCache<String, String[]> lobFileListCache;
private boolean autoServerMode;
private int autoServerPort;
private Server server;
private HashMap<TableLinkConnection, TableLinkConnection> linkConnections;
private TempFileDeleter tempFileDeleter = TempFileDeleter.getInstance();
......@@ -189,6 +190,7 @@ public class Database implements DataHandler {
String lockMethodName = ci.getProperty("FILE_LOCK", null);
this.accessModeData = StringUtils.toLowerEnglish(ci.getProperty("ACCESS_MODE_DATA", "rw"));
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.pageSize = ci.getProperty("PAGE_SIZE", Constants.DEFAULT_PAGE_SIZE);
if ("r".equals(accessModeData)) {
......@@ -662,7 +664,7 @@ public class Database implements DataHandler {
private void startServer(String key) {
try {
server = Server.createTcpServer(
"-tcpPort", "0",
"-tcpPort", Integer.toString(autoServerPort),
"-tcpAllowOthers",
"-tcpDaemon",
"-key", key, databaseName);
......
......@@ -35,6 +35,7 @@ public class TestAutoServer extends TestBase {
public void test() throws Exception {
testUnsupportedCombinations();
testAutoServer(false);
testAutoServer(true);
if (!config.big) {
int todo;
// testAutoServer(true);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论