Search in sources :

Example 1 with ConnectionManager

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

the class WorkerService method initManagers.

private InetSocketAddress initManagers(ContainerInfo masterInfo) {
    // Create managers
    WorkerRpcManager rpcManager = new WorkerRpcManager();
    this.managers.add(rpcManager);
    /*
         * NOTE: this init() method will be called twice, will be ignored at
         * the 2nd time call.
         */
    WorkerRpcManager.updateRpcRemoteServerConfig(this.config, masterInfo.hostname(), masterInfo.rpcPort());
    rpcManager.init(this.config);
    WorkerAggrManager aggregatorManager = new WorkerAggrManager(this.context);
    aggregatorManager.service(rpcManager.aggregateRpcService());
    this.managers.add(aggregatorManager);
    FileManager fileManager = new FileManager();
    this.managers.add(fileManager);
    SortManager recvSortManager = new RecvSortManager(this.context);
    this.managers.add(recvSortManager);
    MessageRecvManager recvManager = new MessageRecvManager(this.context, fileManager, recvSortManager);
    this.managers.add(recvManager);
    ConnectionManager connManager = new TransportConnectionManager();
    DataServerManager serverManager = new DataServerManager(connManager, recvManager);
    this.managers.add(serverManager);
    DataClientManager clientManager = new DataClientManager(connManager, this.context);
    this.managers.add(clientManager);
    SortManager sendSortManager = new SendSortManager(this.context);
    this.managers.add(sendSortManager);
    MessageSendManager sendManager = new MessageSendManager(this.context, sendSortManager, clientManager.sender());
    this.managers.add(sendManager);
    WorkerInputManager inputManager = new WorkerInputManager(this.context, sendManager);
    inputManager.service(rpcManager.inputSplitService());
    this.managers.add(inputManager);
    // Init all managers
    this.managers.initAll(this.config);
    InetSocketAddress address = serverManager.address();
    LOG.info("{} WorkerService initialized managers with data server " + "address '{}'", this, address);
    return address;
}
Also used : WorkerAggrManager(com.baidu.hugegraph.computer.core.aggregator.WorkerAggrManager) DataServerManager(com.baidu.hugegraph.computer.core.network.DataServerManager) InetSocketAddress(java.net.InetSocketAddress) MessageSendManager(com.baidu.hugegraph.computer.core.sender.MessageSendManager) FileManager(com.baidu.hugegraph.computer.core.store.FileManager) RecvSortManager(com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager) SortManager(com.baidu.hugegraph.computer.core.sort.sorting.SortManager) SendSortManager(com.baidu.hugegraph.computer.core.sort.sorting.SendSortManager) WorkerRpcManager(com.baidu.hugegraph.computer.core.rpc.WorkerRpcManager) SendSortManager(com.baidu.hugegraph.computer.core.sort.sorting.SendSortManager) MessageRecvManager(com.baidu.hugegraph.computer.core.receiver.MessageRecvManager) TransportConnectionManager(com.baidu.hugegraph.computer.core.network.connection.TransportConnectionManager) ConnectionManager(com.baidu.hugegraph.computer.core.network.connection.ConnectionManager) DataClientManager(com.baidu.hugegraph.computer.core.network.DataClientManager) WorkerInputManager(com.baidu.hugegraph.computer.core.input.WorkerInputManager) RecvSortManager(com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager) TransportConnectionManager(com.baidu.hugegraph.computer.core.network.connection.TransportConnectionManager)

Example 2 with ConnectionManager

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

the class DataServerManagerTest method test.

@Test
public void test() {
    Config config = UnitTestBase.updateWithRequiredOptions(RpcOptions.RPC_REMOTE_URL, "127.0.0.1:8090", ComputerOptions.JOB_ID, "local_001", ComputerOptions.JOB_WORKERS_COUNT, "1", ComputerOptions.BSP_LOG_INTERVAL, "30000", ComputerOptions.BSP_MAX_SUPER_STEP, "2", ComputerOptions.WORKER_COMPUTATION_CLASS, MockComputation.class.getName(), ComputerOptions.MASTER_COMPUTATION_CLASS, MockMasterComputation.class.getName());
    FileManager fileManager = new FileManager();
    fileManager.init(config);
    SortManager sortManager = new RecvSortManager(context());
    sortManager.init(config);
    MessageRecvManager recvManager = new MessageRecvManager(context(), fileManager, sortManager);
    recvManager.init(config);
    ConnectionManager connManager = new TransportConnectionManager();
    DataServerManager serverManager = new DataServerManager(connManager, recvManager);
    serverManager.init(config);
    Assert.assertEquals(DataServerManager.NAME, serverManager.name());
    InetSocketAddress address = serverManager.address();
    Assert.assertNotEquals(0, address.getPort());
    ConnectionId connectionId = ConnectionId.parseConnectionId(address.getHostName(), address.getPort());
    recvManager.onChannelActive(connectionId);
    recvManager.onChannelInactive(connectionId);
    TransportException e = new TransportException("test transport " + "exception");
    recvManager.exceptionCaught(e, connectionId);
    serverManager.close(config);
    fileManager.close(config);
    sortManager.close(config);
}
Also used : Config(com.baidu.hugegraph.computer.core.config.Config) InetSocketAddress(java.net.InetSocketAddress) MockMasterComputation(com.baidu.hugegraph.computer.core.worker.MockMasterComputation) TransportException(com.baidu.hugegraph.computer.core.common.exception.TransportException) FileManager(com.baidu.hugegraph.computer.core.store.FileManager) RecvSortManager(com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager) SortManager(com.baidu.hugegraph.computer.core.sort.sorting.SortManager) MessageRecvManager(com.baidu.hugegraph.computer.core.receiver.MessageRecvManager) ConnectionManager(com.baidu.hugegraph.computer.core.network.connection.ConnectionManager) TransportConnectionManager(com.baidu.hugegraph.computer.core.network.connection.TransportConnectionManager) MockComputation(com.baidu.hugegraph.computer.core.worker.MockComputation) RecvSortManager(com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager) TransportConnectionManager(com.baidu.hugegraph.computer.core.network.connection.TransportConnectionManager) Test(org.junit.Test)

