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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations