Search in sources :

Example 1 with TransportServer

use of com.baidu.hugegraph.computer.core.network.TransportServer in project hugegraph-computer by hugegraph.

the class AbstractNetworkTest method mockSpyProtocol.

private void mockSpyProtocol() {
    Object clientFactory = Whitebox.getInternalState(connectionManager, "clientFactory");
    NettyProtocol protocol2 = Whitebox.getInternalState(clientFactory, "protocol");
    clientProtocol = Mockito.spy(protocol2);
    Whitebox.setInternalState(clientFactory, "protocol", clientProtocol);
    TransportServer sever = connectionManager.getServer();
    ServerBootstrap bootstrap = Whitebox.getInternalState(sever, "bootstrap");
    Object channelInitializer = Whitebox.invoke(ServerBootstrap.class, "childHandler", bootstrap);
    NettyProtocol protocol = Whitebox.getInternalState(channelInitializer, "protocol");
    serverProtocol = Mockito.spy(protocol);
    Whitebox.setInternalState(channelInitializer, "protocol", serverProtocol);
}
Also used : TransportServer(com.baidu.hugegraph.computer.core.network.TransportServer) ServerBootstrap(io.netty.bootstrap.ServerBootstrap)

Example 2 with TransportServer

use of com.baidu.hugegraph.computer.core.network.TransportServer in project hugegraph-computer by hugegraph.

the class ConnectionManagerTest method testGetServer.

@Test
public void testGetServer() {
    TransportServer server = connectionManager.getServer();
    Assert.assertTrue(server.bound());
    Assert.assertEquals(port, server.port());
    Assert.assertNotEquals(0, server.port());
}
Also used : TransportServer(com.baidu.hugegraph.computer.core.network.TransportServer) Test(org.junit.Test)

Example 3 with TransportServer

use of com.baidu.hugegraph.computer.core.network.TransportServer in project hugegraph-computer by hugegraph.

the class TransportConnectionManager method startServer.

@Override
public synchronized int startServer(Config config, MessageHandler serverHandler) {
    E.checkArgument(this.server == null, "The TransportServer has already been listened");
    E.checkArgumentNotNull(serverHandler, "The serverHandler param can't be null");
    TransportConf conf = TransportConf.wrapConfig(config);
    TransportServer server = conf.transportProvider().createServer(conf);
    int bindPort = server.listen(config, serverHandler);
    this.server = server;
    return bindPort;
}
Also used : TransportServer(com.baidu.hugegraph.computer.core.network.TransportServer) TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf)

Aggregations

TransportServer (com.baidu.hugegraph.computer.core.network.TransportServer)3 TransportConf (com.baidu.hugegraph.computer.core.network.TransportConf)1 ServerBootstrap (io.netty.bootstrap.ServerBootstrap)1 Test (org.junit.Test)1