Search in sources :

Example 1 with PARTIAL_STATE

use of com.ctrip.xpipe.api.server.PARTIAL_STATE in project x-pipe by ctripcorp.

the class KeeperSingleDcSlaveof method testMakeRedisSlave.

private void testMakeRedisSlave(boolean xslaveof) throws Exception {
    sendMessageToMasterAndTestSlaveRedis();
    RedisKeeperServer backupKeeperServer = getRedisKeeperServer(backupKeeper);
    setKeeperState(backupKeeper, KeeperState.ACTIVE, redisMaster.getIp(), redisMaster.getPort(), false);
    setKeeperState(activeKeeper, KeeperState.BACKUP, backupKeeper.getIp(), backupKeeper.getPort(), false);
    if (xslaveof) {
        new XSlaveofJob(slaves, backupKeeper.getIp(), backupKeeper.getPort(), getXpipeNettyClientKeyedObjectPool(), scheduled, executors).execute().sync();
    } else {
        new SlaveofJob(slaves, backupKeeper.getIp(), backupKeeper.getPort(), getXpipeNettyClientKeyedObjectPool(), scheduled, executors).execute().sync();
    }
    sleep(2000);
    Set<RedisSlave> slaves = backupKeeperServer.slaves();
    Assert.assertEquals(3, slaves.size());
    for (RedisSlave redisSlave : slaves) {
        PARTIAL_STATE dest = PARTIAL_STATE.PARTIAL;
        if (redisSlave.getSlaveListeningPort() == activeKeeper.getPort()) {
            logger.info("[testXSlaveof][role keeper]{}, {}", redisSlave, redisSlave.partialState());
        } else {
            logger.info("[testXSlaveof][role redis]{}, {}", redisSlave, redisSlave.partialState());
        }
        Assert.assertEquals(dest, redisSlave.partialState());
    }
    sendMessageToMasterAndTestSlaveRedis();
}
Also used : RedisKeeperServer(com.ctrip.xpipe.redis.keeper.RedisKeeperServer) XSlaveofJob(com.ctrip.xpipe.redis.meta.server.job.XSlaveofJob) PARTIAL_STATE(com.ctrip.xpipe.api.server.PARTIAL_STATE) RedisSlave(com.ctrip.xpipe.redis.keeper.RedisSlave) XSlaveofJob(com.ctrip.xpipe.redis.meta.server.job.XSlaveofJob) SlaveofJob(com.ctrip.xpipe.redis.meta.server.job.SlaveofJob)

Aggregations

PARTIAL_STATE (com.ctrip.xpipe.api.server.PARTIAL_STATE)1 RedisKeeperServer (com.ctrip.xpipe.redis.keeper.RedisKeeperServer)1 RedisSlave (com.ctrip.xpipe.redis.keeper.RedisSlave)1 SlaveofJob (com.ctrip.xpipe.redis.meta.server.job.SlaveofJob)1 XSlaveofJob (com.ctrip.xpipe.redis.meta.server.job.XSlaveofJob)1