JedisSentinelPool now takes care of multi failover

* Now Pool.initPool() call closeInternalPool(), instead of destroy()
** calling destroy() in Pool.initPool() may have side effect, and JedisSentinelPool did
* modify unit test to test failover twice (needs +1 slave)
** modify configurations for additional slave
This commit is contained in:
Jungtaek Lim
2013-09-26 10:48:17 +09:00
parent 08e9b0c7e7
commit 35a2dfd4c0
5 changed files with 97 additions and 45 deletions

View File

@@ -39,6 +39,17 @@ save ""
appendonly no
endef
define REDIS5_CONF
daemonize yes
port 6383
requirepass foobared
masterauth foobared
pidfile /tmp/redis5.pid
logfile /tmp/redis5.log
save ""
appendonly no
endef
define REDIS_SENTINEL1
port 26379
daemonize yes
@@ -82,6 +93,7 @@ export REDIS1_CONF
export REDIS2_CONF
export REDIS3_CONF
export REDIS4_CONF
export REDIS5_CONF
export REDIS_SENTINEL1
export REDIS_SENTINEL2
export REDIS_SENTINEL3
@@ -91,16 +103,18 @@ start:
echo "$$REDIS2_CONF" | redis-server -
echo "$$REDIS3_CONF" | redis-server -
echo "$$REDIS4_CONF" | redis-server -
echo "$$REDIS_SENTINEL1" | redis-sentinel -
echo "$$REDIS_SENTINEL2" | redis-sentinel -
echo "$$REDIS_SENTINEL3" | redis-sentinel -
echo "$$REDIS5_CONF" | redis-server -
echo "$$REDIS_SENTINEL1" | redis-server - --sentinel
echo "$$REDIS_SENTINEL2" | redis-server - --sentinel
echo "$$REDIS_SENTINEL3" | redis-server - --sentinel
stop:
kill `cat /tmp/redis1.pid`
kill `cat /tmp/redis2.pid`
# this get's segfaulted by the tests
kill `cat /tmp/redis3.pid` || true
kill `cat /tmp/redis4.pid`
kill `cat /tmp/redis4.pid` || true
kill `cat /tmp/redis5.pid` || true
kill `cat /tmp/sentinel1.pid`
kill `cat /tmp/sentinel2.pid`
kill `cat /tmp/sentinel3.pid`
@@ -110,9 +124,10 @@ test:
echo "$$REDIS2_CONF" | redis-server -
echo "$$REDIS3_CONF" | redis-server -
echo "$$REDIS4_CONF" | redis-server -
echo "$$REDIS_SENTINEL1" | redis-sentinel -
echo "$$REDIS_SENTINEL2" | redis-sentinel -
echo "$$REDIS_SENTINEL3" | redis-sentinel -
echo "$$REDIS5_CONF" | redis-server -
echo "$$REDIS_SENTINEL1" | redis-server - --sentinel
echo "$$REDIS_SENTINEL2" | redis-server - --sentinel
echo "$$REDIS_SENTINEL3" | redis-server - --sentinel
mvn clean compile test
@@ -120,7 +135,8 @@ test:
kill `cat /tmp/redis2.pid`
# this get's segfaulted by the tests
kill `cat /tmp/redis3.pid` || true
kill `cat /tmp/redis4.pid`
kill `cat /tmp/redis4.pid` || true
kill `cat /tmp/redis5.pid` || true
kill `cat /tmp/sentinel1.pid`
kill `cat /tmp/sentinel2.pid`
kill `cat /tmp/sentinel3.pid`
@@ -130,9 +146,10 @@ deploy:
echo "$$REDIS2_CONF" | redis-server -
echo "$$REDIS3_CONF" | redis-server -
echo "$$REDIS4_CONF" | redis-server -
echo "$$REDIS_SENTINEL1" | redis-sentinel -
echo "$$REDIS_SENTINEL2" | redis-sentinel -
echo "$$REDIS_SENTINEL3" | redis-sentinel -
echo "$$REDIS5_CONF" | redis-server -
echo "$$REDIS_SENTINEL1" | redis-server - --sentinel
echo "$$REDIS_SENTINEL2" | redis-server - --sentinel
echo "$$REDIS_SENTINEL3" | redis-server - --sentinel
mvn clean deploy
@@ -140,7 +157,8 @@ deploy:
kill `cat /tmp/redis2.pid`
# this get's segfaulted by the tests
kill `cat /tmp/redis3.pid` || true
kill `cat /tmp/redis4.pid`
kill `cat /tmp/redis4.pid` || true
kill `cat /tmp/redis5.pid` || true
kill `cat /tmp/sentinel1.pid`
kill `cat /tmp/sentinel2.pid`
kill `cat /tmp/sentinel3.pid`
@@ -150,9 +168,10 @@ release:
echo "$$REDIS2_CONF" | redis-server -
echo "$$REDIS3_CONF" | redis-server -
echo "$$REDIS4_CONF" | redis-server -
echo "$$REDIS_SENTINEL1" | redis-sentinel -
echo "$$REDIS_SENTINEL2" | redis-sentinel -
echo "$$REDIS_SENTINEL3" | redis-sentinel -
echo "$$REDIS5_CONF" | redis-server -
echo "$$REDIS_SENTINEL1" | redis-server - --sentinel
echo "$$REDIS_SENTINEL2" | redis-server - --sentinel
echo "$$REDIS_SENTINEL3" | redis-server - --sentinel
mvn release:clean
mvn release:prepare
@@ -162,7 +181,8 @@ release:
kill `cat /tmp/redis2.pid`
# this get's segfaulted by the tests
kill `cat /tmp/redis3.pid` || true
kill `cat /tmp/redis4.pid`
kill `cat /tmp/redis4.pid` || true
kill `cat /tmp/redis5.pid` || true
kill `cat /tmp/sentinel1.pid`
kill `cat /tmp/sentinel2.pid`
kill `cat /tmp/sentinel3.pid`