Search in sources :

Example 1 with ConnectionId

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

the class NettyServerHandler method exceptionCaught.

@Override
public void exceptionCaught(ChannelHandlerContext ctx, Throwable cause) {
    TransportException exception;
    Channel channel = ctx.channel();
    if (cause instanceof TransportException) {
        exception = (TransportException) cause;
    } else {
        exception = new TransportException("%s when the server receive data from '%s'", cause, cause.getMessage(), TransportUtil.remoteAddress(channel));
    }
    ConnectionId connectionId = TransportUtil.remoteConnectionId(channel);
    this.handler.exceptionCaught(exception, connectionId);
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) Channel(io.netty.channel.Channel) SocketChannel(io.netty.channel.socket.SocketChannel) TransportException(com.baidu.hugegraph.computer.core.common.exception.TransportException)

Example 2 with ConnectionId

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

the class NettyServerHandler method channelInactive.

@Override
public void channelInactive(ChannelHandlerContext ctx) throws Exception {
    Channel channel = ctx.channel();
    ConnectionId connectionId = TransportUtil.remoteConnectionId(channel);
    this.handler.onChannelInactive(connectionId);
    super.channelInactive(ctx);
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) Channel(io.netty.channel.Channel) SocketChannel(io.netty.channel.socket.SocketChannel)

Example 3 with ConnectionId

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

the class NettyServerHandler method channelActive.

@Override
public void channelActive(ChannelHandlerContext ctx) throws Exception {
    Channel channel = ctx.channel();
    ConnectionId connectionId = TransportUtil.remoteConnectionId(channel);
    this.handler.onChannelActive(connectionId);
    super.channelActive(ctx);
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) Channel(io.netty.channel.Channel) SocketChannel(io.netty.channel.socket.SocketChannel)

Example 4 with ConnectionId

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

the class TransportConnectionManager method shutdownClients.

@Override
public void shutdownClients() {
    if (this.clientFactory != null) {
        this.clientFactory.close();
        this.clientFactory = null;
    }
    if (!this.clients.isEmpty()) {
        Iterator<Map.Entry<ConnectionId, TransportClient>> iterator = this.clients.entrySet().iterator();
        while (iterator.hasNext()) {
            Map.Entry<ConnectionId, TransportClient> next = iterator.next();
            TransportClient client = next.getValue();
            if (client != null) {
                client.close();
            }
            iterator.remove();
        }
    }
}
Also used : ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) TransportClient(com.baidu.hugegraph.computer.core.network.TransportClient) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) Map(java.util.Map)

Example 5 with ConnectionId

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

the class ComputeManagerTest method setup.

@Before
public void setup() {
    this.config = UnitTestBase.updateWithRequiredOptions(ComputerOptions.JOB_ID, "local_001", ComputerOptions.JOB_WORKERS_COUNT, "1", ComputerOptions.JOB_PARTITIONS_COUNT, "2", ComputerOptions.BSP_MAX_SUPER_STEP, "2", ComputerOptions.WORKER_COMBINER_CLASS, // Can't combine
    Null.class.getName(), ComputerOptions.ALGORITHM_RESULT_CLASS, IdListList.class.getName(), ComputerOptions.ALGORITHM_MESSAGE_CLASS, IdList.class.getName(), ComputerOptions.WORKER_DATA_DIRS, "[data_dir1, data_dir2]", ComputerOptions.WORKER_RECEIVED_BUFFERS_BYTES_LIMIT, "10000", ComputerOptions.WORKER_WAIT_FINISH_MESSAGES_TIMEOUT, "1000", ComputerOptions.INPUT_MAX_EDGES_IN_ONE_VERTEX, "10", ComputerOptions.WORKER_COMPUTATION_CLASS, MockComputation.class.getName(), ComputerOptions.INPUT_EDGE_FREQ, "SINGLE", ComputerOptions.TRANSPORT_RECV_FILE_MODE, "false");
    this.managers = new Managers();
    FileManager fileManager = new FileManager();
    this.managers.add(fileManager);
    SortManager sortManager = new SendSortManager(context());
    this.managers.add(sortManager);
    MessageSendManager sendManager = new MessageSendManager(context(), sortManager, new MockMessageSender());
    this.managers.add(sendManager);
    MessageRecvManager receiveManager = new MessageRecvManager(context(), fileManager, sortManager);
    this.managers.add(receiveManager);
    this.managers.initAll(this.config);
    this.connectionId = new ConnectionId(new InetSocketAddress("localhost", 8081), 0);
    this.computeManager = new ComputeManager(context(), this.managers);
}
Also used : SendSortManager(com.baidu.hugegraph.computer.core.sort.sorting.SendSortManager) MessageRecvManager(com.baidu.hugegraph.computer.core.receiver.MessageRecvManager) ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) Managers(com.baidu.hugegraph.computer.core.manager.Managers) InetSocketAddress(java.net.InetSocketAddress) MessageSendManager(com.baidu.hugegraph.computer.core.sender.MessageSendManager) FileManager(com.baidu.hugegraph.computer.core.store.FileManager) SortManager(com.baidu.hugegraph.computer.core.sort.sorting.SortManager) SendSortManager(com.baidu.hugegraph.computer.core.sort.sorting.SendSortManager) Before(org.junit.Before)

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