use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperSingleDc method testMakeActiveBackup.
@Test
public void testMakeActiveBackup() throws Exception {
logger.info(remarkableMessage("make keeper active{}"), backupKeeper);
setKeeperState(backupKeeper, KeeperState.ACTIVE, redisMaster.getIp(), redisMaster.getPort());
RedisKeeperServer redisKeeperServer = getRedisKeeperServer(activeKeeper);
Assert.assertEquals(PARTIAL_STATE.FULL, redisKeeperServer.getRedisMaster().partialState());
logger.info(remarkableMessage("[testMakeActiveBackup]{}"), activeKeeper);
setKeeperState(activeKeeper, KeeperState.BACKUP, backupKeeper.getIp(), backupKeeper.getPort());
sleep(2000);
Assert.assertEquals(PARTIAL_STATE.PARTIAL, redisKeeperServer.getRedisMaster().partialState());
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperSingleDc method testMakeBackupActive.
@Test
public void testMakeBackupActive() throws Exception {
RedisKeeperServer redisKeeperServer = getRedisKeeperServer(backupKeeper);
Assert.assertEquals(PARTIAL_STATE.FULL, redisKeeperServer.getRedisMaster().partialState());
logger.info(remarkableMessage("make keeper active{}"), backupKeeper);
setKeeperState(backupKeeper, KeeperState.ACTIVE, redisMaster.getIp(), redisMaster.getPort());
sleep(2000);
Assert.assertEquals(PARTIAL_STATE.PARTIAL, redisKeeperServer.getRedisMaster().partialState());
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperSingleDcRestart method testActiveRestart.
@Test
public void testActiveRestart() throws Exception {
RedisKeeperServer redisKeeperServer = getRedisKeeperServer(activeKeeper);
remove(redisKeeperServer);
// make backup active
logger.info(remarkableMessage("[make backup active]{}"), backupKeeper);
RedisKeeperServer rawBackupServer = getRedisKeeperServer(backupKeeper);
Assert.assertEquals(KeeperState.BACKUP, rawBackupServer.getRedisKeeperServerState().keeperState());
setKeeperState(backupKeeper, KeeperState.ACTIVE, redisMaster.getIp(), redisMaster.getPort());
sleep(2000);
Assert.assertEquals(KeeperState.ACTIVE, rawBackupServer.getRedisKeeperServerState().keeperState());
Assert.assertEquals(PARTIAL_STATE.PARTIAL, rawBackupServer.getRedisMaster().partialState());
// start active again
startKeeper(activeKeeper);
RedisKeeperServer newRedisKeeperServer = getRedisKeeperServer(activeKeeper);
Assert.assertNotEquals(newRedisKeeperServer, redisKeeperServer);
Assert.assertEquals(KeeperState.PRE_ACTIVE, newRedisKeeperServer.getRedisKeeperServerState().keeperState());
// make new keeper backup
logger.info(remarkableMessage("[make old active backup]{}"), activeKeeper);
setKeeperState(activeKeeper, KeeperState.BACKUP, backupKeeper.getIp(), backupKeeper.getPort());
sleep(2000);
Assert.assertEquals(KeeperState.BACKUP, newRedisKeeperServer.getRedisKeeperServerState().keeperState());
Assert.assertEquals(PARTIAL_STATE.PARTIAL, newRedisKeeperServer.getRedisMaster().partialState());
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperSingleDcRestart method testBackupRestart.
@Test
public void testBackupRestart() throws Exception {
RedisKeeperServer redisKeeperServer = getRedisKeeperServer(backupKeeper);
remove(redisKeeperServer);
startKeeper(backupKeeper);
RedisKeeperServer newRedisKeeperServer = getRedisKeeperServer(backupKeeper);
Assert.assertNotEquals(newRedisKeeperServer, redisKeeperServer);
Assert.assertEquals(KeeperState.PRE_BACKUP, newRedisKeeperServer.getRedisKeeperServerState().keeperState());
setKeeperState(backupKeeper, KeeperState.BACKUP, activeKeeper.getIp(), activeKeeper.getPort());
sleep(2000);
Assert.assertEquals(KeeperState.BACKUP, newRedisKeeperServer.getRedisKeeperServerState().keeperState());
Assert.assertEquals(PARTIAL_STATE.PARTIAL, newRedisKeeperServer.getRedisMaster().partialState());
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperPsync2Continue method testExchangeMasterSlave.
@Test
public void testExchangeMasterSlave() throws Exception {
RedisKeeperServer redisKeeperServer = getRedisKeeperServer(activeKeeper);
int slaveChosen = 0;
long fullSyncCount = redisKeeperServer.getKeeperMonitor().getKeeperStats().getFullSyncCount();
for (int i = 0; i < testRound; i++) {
logger.info(remarkableMessage("round:{}"), i);
RedisMeta slaveToPromote = slaves.get(0);
xslaveof(activeKeeper.getIp(), activeKeeper.getPort(), redisMaster);
xslaveof(null, 0, slaveToPromote);
setKeeperState(activeKeeper, KeeperState.ACTIVE, slaveToPromote.getIp(), slaveToPromote.getPort());
sleep(3000);
Assert.assertEquals(fullSyncCount, redisKeeperServer.getKeeperMonitor().getKeeperStats().getFullSyncCount());
RedisMeta tmpRedisMaster = redisMaster;
redisMaster = slaveToPromote;
slaves.remove(slaveChosen);
slaves.add(0, tmpRedisMaster);
}
}
Aggregations