Search in sources :

Example 6 with TransportConf

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());
    });
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Example 7 with TransportConf

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);
}
Also used : TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Example 8 with TransportConf

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());
}
Also used : TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Example 9 with TransportConf

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());
}
Also used : InetAddress(java.net.InetAddress) TransportConf(com.baidu.hugegraph.computer.core.network.TransportConf) Test(org.junit.Test)

Example 10 with TransportConf

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