Search in sources :

Example 1 with DefaultNettyClient

use of com.ctrip.xpipe.netty.commands.DefaultNettyClient in project x-pipe by ctripcorp.

the class AbstractRedisMasterReplication method masterConnected.

@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
public void masterConnected(Channel channel) {
    connectedTime = System.currentTimeMillis();
    this.masterChannel = channel;
    clientPool = new FixedObjectPool<NettyClient>(new DefaultNettyClient(channel));
    checkTimeout(channel);
    checkKeeper();
    SequenceCommandChain chain = new SequenceCommandChain(false);
    chain.add(listeningPortCommand());
    chain.add(new FailSafeCommandWrapper<>(new Replconf(clientPool, ReplConfType.CAPA, scheduled, CAPA.EOF.toString(), CAPA.PSYNC2.toString())));
    try {
        executeCommand(chain).addListener(new CommandFutureListener() {

            @Override
            public void operationComplete(CommandFuture commandFuture) throws Exception {
                if (commandFuture.isSuccess()) {
                    sendReplicationCommand();
                } else {
                    logger.error("[operationComplete][listeningPortCommand]", commandFuture.cause());
                }
            }
        });
    } catch (Exception e) {
        logger.error("[masterConnected]" + channel, e);
    }
}
Also used : NettyClient(com.ctrip.xpipe.netty.commands.NettyClient) DefaultNettyClient(com.ctrip.xpipe.netty.commands.DefaultNettyClient) CommandFuture(com.ctrip.xpipe.api.command.CommandFuture) Replconf(com.ctrip.xpipe.redis.core.protocal.cmd.Replconf) CommandFutureListener(com.ctrip.xpipe.api.command.CommandFutureListener) DefaultNettyClient(com.ctrip.xpipe.netty.commands.DefaultNettyClient) CommandExecutionException(com.ctrip.xpipe.command.CommandExecutionException) IOException(java.io.IOException) XpipeException(com.ctrip.xpipe.exception.XpipeException) SequenceCommandChain(com.ctrip.xpipe.command.SequenceCommandChain)

Aggregations

CommandFuture (com.ctrip.xpipe.api.command.CommandFuture)1 CommandFutureListener (com.ctrip.xpipe.api.command.CommandFutureListener)1 CommandExecutionException (com.ctrip.xpipe.command.CommandExecutionException)1 SequenceCommandChain (com.ctrip.xpipe.command.SequenceCommandChain)1 XpipeException (com.ctrip.xpipe.exception.XpipeException)1 DefaultNettyClient (com.ctrip.xpipe.netty.commands.DefaultNettyClient)1 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)1 Replconf (com.ctrip.xpipe.redis.core.protocal.cmd.Replconf)1 IOException (java.io.IOException)1