Search in sources :

Example 1 with TransportConf

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

the class NettyTransportServerTest method testListenWithLocalHost.

@Test
public void testListenWithLocalHost() {
    config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.TRANSPORT_SERVER_HOST, "localhost");
    int port = this.server.listen(config, messageHandler);
    TransportConf conf = this.server.conf();
    Assert.assertEquals("localhost", conf.serverAddress().getHostName());
    Assert.assertNotEquals(0, this.server.port());
    Assert.assertNotEquals(0, port);
    Assert.assertEquals("127.0.0.1", this.server.ip());
    Assert.assertEquals(port, this.server.port());
}
Also used : TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Example 2 with TransportConf

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

the class NettyTransportServerTest method testListenWithDefaultPort.

@Test
public void testListenWithDefaultPort() {
    int port = this.server.listen(config, messageHandler);
    TransportConf conf = this.server.conf();
    Assert.assertLte(3, conf.serverThreads());
    Assert.assertEquals(IOMode.NIO, conf.ioMode());
    Assert.assertEquals("127.0.0.1", conf.serverAddress().getHostAddress());
    Assert.assertNotEquals(0, this.server.port());
    Assert.assertNotEquals(0, port);
    Assert.assertEquals("127.0.0.1", this.server.ip());
    String hostName = this.server.bindAddress().getHostName();
    Assert.assertEquals("localhost", hostName);
    Assert.assertEquals(port, this.server.port());
}
Also used : TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Example 3 with TransportConf

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

the class NettyTransportServerTest method testListenWithZeroIp.

@Test
public void testListenWithZeroIp() {
    config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.TRANSPORT_SERVER_HOST, "0.0.0.0");
    int port = this.server.listen(config, messageHandler);
    TransportConf conf = this.server.conf();
    Assert.assertEquals("0.0.0.0", conf.serverAddress().getHostAddress());
    Assert.assertNotEquals(0, port);
    Assert.assertNotEquals(0, this.server.port());
    Assert.assertTrue(this.server.bindAddress().getAddress().isAnyLocalAddress());
    Assert.assertEquals(port, this.server.port());
}
Also used : TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Example 4 with TransportConf

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

the class NettyClientFactoryTest method testClose.

@Test
public void testClose() throws IOException {
    TransportConf conf = TransportConf.wrapConfig(config);
    NettyClientFactory clientFactory = new NettyClientFactory(conf);
    clientFactory.init();
    ConnectionId connectionId = ConnectionId.parseConnectionId("127.0.0.1", 8086);
    this.client = clientFactory.createClient(connectionId, clientHandler);
    Assert.assertTrue(this.client.active());
    this.client.close();
    Assert.assertFalse(this.client.active());
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Example 5 with TransportConf

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

the class NettyClientFactoryTest method testCreateClient.

@Test
public void testCreateClient() throws IOException {
    TransportConf conf = TransportConf.wrapConfig(config);
    NettyClientFactory clientFactory = new NettyClientFactory(conf);
    clientFactory.init();
    ConnectionId connectionId = ConnectionId.parseConnectionId("127.0.0.1", 8086);
    this.client = clientFactory.createClient(connectionId, clientHandler);
    Assert.assertTrue(this.client.active());
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Aggregations

TransportConf (com.baidu.hugegraph.computer.core.network.TransportConf)13 Test (org.junit.Test)11 ConnectionId (com.baidu.hugegraph.computer.core.network.ConnectionId)4 ClientFactory (com.baidu.hugegraph.computer.core.network.ClientFactory)1 TransportProvider (com.baidu.hugegraph.computer.core.network.TransportProvider)1 TransportServer (com.baidu.hugegraph.computer.core.network.TransportServer)1 InetAddress (java.net.InetAddress)1