use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperPsync2 method assertSyncCount.
private void assertSyncCount(List<RedisKeeperServer> redisKeeperServers) {
logger.info("[assertSyncCount]");
int full = 0, partialError = 0;
for (RedisKeeperServer redisKeeperServer : redisKeeperServers) {
full += redisKeeperServer.getKeeperMonitor().getKeeperStats().getFullSyncCount();
partialError += redisKeeperServer.getKeeperMonitor().getKeeperStats().getPartialSyncErrorCount();
}
Assert.assertEquals(0, partialError);
Assert.assertEquals(totalKeepers - 1, full);
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperPsync2 method initKeepers.
private void initKeepers() throws Exception {
redisKeeperServers.add(getRedisKeeperServer(activeKeeper));
redisKeeperServers.add(getRedisKeeperServer(backupKeeper));
setKeeperState(backupKeeper, KeeperState.ACTIVE, activeKeeper.getIp(), activeKeeper.getPort());
KeeperMeta lastKeeper = backupKeeper;
List<KeeperMeta> keeperMetas = new LinkedList<>();
int portStart = Math.max(activeKeeper.getPort(), backupKeeper.getPort());
for (int i = 0; i < totalKeepers - redisKeeperServers.size(); i++) {
KeeperMeta keeperMeta = new KeeperMeta().setIp("localhost").setPort(++portStart);
keeperMeta.setParent(activeKeeper.parent());
keeperMetas.add(keeperMeta);
}
for (KeeperMeta keeperMeta : keeperMetas) {
RedisKeeperServer redisKeeperServer = startKeeper(keeperMeta);
setKeeperState(keeperMeta, KeeperState.ACTIVE, lastKeeper.getIp(), lastKeeper.getPort());
logger.info("[initKeepers][slaveof]{}:{} slaveof {}:{}", keeperMeta.getIp(), keeperMeta.getPort(), lastKeeper.getIp(), lastKeeper.getPort());
redisKeeperServers.add(redisKeeperServer);
lastKeeper = keeperMeta;
}
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperSingleDc method testReFullSync.
@Test
public void testReFullSync() throws ExecuteException, IOException {
RedisKeeperServer redisKeeperServer = getRedisKeeperServerActive(dc);
DefaultReplicationStore replicationStore = (DefaultReplicationStore) redisKeeperServer.getReplicationStore();
DcMeta dcMeta = getDcMeta();
RedisMeta slave1 = createSlave(activeKeeper.getIp(), activeKeeper.getPort());
int lastRdbUpdateCount = replicationStore.getRdbUpdateCount();
logger.info(remarkableMessage("[testReFullSync][sendRandomMessage]"));
sendRandomMessage(redisMaster, 1, replicationStoreCommandFileSize);
for (int i = 0; i < 3; i++) {
logger.info(remarkableMessage("[testReFullSync]{}"), i);
startRedis(slave1);
sleep(3000);
int currentRdbUpdateCount = replicationStore.getRdbUpdateCount();
logger.info("[testReFullSync]{},{}", lastRdbUpdateCount, currentRdbUpdateCount);
Assert.assertEquals(lastRdbUpdateCount + 1, currentRdbUpdateCount);
lastRdbUpdateCount = currentRdbUpdateCount;
sendMesssageToMasterAndTest(100, getRedisMaster(), Lists.newArrayList(slave1));
}
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperSingleDcEof method testEofRestart.
@Test
public void testEofRestart() throws Exception {
sendMessageToMasterAndTestSlaveRedis();
logger.info(remarkableMessage("stop keepers"));
RedisKeeperServer active = getRedisKeeperServer(activeKeeper);
LifecycleHelper.stopIfPossible(active);
LifecycleHelper.disposeIfPossible(active);
RedisKeeperServer backup = getRedisKeeperServer(backupKeeper);
LifecycleHelper.stopIfPossible(backup);
LifecycleHelper.disposeIfPossible(backup);
logger.info(remarkableMessage("start keepers"));
startKeepers();
makeKeeperRight();
sleep(2000);
sendMessageToMasterAndTestSlaveRedis();
}
use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer in project x-pipe by ctripcorp.
the class KeeperSingleDcSlaveof method testMakeRedisSlave.
private void testMakeRedisSlave(boolean xslaveof) throws Exception {
sendMessageToMasterAndTestSlaveRedis();
RedisKeeperServer backupKeeperServer = getRedisKeeperServer(backupKeeper);
setKeeperState(backupKeeper, KeeperState.ACTIVE, redisMaster.getIp(), redisMaster.getPort(), false);
setKeeperState(activeKeeper, KeeperState.BACKUP, backupKeeper.getIp(), backupKeeper.getPort(), false);
if (xslaveof) {
new XSlaveofJob(slaves, backupKeeper.getIp(), backupKeeper.getPort(), getXpipeNettyClientKeyedObjectPool(), scheduled, executors).execute().sync();
} else {
new SlaveofJob(slaves, backupKeeper.getIp(), backupKeeper.getPort(), getXpipeNettyClientKeyedObjectPool(), scheduled, executors).execute().sync();
}
sleep(2000);
Set<RedisSlave> slaves = backupKeeperServer.slaves();
Assert.assertEquals(3, slaves.size());
for (RedisSlave redisSlave : slaves) {
PARTIAL_STATE dest = PARTIAL_STATE.PARTIAL;
if (redisSlave.getSlaveListeningPort() == activeKeeper.getPort()) {
logger.info("[testXSlaveof][role keeper]{}, {}", redisSlave, redisSlave.partialState());
} else {
logger.info("[testXSlaveof][role redis]{}, {}", redisSlave, redisSlave.partialState());
}
Assert.assertEquals(dest, redisSlave.partialState());
}
sendMessageToMasterAndTestSlaveRedis();
}
Aggregations