Search in sources :

Example 1 with DefaultMetaServer

use of com.ctrip.xpipe.redis.meta.server.impl.DefaultMetaServer 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();
}
Also used : DefaultMetaServer(com.ctrip.xpipe.redis.meta.server.impl.DefaultMetaServer) RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) SERVER_ROLE(com.ctrip.xpipe.api.server.Server.SERVER_ROLE)

Aggregations

SERVER_ROLE (com.ctrip.xpipe.api.server.Server.SERVER_ROLE)1 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)1 RedisKeeperServer (com.ctrip.xpipe.redis.keeper.RedisKeeperServer)1 DefaultMetaServer (com.ctrip.xpipe.redis.meta.server.impl.DefaultMetaServer)1