use of com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync 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());
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync in project x-pipe by ctripcorp.
the class TwoKeepers method psync.
private boolean psync(KeeperMeta downstreamKeeper) throws InterruptedException, ExecutionException {
Psync psync = new InMemoryPsync(downstreamKeeper.getIp(), downstreamKeeper.getPort(), "?", -1, scheduled) {
@Override
protected void endReadRdb() {
super.endReadRdb();
future().setSuccess();
}
};
try {
return psync.execute().sync().isSuccess();
} catch (Exception e) {
return false;
}
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync in project x-pipe by ctripcorp.
the class AbstractFakeRedisTest method sendInmemoryPsync.
protected InMemoryPsync sendInmemoryPsync(String ip, int port, String runid, long offset, PsyncObserver psyncObserver) throws Exception {
SequenceCommandChain chain = new SequenceCommandChain(false);
SimpleObjectPool<NettyClient> pool = getXpipeNettyClientKeyedObjectPool().getKeyPool(new DefaultEndPoint(ip, port));
NettyClient nettyClient = null;
try {
nettyClient = pool.borrowObject();
SimpleObjectPool<NettyClient> clientPool = new FixedObjectPool<NettyClient>(nettyClient);
chain.add(new Replconf(clientPool, ReplConfType.CAPA, scheduled, CAPA.EOF.toString()));
InMemoryPsync psync = new InMemoryPsync(clientPool, runid, offset, scheduled);
chain.add(psync);
if (psyncObserver != null) {
psync.addPsyncObserver(psyncObserver);
}
psync.addPsyncObserver(new PsyncObserver() {
private long masterRdbOffset = 0;
@Override
public void reFullSync() {
}
@Override
public void onFullSync(long masterRdbOffset) {
}
@Override
public void onContinue(String requestReplId, String responseReplId) {
}
@Override
public void onKeeperContinue(String replId, long beginOffset) {
}
@Override
public void endWriteRdb() {
new Replconf(clientPool, ReplConfType.ACK, scheduled, String.valueOf(masterRdbOffset)).execute();
}
@Override
public void beginWriteRdb(EofType eofType, String replId, long masterRdbOffset) throws IOException {
this.masterRdbOffset = masterRdbOffset;
}
});
chain.execute();
return psync;
} finally {
if (nettyClient != null) {
pool.returnObject(nettyClient);
}
}
}
use of com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync in project x-pipe by ctripcorp.
the class FakeRedisHalfRdbServerFail method redisFailWhileSendingRdb.
@Test
public void redisFailWhileSendingRdb() throws Exception {
waitConditionUntilTimeOut(() -> {
return redisKeeperServer.getRedisMaster().getMasterState() == MASTER_STATE.REDIS_REPL_CONNECTED;
});
logger.info(remarkableMessage("[redisFailWhileSendingRdb]"));
InMemoryPsync inMemoryPsync = sendInmemoryPsync("localhost", redisKeeperServer.getListeningPort());
sleep(1500);
assertPsyncResultEquals(inMemoryPsync);
}
Aggregations