Search in sources :

Example 1 with DefaultReplicationStore

use of com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore in project x-pipe by ctripcorp.

the class FakeRedisExceptionTest method testRdbFileError.

@Test
public void testRdbFileError() throws Exception {
    RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis();
    countDownLatch.await(10, TimeUnit.SECONDS);
    RdbStore rdbStore = ((DefaultReplicationStore) redisKeeperServer.getReplicationStore()).getRdbStore();
    Assert.assertFalse(rdbStore.checkOk());
}
Also used : DefaultRedisKeeperServer(com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer) RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) RdbStore(com.ctrip.xpipe.redis.core.store.RdbStore) DefaultReplicationStore(com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore) Test(org.junit.Test)

Example 2 with DefaultReplicationStore

use of com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore in project x-pipe by ctripcorp.

the class DefaultRedisKeeperServerConnectToFakeRedisTest method startKeeperServerAndTestReFullSync.

private void startKeeperServerAndTestReFullSync(int fileToKeep, int maxTransferCommnadsSize) throws Exception {
    RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis(fileToKeep, maxTransferCommnadsSize, 1000);
    int keeperPort = redisKeeperServer.getListeningPort();
    sleep(2000);
    logger.info(remarkableMessage("send psync to redump rdb"));
    int rdbDumpCount1 = ((DefaultReplicationStore) redisKeeperServer.getReplicationStore()).getRdbUpdateCount();
    InMemoryPsync psync = sendInmemoryPsync("localhost", keeperPort);
    sleep(3000);
    int rdbDumpCount2 = ((DefaultReplicationStore) redisKeeperServer.getReplicationStore()).getRdbUpdateCount();
    Assert.assertEquals(rdbDumpCount1 + 1, rdbDumpCount2);
    assertPsyncResultEquals(psync);
}
Also used : DefaultRedisKeeperServer(com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer) RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) DefaultReplicationStore(com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore) InMemoryPsync(com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync)

Example 3 with DefaultReplicationStore

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

Example 4 with DefaultReplicationStore

use of com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore in project x-pipe by ctripcorp.

the class FakeRedisExceptionTest method writeToRdb.

private void writeToRdb(ReplicationStore currentReplicationStore) throws IOException {
    logger.info("[writeToRdb][write error byte]");
    DefaultReplicationStore replicationStore = (DefaultReplicationStore) currentReplicationStore;
    replicationStore.getRdbStore().writeRdb(Unpooled.wrappedBuffer("1".getBytes()));
}
Also used : DefaultReplicationStore(com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore)

Aggregations

DefaultReplicationStore (com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore)4 RedisKeeperServer (com.ctrip.xpipe.redis.keeper.RedisKeeperServer)3 DefaultRedisKeeperServer (com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer)2 Test (org.junit.Test)2 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)1 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)1 InMemoryPsync (com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync)1 RdbStore (com.ctrip.xpipe.redis.core.store.RdbStore)1