Search in sources :

Example 6 with RoleCommand

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

the class RoleCommandTest method testSlave.

@Test
public void testSlave() throws Exception {
    for (MASTER_STATE masterState : MASTER_STATE.values()) {
        Server slave = startServer("*5\r\n" + "$5\r\nslave\r\n" + "$9\r\nlocalhost\r\n" + ":6379\r\n" + "$" + masterState.getDesc().length() + "\r\n" + masterState.getDesc() + "\r\n" + ":477\r\n");
        RoleCommand roleCommand = new RoleCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(localhostInetAddress(slave.getPort())), 2000, false, scheduled);
        SlaveRole role = (SlaveRole) roleCommand.execute().get();
        Assert.assertEquals(SERVER_ROLE.SLAVE, role.getServerRole());
        Assert.assertEquals("localhost", role.getMasterHost());
        Assert.assertEquals(6379, role.getMasterPort());
        Assert.assertEquals(masterState, role.getMasterState());
        Assert.assertEquals(477, role.getMasterOffset());
    }
}
Also used : SlaveRole(com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole) Server(com.ctrip.xpipe.simpleserver.Server) RoleCommand(com.ctrip.xpipe.redis.core.protocal.cmd.RoleCommand) MASTER_STATE(com.ctrip.xpipe.redis.core.protocal.MASTER_STATE) Test(org.junit.Test)

Aggregations

RoleCommand (com.ctrip.xpipe.redis.core.protocal.cmd.RoleCommand)6 Role (com.ctrip.xpipe.redis.core.protocal.pojo.Role)4 SlaveRole (com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole)4 Server (com.ctrip.xpipe.simpleserver.Server)3 InetSocketAddress (java.net.InetSocketAddress)3 Test (org.junit.Test)3 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)2 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)1 MASTER_STATE (com.ctrip.xpipe.redis.core.protocal.MASTER_STATE)1 LinkedList (java.util.LinkedList)1 ExecutionException (java.util.concurrent.ExecutionException)1 TimeoutException (java.util.concurrent.TimeoutException)1