use of com.baidu.hugegraph.computer.core.network.TransportConf in project hugegraph-computer by hugegraph.
the class NettyClientFactoryTest method testCreateClientWithNoInit.
@Test
public void testCreateClientWithNoInit() {
TransportConf conf = TransportConf.wrapConfig(config);
NettyClientFactory clientFactory = new NettyClientFactory(conf);
ConnectionId connectionId = ConnectionId.parseConnectionId("127.0.0.1", 7777);
Assert.assertThrows(IllegalArgumentException.class, () -> {
this.client = clientFactory.createClient(connectionId, clientHandler);
}, e -> {
Assert.assertContains("has not been initialized yet", e.getMessage());
});
}
use of com.baidu.hugegraph.computer.core.network.TransportConf in project hugegraph-computer by hugegraph.
the class NettyTransportClientTest method testCheckMinPendingRequests.
@Test
public void testCheckMinPendingRequests() {
UnitTestBase.updateWithRequiredOptions(ComputerOptions.TRANSPORT_MAX_PENDING_REQUESTS, "100", ComputerOptions.TRANSPORT_MIN_PENDING_REQUESTS, "101");
config = ComputerContext.instance().config();
TransportConf conf = TransportConf.wrapConfig(config);
Assert.assertThrows(IllegalArgumentException.class, conf::minPendingRequests);
}
use of com.baidu.hugegraph.computer.core.network.TransportConf in project hugegraph-computer by hugegraph.
the class NettyTransportServerTest method testListenWithAssignPort.
@Test
public void testListenWithAssignPort() {
config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.TRANSPORT_SERVER_HOST, "127.0.0.1", ComputerOptions.TRANSPORT_SERVER_PORT, "9091");
int port = this.server.listen(config, messageHandler);
TransportConf conf = this.server.conf();
Assert.assertEquals("127.0.0.1", conf.serverAddress().getHostAddress());
Assert.assertEquals(9091, this.server.port());
Assert.assertEquals(9091, port);
String ip = this.server.bindAddress().getAddress().getHostAddress();
Assert.assertEquals("127.0.0.1", 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 testListenWithLocalAddress.
@Test
public void testListenWithLocalAddress() throws UnknownHostException {
InetAddress localHost = InetAddress.getLocalHost();
String hostName = localHost.getHostName();
String ip = InetAddress.getLocalHost().getHostAddress();
config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.TRANSPORT_SERVER_HOST, hostName);
int port = this.server.listen(config, messageHandler);
TransportConf conf = this.server.conf();
Assert.assertEquals(hostName, conf.serverAddress().getHostName());
Assert.assertNotEquals(0, this.server.port());
Assert.assertNotEquals(0, port);
Assert.assertEquals(ip, 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 NettyClientFactoryTest method testCreateClientWithErrorSocket.
@Test
public void testCreateClientWithErrorSocket() {
TransportConf conf = TransportConf.wrapConfig(config);
NettyClientFactory clientFactory = new NettyClientFactory(conf);
clientFactory.init();
ConnectionId connectionId = ConnectionId.parseConnectionId("127.0.0.1", 7777);
Assert.assertThrows(IOException.class, () -> {
this.client = clientFactory.createClient(connectionId, clientHandler);
}, e -> {
Assert.assertContains("Failed to create connection", e.getMessage());
});
}
Aggregations