make jedis unit tests pass to Redis 2.8.1

* increase sentinel instance to test JedisSentinelTest
** clear() called, slave promoted to master (slave of no one), New
Sentinel force to restore it (demote) -> slave is not reusable
* ipv6 applied at Redis 2.8 -> localhost / 127.0.0.1 / ::1 is now all same

* Makefile: sleep some time for launch each sentinel (workaround to sentinel's issue)
** issue to sentinel leader vote: https://github.com/antirez/redis/issues/1419
*** sentinel may confused to vote with sentinels launched approximately same time
This commit is contained in:
Jungtaek Lim
2013-12-02 22:11:52 +09:00
parent e10cdda5c7
commit 15891c4117
5 changed files with 58 additions and 78 deletions

View File

@@ -1,6 +1,8 @@
package redis.clients.jedis;
public class HostAndPort {
public static final String LOCALHOST_STR = "localhost";
private String host;
private int port;
@@ -22,11 +24,11 @@ public class HostAndPort {
if (obj instanceof HostAndPort) {
HostAndPort hp = (HostAndPort) obj;
// localhost and 127.0.0.1 is same
return port == hp.port &&
(host.equals(hp.host) ||
(host.equals("localhost") && hp.host.equals("127.0.0.1")) ||
(host.equals("127.0.0.1") && hp.host.equals("localhost")) );
String thisHost = convertHost(host);
String hpHost = convertHost(hp.host);
return port == hp.port &&
thisHost.equals(hpHost);
}
return false;
@@ -36,4 +38,13 @@ public class HostAndPort {
public String toString() {
return host + ":" + port;
}
private String convertHost(String host) {
if (host.equals("127.0.0.1"))
return LOCALHOST_STR;
else if (host.equals("::1"))
return LOCALHOST_STR;
return host;
}
}