use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class OneDcKeepers method testKeeperChangeState.
@Test
public void testKeeperChangeState() throws Exception {
int round = 1000;
scheduled.scheduleAtFixedRate(new AbstractExceptionLogTask() {
@Override
protected void doRun() throws Exception {
sendMessageToMaster(getRedisMaster(), 100);
}
}, 0, 500, TimeUnit.SECONDS.MILLISECONDS);
RedisMeta redisMaster = getRedisMaster();
KeeperMeta currentActive = activeKeeper;
KeeperMeta currentBackup = backupKeeper;
for (int i = 0; i < round; i++) {
logger.info(remarkableMessage("round: {}"), i);
setKeeperState(currentBackup, KeeperState.ACTIVE, redisMaster.getIp(), redisMaster.getPort());
setKeeperState(currentActive, KeeperState.BACKUP, currentBackup.getIp(), currentBackup.getPort());
sleep(1000);
KeeperMeta tmp = currentActive;
currentActive = currentBackup;
currentBackup = tmp;
}
waitForAnyKey();
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class AbstractIntegratedTestTemplate method failOverTestTemplate.
@SuppressWarnings("unused")
protected void failOverTestTemplate() throws Exception {
RedisMeta redisMaster = getRedisMaster();
stopServerListeningPort(redisMaster.getPort());
RedisKeeperServer redisKeeperServer = getRedisKeeperServerActive(activeDc().getId());
RedisMeta slave = getRedisSlaves(activeDc().getId()).get(0);
SERVER_ROLE role = getRedisServerRole(slave);
Assert.assertEquals(SERVER_ROLE.SLAVE, role);
logger.info(remarkableMessage("[testRedisFailover][promote]{}:{})"), slave.getIp(), slave.getPort());
String clusterId = redisMaster.parent().parent().getId();
String shardId = redisMaster.parent().getId();
DefaultMetaServer metaServer = getDcInfos().get(activeDc().getId()).getApplicationContext().getBean(DefaultMetaServer.class);
// metaServer.promoteRedisMaster(clusterId, shardId, slave.getIp(), slave.getPort());
sleep(6000);
role = getRedisServerRole(slave);
Assert.assertEquals(SERVER_ROLE.MASTER, role);
Assert.assertEquals(PARTIAL_STATE.PARTIAL, redisKeeperServer.getRedisMaster().partialState());
changeRedisMaster(redisMaster, slave);
sendMessageToMasterAndTestSlaveRedis();
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class RedisSlaveReplAllTest method beforeRedisSlaveReplAllTest.
@Before
public void beforeRedisSlaveReplAllTest() throws IOException {
redises.add(new RedisMeta().setIp("127.0.0.1").setPort(6379));
redises.add(new RedisMeta().setIp("127.0.0.1").setPort(6479));
redises.add(new RedisMeta().setIp("127.0.0.1").setPort(6579));
redises.add(new RedisMeta().setIp("127.0.0.1").setPort(6679));
startRedises(redises);
slaveWritable(redises);
sleep(2000);
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class RedisSlaveReplAllTest method startRedises.
private void startRedises(List<RedisMeta> redises) throws IOException {
for (int i = 0; i < redises.size(); i++) {
RedisMeta redis = redises.get(i);
stopServerListeningPort(redis.getPort());
if (i == 0) {
startRedis(redis);
} else {
startRedis(redis, redises.get(i - 1));
}
}
}
use of com.ctrip.xpipe.redis.core.entity.RedisMeta in project x-pipe by ctripcorp.
the class AbstractKeeperIntegratedSingleDc method makeKeeperRight.
protected void makeKeeperRight() throws Exception {
List<KeeperMeta> keepers = getDcKeepers(dc, getClusterId(), getShardId());
RedisMeta redisMaster = getRedisMaster();
KeeperStateChangeJob job = new KeeperStateChangeJob(keepers, new Pair<String, Integer>(redisMaster.getIp(), redisMaster.getPort()), getXpipeNettyClientKeyedObjectPool(), scheduled, executors);
job.execute().sync();
}
Aggregations