use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class XRedisPartialTest method testContinueWhenKeeperRefusedConnectionWhenAnsweringPsyncCommand.
@Test
public void testContinueWhenKeeperRefusedConnectionWhenAnsweringPsyncCommand() throws Exception {
RedisMeta slaveMeta = getRedisSlaves().get(0);
String xRedisVersion = getXRedisVersion(slaveMeta);
if (!VersionUtils.ge(xRedisVersion, versionCheckContinueMin)) {
logger.info("do not check xredis version below than {}", versionCheckContinueMin);
return;
}
RedisKeeperServer redisKeeperServer = getRedisKeeperServer(activeKeeper);
int backlogActiveCount = getBackLogActiveCount(slaveMeta);
Assert.assertEquals(1, backlogActiveCount);
Jedis slaveJedis = createJedis(slaveMeta);
String slaveof = slaveJedis.slaveof("127.0.0.1", randomPort());
sleep(1100);
slaveJedis.slaveof("127.0.0.1", activeKeeper.getPort());
sleep(1100);
backlogActiveCount = getBackLogActiveCount(slaveMeta);
logger.info("[getBackLogActiveCount]{}", backlogActiveCount);
Assert.assertEquals(1, backlogActiveCount);
// be sure slave can accpet partial sync
Jedis master = createJedis(redisMaster);
master.slaveof("127.0.0.1", 0);
int syncFull1 = Integer.parseInt(getInfoKey(slaveMeta, "stats", "sync_full"));
int syncPartialOk1 = Integer.parseInt(getInfoKey(slaveMeta, "stats", "sync_partial_ok"));
logger.info("{}, {}", syncFull1, syncPartialOk1);
slaveJedis.slaveofNoOne();
master.slaveof(slaveMeta.getIp(), slaveMeta.getPort());
sleep(1200);
int syncFull2 = Integer.parseInt(getInfoKey(slaveMeta, "stats", "sync_full"));
int syncPartialOk2 = Integer.parseInt(getInfoKey(slaveMeta, "stats", "sync_partial_ok"));
logger.info("{}, {}", syncFull2, syncPartialOk2);
Assert.assertEquals(syncFull1, syncFull2);
Assert.assertEquals(syncPartialOk1 + 1, syncPartialOk2);
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class KeeperSingleDcVersionTest method test2_8_19Tocurrent.
@Test
public void test2_8_19Tocurrent() throws Exception {
RedisMeta newMaster = new RedisMeta().setIp(addr_2_8_19.getHostString()).setPort(addr_2_8_19.getPort());
setKeeperState(activeKeeper, KeeperState.ACTIVE, addr_2_8_19.getHostString(), addr_2_8_19.getPort());
sleep(2000);
sendMesssageToMasterAndTest(100, newMaster, slaves);
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class KeeperSingleDcVersionTest method testcurrentTo2_8_19.
@Test
public void testcurrentTo2_8_19() throws IOException {
makeRedisSlaveof(addr_2_8_19, activeKeeper.getIp(), activeKeeper.getPort());
sleep(2000);
slaves.add(new RedisMeta().setIp(addr_2_8_19.getHostString()).setPort(addr_2_8_19.getPort()));
sendMesssageToMasterAndTest(100, redisMaster, slaves);
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class OneDcKeepers method killActive.
@Test
public void killActive() throws Exception {
RedisMeta redisMaster = getRedisMaster();
sendMessageToMasterAndTestSlaveRedis();
System.out.println("press any key to make back keeper active");
waitForAnyKey();
KeeperMeta backupKeeper = getKeepersBackup().get(0);
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());
waitForAnyKeyToExit();
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class RedisSlaveReplAllTest method testSlaveOf.
@Test
public void testSlaveOf() throws Exception {
int slaveWriteIndex = 1;
makeSlaveReplAll(redises.get(slaveWriteIndex), true);
sendMesssageToMasterAndTest(messageCount, redises.get(slaveWriteIndex), redises.subList(slaveWriteIndex + 1, redises.size()));
logger.info("[make slave master]{}", redises.get(slaveWriteIndex));
createJedis(redises.get(slaveWriteIndex)).slaveofNoOne();
List<RedisMeta> newRedises = redises.subList(slaveWriteIndex, redises.size());
Assert.assertEquals(newRedises.size() - 1, getSyncFullCount(newRedises));
RedisMeta previous = null;
for (int i = newRedises.size() - 1; i >= 0; i--) {
RedisMeta redis = newRedises.get(i);
if (previous == null) {
createJedis(redis).slaveofNoOne();
} else {
createJedis(redis).slaveof(previous.getIp(), previous.getPort());
}
previous = redis;
}
Assert.assertEquals(newRedises.size() - 1, getSyncFullCount(newRedises));
}
Aggregations