Search in sources :

Example 16 with ConnectionId

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

the class MessageRecvManagerTest method setup.

@Before
public void setup() {
    this.config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.JOB_ID, "local_001", ComputerOptions.JOB_WORKERS_COUNT, "1", ComputerOptions.BSP_MAX_SUPER_STEP, "1", ComputerOptions.WORKER_COMBINER_CLASS, DoubleValueSumCombiner.class.getName(), ComputerOptions.WORKER_DATA_DIRS, "[data_dir1, data_dir2]", ComputerOptions.WORKER_RECEIVED_BUFFERS_BYTES_LIMIT, "100", ComputerOptions.WORKER_WAIT_FINISH_MESSAGES_TIMEOUT, "100", ComputerOptions.ALGORITHM_MESSAGE_CLASS, DoubleValue.class.getName(), ComputerOptions.TRANSPORT_RECV_FILE_MODE, "false");
    this.fileManager = new FileManager();
    this.fileManager.init(this.config);
    this.sortManager = new RecvSortManager(context());
    this.sortManager.init(this.config);
    this.receiveManager = new MessageRecvManager(context(), this.fileManager, this.sortManager);
    this.receiveManager.init(this.config);
    this.connectionId = new ConnectionId(new InetSocketAddress("localhost", 8081), 0);
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) InetSocketAddress(java.net.InetSocketAddress) FileManager(com.baidu.hugegraph.computer.core.store.FileManager) RecvSortManager(com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager) Before(org.junit.Before)

Example 17 with ConnectionId

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

Example 18 with ConnectionId

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

the class ConnectionManagerTest method testCloseClient.

@Test
public void testCloseClient() throws IOException {
    ConnectionId connectionId = ConnectionId.parseConnectionId("127.0.0.1", port);
    TransportClient client = connectionManager.getOrCreateClient(connectionId);
    Assert.assertTrue(client.active());
    connectionManager.closeClient(client.connectionId());
    Assert.assertFalse(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 19 with ConnectionId

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

the class ConnectionManagerTest method testGetClientWithNoInit.

@Test
public void testGetClientWithNoInit() {
    ConnectionManager connectionManager1 = new TransportConnectionManager();
    ConnectionId connectionId = ConnectionId.parseConnectionId("127.0.0.1", port);
    Assert.assertThrows(IllegalArgumentException.class, () -> {
        connectionManager1.getOrCreateClient(connectionId);
    }, e -> {
        Assert.assertContains("has not been initialized yet", e.getMessage());
    });
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) Test(org.junit.Test)

Example 20 with ConnectionId

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

the class TransportConnectionManager method getOrCreateClient.

@Override
public TransportClient getOrCreateClient(String host, int port) throws TransportException {
    E.checkArgument(this.clientFactory != null, "The clientManager has not been initialized yet");
    ConnectionId connectionId = ConnectionId.parseConnectionId(host, port);
    return this.getOrCreateClient(connectionId);
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId)

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