Search in sources :

Example 6 with ConnectionId

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

the class ConnectionManagerTest method testShutDown.

@Test
public void testShutDown() throws IOException {
    ConnectionId connectionId = ConnectionId.parseConnectionId("127.0.0.1", port);
    TransportClient client = connectionManager.getOrCreateClient(connectionId);
    Assert.assertTrue(client.active());
    connectionManager.shutdownClients();
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        connectionManager.getOrCreateClient(connectionId);
    }, e -> {
        Assert.assertContains("has not been initialized yet", e.getMessage());
    });
    connectionManager.shutdownServer();
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        connectionManager.getServer();
    }, e -> {
        Assert.assertContains("has not been initialized yet", e.getMessage());
    });
    connectionManager.shutdown();
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportClient(com.baidu.hugegraph.computer.core.network.TransportClient) Test(org.junit.Test)

Example 7 with ConnectionId

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

the class ConnectionManagerTest method testGetOrCreateClient.

@Test
public void testGetOrCreateClient() throws IOException {
    ConnectionId connectionId = ConnectionId.parseConnectionId("127.0.0.1", port);
    TransportClient client = connectionManager.getOrCreateClient(connectionId);
    Assert.assertTrue(client.active());
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportClient(com.baidu.hugegraph.computer.core.network.TransportClient) Test(org.junit.Test)

Example 8 with ConnectionId

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

the class AbstractNetworkTest method oneClient.

protected TransportClient oneClient() throws IOException {
    ConnectionId connectionId = ConnectionId.parseConnectionId(host, port);
    TransportClient client = connectionManager.getOrCreateClient(connectionId);
    Assert.assertTrue(client.active());
    return client;
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportClient(com.baidu.hugegraph.computer.core.network.TransportClient)

Example 9 with ConnectionId

use of com.baidu.hugegraph.computer.core.network.ConnectionId 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 10 with ConnectionId

use of com.baidu.hugegraph.computer.core.network.ConnectionId 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

ConnectionId (com.baidu.hugegraph.computer.core.network.ConnectionId)22 Test (org.junit.Test)10 TransportClient (com.baidu.hugegraph.computer.core.network.TransportClient)5 InetSocketAddress (java.net.InetSocketAddress)5 TransportConf (com.baidu.hugegraph.computer.core.network.TransportConf)4 FileManager (com.baidu.hugegraph.computer.core.store.FileManager)4 TransportException (com.baidu.hugegraph.computer.core.common.exception.TransportException)3 Managers (com.baidu.hugegraph.computer.core.manager.Managers)3 MessageRecvManager (com.baidu.hugegraph.computer.core.receiver.MessageRecvManager)3 SortManager (com.baidu.hugegraph.computer.core.sort.sorting.SortManager)3 Channel (io.netty.channel.Channel)3 SocketChannel (io.netty.channel.socket.SocketChannel)3 Before (org.junit.Before)3 MessageSendManager (com.baidu.hugegraph.computer.core.sender.MessageSendManager)2 RecvSortManager (com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager)2 SendSortManager (com.baidu.hugegraph.computer.core.sort.sorting.SendSortManager)2 FileGraphPartition (com.baidu.hugegraph.computer.core.compute.FileGraphPartition)1 MockMessageSender (com.baidu.hugegraph.computer.core.compute.MockMessageSender)1 NetworkBuffer (com.baidu.hugegraph.computer.core.network.buffer.NetworkBuffer)1 File (java.io.File)1