Search in sources :

Example 51 with RedisMeta

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);
}
Also used : Jedis(redis.clients.jedis.Jedis) DefaultRedisKeeperServer(com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer) RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) Test(org.junit.Test)

Example 52 with RedisMeta

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);
}
Also used : RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) Test(org.junit.Test)

Example 53 with RedisMeta

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);
}
Also used : RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) Test(org.junit.Test)

Example 54 with RedisMeta

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();
}
Also used : RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) KeeperMeta(com.ctrip.xpipe.redis.core.entity.KeeperMeta) Test(org.junit.Test)

Example 55 with RedisMeta

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));
}
Also used : RedisMeta(com.ctrip.xpipe.redis.core.entity.RedisMeta) AbstractIntegratedTest(com.ctrip.xpipe.redis.integratedtest.AbstractIntegratedTest) Test(org.junit.Test)

Aggregations

RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)55 Test (org.junit.Test)26 LinkedList (java.util.LinkedList)14 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)9 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)8 Before (org.junit.Before)7 SimpleErrorMessage (com.ctrip.xpipe.exception.SimpleErrorMessage)5 RedisKeeperServer (com.ctrip.xpipe.redis.keeper.RedisKeeperServer)5 AtLeastOneChecker (com.ctrip.xpipe.redis.meta.server.dcchange.impl.AtLeastOneChecker)5 ClusterMeta (com.ctrip.xpipe.redis.core.entity.ClusterMeta)4 ShardMeta (com.ctrip.xpipe.redis.core.entity.ShardMeta)4 SlaveRole (com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole)4 Pair (com.ctrip.xpipe.tuple.Pair)4 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)3 PrimaryDcChangeMessage (com.ctrip.xpipe.redis.core.metaserver.MetaServerConsoleService.PrimaryDcChangeMessage)3 Server (com.ctrip.xpipe.simpleserver.Server)3 InetSocketAddress (java.net.InetSocketAddress)3 SERVER_ROLE (com.ctrip.xpipe.api.server.Server.SERVER_ROLE)2 AbstractExceptionLogTask (com.ctrip.xpipe.concurrent.AbstractExceptionLogTask)2 HostPort (com.ctrip.xpipe.endpoint.HostPort)2