Search in sources :

Example 16 with RedisKeeperServer

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

the class AbstractFullIntegrated method getRedisKeeperServers.

protected List<RedisKeeperServer> getRedisKeeperServers(String dc) {
    List<RedisKeeperServer> result = new LinkedList<>();
    Map<String, RedisKeeperServer> redisKeeperServers = getRegistry().getComponents(RedisKeeperServer.class);
    for (RedisKeeperServer redisKeeperServer : redisKeeperServers.values()) {
        String currentDc = redisKeeperServer.getCurrentKeeperMeta().parent().parent().parent().getId();
        if (dc.equals(currentDc)) {
            result.add(redisKeeperServer);
        }
    }
    return result;
}
Also used : RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) LinkedList(java.util.LinkedList)

Example 17 with RedisKeeperServer

use of com.ctrip.xpipe.redis.keeper.RedisKeeperServer 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 18 with RedisKeeperServer

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

the class DefaultRedisKeeperServerConnectToFakeRedisTest method testDumpWhileWaitForRdb.

@Test
public void testDumpWhileWaitForRdb() throws Exception {
    int sleepBeforeSendRdb = 2000;
    fakeRedisServer.setSleepBeforeSendRdb(sleepBeforeSendRdb);
    RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis(100, allCommandsSize);
    sleep(sleepBeforeSendRdb / 4);
    int rdbDumpCount1 = ((DefaultRedisKeeperServer) redisKeeperServer).getRdbDumpTryCount();
    Assert.assertEquals(1, rdbDumpCount1);
    int keeperPort = redisKeeperServer.getListeningPort();
    logger.info(remarkableMessage("send psync to keeper port:{}"), keeperPort);
    InMemoryPsync psync = sendInmemoryPsync("localhost", keeperPort, "?", -1L);
    sleep(1000);
    int rdbDumpCount2 = ((DefaultRedisKeeperServer) redisKeeperServer).getRdbDumpTryCount();
    Assert.assertEquals(1, rdbDumpCount2);
    sleep(sleepBeforeSendRdb);
    assertPsyncResultEquals(psync);
}
Also used : DefaultRedisKeeperServer(com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer) DefaultRedisKeeperServer(com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer) RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) InMemoryPsync(com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync) Test(org.junit.Test)

Example 19 with RedisKeeperServer

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

the class FakeRedisRdbDumperTest method testRdbDumpWhileNotConnectedToMaster.

@Test
public void testRdbDumpWhileNotConnectedToMaster() throws Exception {
    fakeRedisServer.setSleepBeforeSendFullSyncInfo(sleepBeforeSendFullSyncInfo);
    RedisKeeperServer redisKeeperServer = startRedisKeeperServerAndConnectToFakeRedis();
    InMemoryPsync inMemoryPsync = sendInmemoryPsync("localhost", redisKeeperServer.getListeningPort());
    CommandFuture<?> future = inMemoryPsync.future();
    sleep(sleepBeforeSendFullSyncInfo + 1000);
    Assert.assertEquals(1, ((DefaultRedisKeeperServer) redisKeeperServer).getRdbDumpTryCount());
    Assert.assertFalse(future.isSuccess());
}
Also used : DefaultRedisKeeperServer(com.ctrip.xpipe.redis.keeper.impl.DefaultRedisKeeperServer) RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) InMemoryPsync(com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync) Test(org.junit.Test)

Example 20 with RedisKeeperServer

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

the class PsyncHandler method doFullSync.

protected void doFullSync(RedisSlave redisSlave) {
    try {
        if (logger.isInfoEnabled()) {
            logger.info("[doFullSync]" + redisSlave);
        }
        redisSlave.markPsyncProcessed();
        RedisKeeperServer redisKeeperServer = redisSlave.getRedisKeeperServer();
        // alert full sync
        String alert = String.format("FULL(M)<-%s[%s,%s]", redisSlave.metaInfo(), redisKeeperServer.getClusterId(), redisKeeperServer.getShardId());
        EventMonitor.DEFAULT.logAlertEvent(alert);
        redisKeeperServer.fullSyncToSlave(redisSlave);
        redisKeeperServer.getKeeperMonitor().getKeeperStats().increaseFullSync();
    } catch (IOException e) {
        logger.error("[doFullSync][close client]" + redisSlave, e);
        try {
            redisSlave.close();
        } catch (IOException e1) {
            logger.error("[doFullSync]" + redisSlave, e1);
        }
    }
}
Also used : RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) IOException(java.io.IOException)

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