Search in sources :

Example 16 with Server

use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.

the class AbstractTest method startServer.

protected Server startServer(int serverPort, IoActionFactory ioActionFactory) throws Exception {
    Server server = new Server(serverPort, ioActionFactory);
    server.initialize();
    server.start();
    add(server);
    return server;
}
Also used : ZkTestServer(com.ctrip.xpipe.zk.ZkTestServer) Server(com.ctrip.xpipe.simpleserver.Server)

Example 17 with Server

use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.

the class StreamTest method testSendBuff.

@Test
public void testSendBuff() throws Exception {
    Server server = startEchoServer();
    @SuppressWarnings("resource") Socket socket = new Socket();
    socket.connect(new InetSocketAddress("localhost", server.getPort()));
    System.out.println(socket.getSendBufferSize());
    System.out.println(socket.getReceiveBufferSize());
}
Also used : Server(com.ctrip.xpipe.simpleserver.Server) InetSocketAddress(java.net.InetSocketAddress) Socket(java.net.Socket) Test(org.junit.Test) AbstractTest(com.ctrip.xpipe.AbstractTest)

Example 18 with Server

use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.

the class TcpPortCheckTest method testCheck.

@Test
public void testCheck() throws Exception {
    int port = randomPort();
    Assert.assertFalse(new TcpPortCheck("localhost", port).checkOpen());
    Server server = startEchoServer(port);
    Assert.assertTrue(new TcpPortCheck("localhost", port).checkOpen());
    sleep(100);
    Assert.assertEquals(0, server.getConnected());
}
Also used : Server(com.ctrip.xpipe.simpleserver.Server) Test(org.junit.Test) AbstractTest(com.ctrip.xpipe.AbstractTest)

Example 19 with Server

use of com.ctrip.xpipe.simpleserver.Server in project x-pipe by ctripcorp.

the class RoleCommandTest method testMaster.

@Test
public void testMaster() throws Exception {
    Server master = startServer("*3\r\n" + "$6\r\nmaster\r\n" + ":43\r\n" + "*3\r\n" + "$9\r\n127.0.0.1\r\n" + "$4\r\n6479\r\n" + "$1\r\n0\r\n");
    RoleCommand roleCommand = new RoleCommand(getXpipeNettyClientKeyedObjectPool().getKeyPool(localhostInetAddress(master.getPort())), 2000, false, scheduled);
    Role role = roleCommand.execute().get();
    Assert.assertEquals(SERVER_ROLE.MASTER, role.getServerRole());
}
Also used : Role(com.ctrip.xpipe.redis.core.protocal.pojo.Role) SlaveRole(com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole) Server(com.ctrip.xpipe.simpleserver.Server) RoleCommand(com.ctrip.xpipe.redis.core.protocal.cmd.RoleCommand) Test(org.junit.Test)

Example 20 with Server

use of com.ctrip.xpipe.simpleserver.Server 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

Server (com.ctrip.xpipe.simpleserver.Server)28 Test (org.junit.Test)25 AbstractTest (com.ctrip.xpipe.AbstractTest)9 SlaveRole (com.ctrip.xpipe.redis.core.protocal.pojo.SlaveRole)9 InetSocketAddress (java.net.InetSocketAddress)8 AbstractMetaServerTest (com.ctrip.xpipe.redis.meta.server.AbstractMetaServerTest)6 ExecutionException (java.util.concurrent.ExecutionException)6 AbstractRedisTest (com.ctrip.xpipe.redis.core.AbstractRedisTest)5 NettyClient (com.ctrip.xpipe.netty.commands.NettyClient)4 RedisMeta (com.ctrip.xpipe.redis.core.entity.RedisMeta)3 RoleCommand (com.ctrip.xpipe.redis.core.protocal.cmd.RoleCommand)3 Role (com.ctrip.xpipe.redis.core.protocal.pojo.Role)3 LinkedList (java.util.LinkedList)3 AbstractExceptionLogTask (com.ctrip.xpipe.concurrent.AbstractExceptionLogTask)2 SimpleErrorMessage (com.ctrip.xpipe.exception.SimpleErrorMessage)2 KeeperMeta (com.ctrip.xpipe.redis.core.entity.KeeperMeta)2 AtLeastOneChecker (com.ctrip.xpipe.redis.meta.server.dcchange.impl.AtLeastOneChecker)2 Socket (java.net.Socket)2 CommandTimeoutException (com.ctrip.xpipe.command.CommandTimeoutException)1 DefaultEndPoint (com.ctrip.xpipe.endpoint.DefaultEndPoint)1