Search in sources :

Example 41 with RedisKeeperServer

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

the class DefaultRedisKeeperServerConnectToFakeRedisTest method testReplicationData.

@Test
public void testReplicationData() throws Exception {
    RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis();
    sleep(1500);
    logger.info(remarkableMessage("[testReplicationData][read replication store]"));
    ReplicationStore replicationStore = redisKeeperServer.getReplicationStore();
    String rdbContent = readRdbFileTilEnd(replicationStore);
    Assert.assertEquals(fakeRedisServer.getRdbContent(), rdbContent);
    String commands = readCommandFileTilEnd(replicationStore, fakeRedisServer.currentCommands().length());
    Assert.assertEquals(fakeRedisServer.currentCommands(), commands);
}
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) ReplicationStore(com.ctrip.xpipe.redis.core.store.ReplicationStore) Test(org.junit.Test)

Example 42 with RedisKeeperServer

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

the class AbstractFakeRedisTest method startRedisKeeperServer.

protected RedisKeeperServer startRedisKeeperServer(int replicationStoreCommandFileNumToKeep, int replicationStoreMaxCommandsToTransferBeforeCreateRdb, int minTimeMilliToGcAfterCreate) throws Exception {
    KeeperConfig keeperConfig = new TestKeeperConfig(commandFileSize, replicationStoreCommandFileNumToKeep, replicationStoreMaxCommandsToTransferBeforeCreateRdb, minTimeMilliToGcAfterCreate);
    RedisKeeperServer redisKeeperServer = createRedisKeeperServer(keeperConfig);
    redisKeeperServer.initialize();
    redisKeeperServer.start();
    add(redisKeeperServer);
    return redisKeeperServer;
}
Also used : RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) TestKeeperConfig(com.ctrip.xpipe.redis.keeper.config.TestKeeperConfig) KeeperConfig(com.ctrip.xpipe.redis.keeper.config.KeeperConfig) TestKeeperConfig(com.ctrip.xpipe.redis.keeper.config.TestKeeperConfig)

Example 43 with RedisKeeperServer

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

the class FakeRedisRdbDumpLong method testRedisWithLf.

@Test
public void testRedisWithLf() throws Exception {
    int sleepBeforeSendRdb = replicationTimeoutMilli * 2;
    fakeRedisServer.setSleepBeforeSendRdb(sleepBeforeSendRdb);
    RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis();
    waitConditionUntilTimeOut(() -> MASTER_STATE.REDIS_REPL_CONNECTED == redisKeeperServer.getRedisMaster().getMasterState(), replicationTimeoutMilli * 5);
}
Also used : RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) Test(org.junit.Test)

Example 44 with RedisKeeperServer

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

the class KeeperContainerServiceTest method testAddKeeper.

@Test
public void testAddKeeper() throws Exception {
    RedisKeeperServer redisKeeperServer = keeperContainerService.add(someKeeperTransMeta);
    verify(componentRegistry, times(1)).add(redisKeeperServer);
    assertEquals(someCluster, redisKeeperServer.getClusterId());
    assertEquals(someShard, redisKeeperServer.getShardId());
    assertEquals(somePort, redisKeeperServer.getListeningPort());
}
Also used : RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) Test(org.junit.Test)

Aggregations

RedisKeeperServer (com.ctrip.xpipe.redis.keeper.RedisKeeperServer)44 Test (org.junit.Test)23 DefaultRedisKeeperServer (com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer)13 RedisSlave (com.ctrip.xpipe.redis.keeper.RedisSlave)6 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)5 ErrorMessage (com.ctrip.xpipe.exception.ErrorMessage)4 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)4 RedisKeeperRuntimeException (com.ctrip.xpipe.redis.keeper.exception.RedisKeeperRuntimeException)4 DefaultReplicationStore (com.ctrip.xpipe.redis.keeper.store.DefaultReplicationStore)4 InMemoryPsync (com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync)3 RedisErrorParser (com.ctrip.xpipe.redis.core.protocal.protocal.RedisErrorParser)3 LinkedList (java.util.LinkedList)3 ReplicationStore (com.ctrip.xpipe.redis.core.store.ReplicationStore)2 XSlaveofJob (com.ctrip.xpipe.redis.meta.server.job.XSlaveofJob)2 IOException (java.io.IOException)2 Endpoint (com.ctrip.xpipe.api.endpoint.Endpoint)1 PARTIAL_STATE (com.ctrip.xpipe.api.server.PARTIAL_STATE)1 SERVER_ROLE (com.ctrip.xpipe.api.server.Server.SERVER_ROLE)1 DcMeta (com.ctrip.xpipe.redis.core.entity.DcMeta)1 NoMasterlinkRedisError (com.ctrip.xpipe.redis.core.protocal.error.NoMasterlinkRedisError)1