Example 3 with ConnectionManager

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

the class SenderIntegrateTest method slowSendFunc.

private void slowSendFunc(WorkerService service) throws TransportException {
    Managers managers = Whitebox.getInternalState(service, "managers");
    DataClientManager clientManager = managers.get(DataClientManager.NAME);
    ConnectionManager connManager = Whitebox.getInternalState(clientManager, "connManager");
    NettyTransportClient client = (NettyTransportClient) connManager.getOrCreateClient("127.0.0.1", 8091);
    ClientSession clientSession = Whitebox.invoke(client.getClass(), "clientSession", client);
    Function<Message, Future<Void>> sendFuncBak = Whitebox.getInternalState(clientSession, "sendFunction");
    Function<Message, Future<Void>> sendFunc = message -> {
        try {
            Thread.sleep(100);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return sendFuncBak.apply(message);
    };
    Whitebox.setInternalState(clientSession, "sendFunction", sendFunc);
}
Also used : PageRankParams(com.baidu.hugegraph.computer.algorithm.centrality.pagerank.PageRankParams) ComputerOptions(com.baidu.hugegraph.computer.core.config.ComputerOptions) DoubleValue(com.baidu.hugegraph.computer.core.graph.value.DoubleValue) BeforeClass(org.junit.BeforeClass) Managers(com.baidu.hugegraph.computer.core.manager.Managers) RpcOptions(com.baidu.hugegraph.config.RpcOptions) Function(java.util.function.Function) MasterService(com.baidu.hugegraph.computer.core.master.MasterService) ArrayList(java.util.ArrayList) Future(java.util.concurrent.Future) Whitebox(com.baidu.hugegraph.testutil.Whitebox) TransportException(com.baidu.hugegraph.computer.core.common.exception.TransportException) ComputerContextUtil(com.baidu.hugegraph.computer.core.util.ComputerContextUtil) Message(com.baidu.hugegraph.computer.core.network.message.Message) AfterClass(org.junit.AfterClass) Logger(org.slf4j.Logger) ConnectionManager(com.baidu.hugegraph.computer.core.network.connection.ConnectionManager) Test(org.junit.Test) NettyTransportClient(com.baidu.hugegraph.computer.core.network.netty.NettyTransportClient) ClientSession(com.baidu.hugegraph.computer.core.network.session.ClientSession) Config(com.baidu.hugegraph.computer.core.config.Config) DataClientManager(com.baidu.hugegraph.computer.core.network.DataClientManager) List(java.util.List) Log(com.baidu.hugegraph.util.Log) WorkerService(com.baidu.hugegraph.computer.core.worker.WorkerService) Assert(com.baidu.hugegraph.testutil.Assert) ConnectionManager(com.baidu.hugegraph.computer.core.network.connection.ConnectionManager) Message(com.baidu.hugegraph.computer.core.network.message.Message) Managers(com.baidu.hugegraph.computer.core.manager.Managers) DataClientManager(com.baidu.hugegraph.computer.core.network.DataClientManager) NettyTransportClient(com.baidu.hugegraph.computer.core.network.netty.NettyTransportClient) ClientSession(com.baidu.hugegraph.computer.core.network.session.ClientSession) Future(java.util.concurrent.Future)

Aggregations

ConnectionManager (com.baidu.hugegraph.computer.core.network.connection.ConnectionManager)3 TransportException (com.baidu.hugegraph.computer.core.common.exception.TransportException)2 Config (com.baidu.hugegraph.computer.core.config.Config)2 DataClientManager (com.baidu.hugegraph.computer.core.network.DataClientManager)2 TransportConnectionManager (com.baidu.hugegraph.computer.core.network.connection.TransportConnectionManager)2 MessageRecvManager (com.baidu.hugegraph.computer.core.receiver.MessageRecvManager)2 RecvSortManager (com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager)2 SortManager (com.baidu.hugegraph.computer.core.sort.sorting.SortManager)2 FileManager (com.baidu.hugegraph.computer.core.store.FileManager)2 InetSocketAddress (java.net.InetSocketAddress)2 Test (org.junit.Test)2 PageRankParams (com.baidu.hugegraph.computer.algorithm.centrality.pagerank.PageRankParams)1 WorkerAggrManager (com.baidu.hugegraph.computer.core.aggregator.WorkerAggrManager)1 ComputerOptions (com.baidu.hugegraph.computer.core.config.ComputerOptions)1 DoubleValue (com.baidu.hugegraph.computer.core.graph.value.DoubleValue)1 WorkerInputManager (com.baidu.hugegraph.computer.core.input.WorkerInputManager)1 Managers (com.baidu.hugegraph.computer.core.manager.Managers)1 MasterService (com.baidu.hugegraph.computer.core.master.MasterService)1 DataServerManager (com.baidu.hugegraph.computer.core.network.DataServerManager)1 Message (com.baidu.hugegraph.computer.core.network.message.Message)1