Replace tabs with spaces
This commit is contained in:
@@ -12,93 +12,93 @@ public class HostAndPortUtil {
|
||||
private static List<HostAndPort> clusterHostAndPortList = new ArrayList<HostAndPort>();
|
||||
|
||||
static {
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 1));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 2));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 3));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 4));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 5));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 6));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 1));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 2));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 3));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 4));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 5));
|
||||
redisHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_PORT + 6));
|
||||
|
||||
sentinelHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_SENTINEL_PORT));
|
||||
sentinelHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_SENTINEL_PORT + 1));
|
||||
sentinelHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_SENTINEL_PORT + 2));
|
||||
sentinelHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_SENTINEL_PORT + 3));
|
||||
sentinelHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_SENTINEL_PORT));
|
||||
sentinelHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_SENTINEL_PORT + 1));
|
||||
sentinelHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_SENTINEL_PORT + 2));
|
||||
sentinelHostAndPortList.add(new HostAndPort("localhost",
|
||||
Protocol.DEFAULT_SENTINEL_PORT + 3));
|
||||
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7379));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7380));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7381));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7382));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7383));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7384));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7379));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7380));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7381));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7382));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7383));
|
||||
clusterHostAndPortList.add(new HostAndPort("localhost", 7384));
|
||||
|
||||
String envRedisHosts = System.getProperty("redis-hosts");
|
||||
String envSentinelHosts = System.getProperty("sentinel-hosts");
|
||||
String envClusterHosts = System.getProperty("cluster-hosts");
|
||||
String envRedisHosts = System.getProperty("redis-hosts");
|
||||
String envSentinelHosts = System.getProperty("sentinel-hosts");
|
||||
String envClusterHosts = System.getProperty("cluster-hosts");
|
||||
|
||||
redisHostAndPortList = parseHosts(envRedisHosts, redisHostAndPortList);
|
||||
sentinelHostAndPortList = parseHosts(envSentinelHosts,
|
||||
sentinelHostAndPortList);
|
||||
clusterHostAndPortList = parseHosts(envClusterHosts,
|
||||
clusterHostAndPortList);
|
||||
redisHostAndPortList = parseHosts(envRedisHosts, redisHostAndPortList);
|
||||
sentinelHostAndPortList = parseHosts(envSentinelHosts,
|
||||
sentinelHostAndPortList);
|
||||
clusterHostAndPortList = parseHosts(envClusterHosts,
|
||||
clusterHostAndPortList);
|
||||
}
|
||||
|
||||
public static List<HostAndPort> parseHosts(String envHosts,
|
||||
List<HostAndPort> existingHostsAndPorts) {
|
||||
List<HostAndPort> existingHostsAndPorts) {
|
||||
|
||||
if (null != envHosts && 0 < envHosts.length()) {
|
||||
if (null != envHosts && 0 < envHosts.length()) {
|
||||
|
||||
String[] hostDefs = envHosts.split(",");
|
||||
String[] hostDefs = envHosts.split(",");
|
||||
|
||||
if (null != hostDefs && 2 <= hostDefs.length) {
|
||||
if (null != hostDefs && 2 <= hostDefs.length) {
|
||||
|
||||
List<HostAndPort> envHostsAndPorts = new ArrayList<HostAndPort>(
|
||||
hostDefs.length);
|
||||
List<HostAndPort> envHostsAndPorts = new ArrayList<HostAndPort>(
|
||||
hostDefs.length);
|
||||
|
||||
for (String hostDef : hostDefs) {
|
||||
for (String hostDef : hostDefs) {
|
||||
|
||||
String[] hostAndPort = hostDef.split(":");
|
||||
String[] hostAndPort = hostDef.split(":");
|
||||
|
||||
if (null != hostAndPort && 2 == hostAndPort.length) {
|
||||
String host = hostAndPort[0];
|
||||
int port = Protocol.DEFAULT_PORT;
|
||||
if (null != hostAndPort && 2 == hostAndPort.length) {
|
||||
String host = hostAndPort[0];
|
||||
int port = Protocol.DEFAULT_PORT;
|
||||
|
||||
try {
|
||||
port = Integer.parseInt(hostAndPort[1]);
|
||||
} catch (final NumberFormatException nfe) {
|
||||
}
|
||||
try {
|
||||
port = Integer.parseInt(hostAndPort[1]);
|
||||
} catch (final NumberFormatException nfe) {
|
||||
}
|
||||
|
||||
envHostsAndPorts.add(new HostAndPort(host, port));
|
||||
}
|
||||
}
|
||||
envHostsAndPorts.add(new HostAndPort(host, port));
|
||||
}
|
||||
}
|
||||
|
||||
return envHostsAndPorts;
|
||||
}
|
||||
}
|
||||
return envHostsAndPorts;
|
||||
}
|
||||
}
|
||||
|
||||
return existingHostsAndPorts;
|
||||
return existingHostsAndPorts;
|
||||
}
|
||||
|
||||
public static List<HostAndPort> getRedisServers() {
|
||||
return redisHostAndPortList;
|
||||
return redisHostAndPortList;
|
||||
}
|
||||
|
||||
public static List<HostAndPort> getSentinelServers() {
|
||||
return sentinelHostAndPortList;
|
||||
return sentinelHostAndPortList;
|
||||
}
|
||||
|
||||
public static List<HostAndPort> getClusterServers() {
|
||||
return clusterHostAndPortList;
|
||||
return clusterHostAndPortList;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user