|
|
@ -5,6 +5,7 @@ import java.io.File;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.IOException;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.io.InputStreamReader;
|
|
|
|
import java.net.Inet4Address;
|
|
|
|
import java.net.Inet4Address;
|
|
|
|
|
|
|
|
import java.net.ServerSocket;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.net.URL;
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
import java.nio.file.Paths;
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.ArrayList;
|
|
|
@ -31,6 +32,7 @@ public class RedisRunner {
|
|
|
|
DAEMONIZE,
|
|
|
|
DAEMONIZE,
|
|
|
|
PIDFILE,
|
|
|
|
PIDFILE,
|
|
|
|
PORT,
|
|
|
|
PORT,
|
|
|
|
|
|
|
|
RANDOM_PORT,
|
|
|
|
TCP_BACKLOG,
|
|
|
|
TCP_BACKLOG,
|
|
|
|
BIND(true),
|
|
|
|
BIND(true),
|
|
|
|
UNIXSOCKET,
|
|
|
|
UNIXSOCKET,
|
|
|
@ -179,6 +181,7 @@ public class RedisRunner {
|
|
|
|
private boolean randomDir = false;
|
|
|
|
private boolean randomDir = false;
|
|
|
|
private ArrayList<String> bindAddr = new ArrayList<>();
|
|
|
|
private ArrayList<String> bindAddr = new ArrayList<>();
|
|
|
|
private int port = 6379;
|
|
|
|
private int port = 6379;
|
|
|
|
|
|
|
|
private boolean randomPort = true;
|
|
|
|
|
|
|
|
|
|
|
|
{
|
|
|
|
{
|
|
|
|
this.options.put(REDIS_OPTIONS.BINARY_PATH, RedissonRuntimeEnvironment.redisBinaryPath);
|
|
|
|
this.options.put(REDIS_OPTIONS.BINARY_PATH, RedissonRuntimeEnvironment.redisBinaryPath);
|
|
|
@ -266,10 +269,17 @@ public class RedisRunner {
|
|
|
|
|
|
|
|
|
|
|
|
public RedisRunner port(int port) {
|
|
|
|
public RedisRunner port(int port) {
|
|
|
|
this.port = port;
|
|
|
|
this.port = port;
|
|
|
|
|
|
|
|
this.randomPort = false;
|
|
|
|
addConfigOption(REDIS_OPTIONS.PORT, port);
|
|
|
|
addConfigOption(REDIS_OPTIONS.PORT, port);
|
|
|
|
return this;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public RedisRunner randomPort() {
|
|
|
|
|
|
|
|
this.randomPort = true;
|
|
|
|
|
|
|
|
options.remove(REDIS_OPTIONS.PORT);
|
|
|
|
|
|
|
|
return this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getPort() {
|
|
|
|
public int getPort() {
|
|
|
|
return this.port;
|
|
|
|
return this.port;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -785,4 +795,28 @@ public class RedisRunner {
|
|
|
|
public static RedisRunner.RedisProcess getDefaultRedisServerInstance() {
|
|
|
|
public static RedisRunner.RedisProcess getDefaultRedisServerInstance() {
|
|
|
|
return defaultRedisInstance;
|
|
|
|
return defaultRedisInstance;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private static int findFreePort() {
|
|
|
|
|
|
|
|
ServerSocket socket = null;
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
socket = new ServerSocket(0);
|
|
|
|
|
|
|
|
socket.setReuseAddress(true);
|
|
|
|
|
|
|
|
int port = socket.getLocalPort();
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
socket.close();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
// Ignore IOException on close()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return port;
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
} finally {
|
|
|
|
|
|
|
|
if (socket != null) {
|
|
|
|
|
|
|
|
try {
|
|
|
|
|
|
|
|
socket.close();
|
|
|
|
|
|
|
|
} catch (IOException e) {
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
throw new IllegalStateException("Could not find a free TCP/IP port to start embedded Jetty HTTP Server on");
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|