Search in sources :

Example 1 with Psync

use of com.ctrip.xpipe.redis.core.protocal.Psync in project x-pipe by ctripcorp.

the class ReplconfTest method test.

@Test
public void test() throws Exception {
    for (int i = 0; i < 100; i++) {
        FixedObjectPool<NettyClient> clientPool = null;
        try {
            clientPool = createClientPool(host, port);
            Replconf replconf = new Replconf(clientPool, ReplConfType.LISTENING_PORT, scheduled, String.valueOf(1234));
            replconf.execute().addListener(new CommandFutureListener<Object>() {

                @Override
                public void operationComplete(CommandFuture<Object> commandFuture) throws Exception {
                    logger.info("{}", commandFuture.get());
                }
            });
            Psync psync = new InMemoryPsync(clientPool, "?", -1L, scheduled);
            try {
                psync.execute().get(100, TimeUnit.MILLISECONDS);
                Assert.fail();
            } catch (TimeoutException e) {
            }
        } finally {
            if (clientPool != null) {
                clientPool.getObject().channel().close();
            }
        }
    }
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) Replconf(com.ctrip.xpipe.redis.core.protocal.cmd.Replconf) Psync(com.ctrip.xpipe.redis.core.protocal.Psync) InMemoryPsync(com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync) InMemoryPsync(com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync) TimeoutException(java.util.concurrent.TimeoutException) TimeoutException(java.util.concurrent.TimeoutException) Test(org.junit.Test)

Example 2 with Psync

use of com.ctrip.xpipe.redis.core.protocal.Psync in project x-pipe by ctripcorp.

the class RdbonlyRedisMasterReplication method createPsync.

@Override
protected Psync createPsync() {
    Psync psync = new RdbOnlyPsync(clientPool, rdbOnlyReplicationStore, scheduled);
    psync.addPsyncObserver(this);
    return psync;
}
Also used : Psync(com.ctrip.xpipe.redis.core.protocal.Psync) RdbOnlyPsync(com.ctrip.xpipe.redis.core.protocal.cmd.RdbOnlyPsync) RdbOnlyPsync(com.ctrip.xpipe.redis.core.protocal.cmd.RdbOnlyPsync)

Example 3 with Psync

use of com.ctrip.xpipe.redis.core.protocal.Psync in project x-pipe by ctripcorp.

the class AbstractRedisMasterReplication method psyncCommand.

protected Psync psyncCommand() {
    if (getLifecycleState().isStopping() || getLifecycleState().isStopped()) {
        logger.info("[psyncCommand][stopped]{}", this);
        return null;
    }
    Psync psync = createPsync();
    psync.future().addListener(new CommandFutureListener<Object>() {

        @Override
        public void operationComplete(CommandFuture<Object> commandFuture) throws Exception {
            if (!commandFuture.isSuccess()) {
                logger.error("[operationComplete][psyncCommand][fail]" + AbstractRedisMasterReplication.this, commandFuture.cause());
                dumpFail(commandFuture.cause());
                psyncFail(commandFuture.cause());
            }
        }
    });
    return psync;
}
Also used : Psync(com.ctrip.xpipe.redis.core.protocal.Psync) CommandExecutionException(com.ctrip.xpipe.command.CommandExecutionException) IOException(java.io.IOException) XpipeException(com.ctrip.xpipe.exception.XpipeException)

Example 4 with Psync

use of com.ctrip.xpipe.redis.core.protocal.Psync in project x-pipe by ctripcorp.

the class DefaultRedisMasterReplication method createPsync.

@Override
protected Psync createPsync() {
    Psync psync = new DefaultPsync(clientPool, redisMaster.masterEndPoint(), redisMaster.getReplicationStoreManager(), scheduled);
    psync.addPsyncObserver(this);
    psync.addPsyncObserver(redisKeeperServer);
    return psync;
}
Also used : Psync(com.ctrip.xpipe.redis.core.protocal.Psync) DefaultPsync(com.ctrip.xpipe.redis.core.protocal.cmd.DefaultPsync) DefaultPsync(com.ctrip.xpipe.redis.core.protocal.cmd.DefaultPsync)

Aggregations

Psync (com.ctrip.xpipe.redis.core.protocal.Psync)4 CommandExecutionException (com.ctrip.xpipe.command.CommandExecutionException)1 XpipeException (com.ctrip.xpipe.exception.XpipeException)1 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)1 DefaultPsync (com.ctrip.xpipe.redis.core.protocal.cmd.DefaultPsync)1 InMemoryPsync (com.ctrip.xpipe.redis.core.protocal.cmd.InMemoryPsync)1 RdbOnlyPsync (com.ctrip.xpipe.redis.core.protocal.cmd.RdbOnlyPsync)1 Replconf (com.ctrip.xpipe.redis.core.protocal.cmd.Replconf)1 IOException (java.io.IOException)1 TimeoutException (java.util.concurrent.TimeoutException)1 Test (org.junit.Test)1