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