Search in sources :

Example 1 with DefaultFullSyncListener

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

the class AbstractRdbDumper method tryFullSync.

@Override
public void tryFullSync(RedisSlave redisSlave) throws IOException {
    switch(rdbDumpState) {
        case DUMPING:
            FullSyncListener fullSyncListener = new DefaultFullSyncListener(redisSlave);
            if (!redisKeeperServer.getReplicationStore().fullSyncIfPossible(fullSyncListener)) {
                throw new IllegalStateException("[tryFullSync][rdb dumping, but can not full synn]");
            }
            break;
        case FAIL:
        case NORMAL:
            logger.warn("[tryFullSync]{}", redisSlave);
            redisKeeperServer.clearRdbDumper(this);
            redisKeeperServer.fullSyncToSlave(redisSlave);
            break;
        case WAIT_DUMPPING:
            logger.info("[tryFullSync][make slave waiting]{}", redisSlave);
            redisSlave.waitForRdbDumping();
            break;
    }
}
Also used : DefaultFullSyncListener(com.ctrip.xpipe.redis.keeper.store.DefaultFullSyncListener) FullSyncListener(com.ctrip.xpipe.redis.core.store.FullSyncListener) DefaultFullSyncListener(com.ctrip.xpipe.redis.keeper.store.DefaultFullSyncListener)

Example 2 with DefaultFullSyncListener

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

the class DefaultRedisKeeperServer method fullSyncToSlave.

@Override
public void fullSyncToSlave(final RedisSlave redisSlave) throws IOException {
    logger.info("[fullSyncToSlave]{}, {}", redisSlave, rdbDumper.get());
    if (rdbDumper.get() == null) {
        logger.info("[fullSyncToSlave][dumper null]{}", redisSlave);
        FullSyncListener fullSyncListener = new DefaultFullSyncListener(redisSlave);
        if (!getCurrentReplicationStore().fullSyncIfPossible(fullSyncListener)) {
            // go dump rdb
            try {
                dumpNewRdb();
                redisSlave.waitForRdbDumping();
            } catch (AbstractRdbDumperException e) {
                logger.error("[fullSyncToSlave]", e);
                if (e.isCancelSlave()) {
                    logger.info("[fullSyncToSlave][cancel slave]");
                    redisSlave.close();
                }
            }
        }
    } else {
        rdbDumper.get().tryFullSync(redisSlave);
    }
}
Also used : FullSyncListener(com.ctrip.xpipe.redis.core.store.FullSyncListener) DefaultFullSyncListener(com.ctrip.xpipe.redis.keeper.store.DefaultFullSyncListener) DefaultFullSyncListener(com.ctrip.xpipe.redis.keeper.store.DefaultFullSyncListener)

Aggregations

FullSyncListener (com.ctrip.xpipe.redis.core.store.FullSyncListener)2 DefaultFullSyncListener (com.ctrip.xpipe.redis.keeper.store.DefaultFullSyncListener)2