Search in sources :

Example 6 with MessageRecvManager

use of com.baidu.hugegraph.computer.core.receiver.MessageRecvManager in project hugegraph-computer by hugegraph.

the class MessageInputTest 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.TRANSPORT_RECV_FILE_MODE, "false");
    this.managers = new Managers();
    FileManager fileManager = new FileManager();
    this.managers.add(fileManager);
    SortManager sortManager = new RecvSortManager(context());
    this.managers.add(sortManager);
    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);
}
Also used : 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) 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) RecvSortManager(com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager) Before(org.junit.Before)

Example 7 with MessageRecvManager

use of com.baidu.hugegraph.computer.core.receiver.MessageRecvManager in project hugegraph-computer by hugegraph.

the class MessageInputTest method testMessageInput.

@Test
public void testMessageInput() throws IOException {
    MessageRecvManager receiveManager = this.managers.get(MessageRecvManager.NAME);
    receiveManager.onStarted(this.connectionId);
    // Superstep 0
    receiveManager.beforeSuperstep(this.config, 0);
    receiveManager.onStarted(this.connectionId);
    addMessages((NetworkBuffer buffer) -> {
        receiveManager.handle(MessageType.MSG, 0, buffer);
    });
    receiveManager.onFinished(this.connectionId);
    PeekableIterator<KvEntry> it = receiveManager.messagePartitions().get(0);
    MessageInput<IdList> input = new MessageInput<>(context(), it);
    Map<Id, List<IdList>> expectedMessages = expectedMessages();
    checkMessages(expectedMessages, input);
}
Also used : MessageRecvManager(com.baidu.hugegraph.computer.core.receiver.MessageRecvManager) KvEntry(com.baidu.hugegraph.computer.core.store.entry.KvEntry) NetworkBuffer(com.baidu.hugegraph.computer.core.network.buffer.NetworkBuffer) ArrayList(java.util.ArrayList) IdList(com.baidu.hugegraph.computer.core.graph.value.IdList) List(java.util.List) IdListList(com.baidu.hugegraph.computer.core.graph.value.IdListList) Id(com.baidu.hugegraph.computer.core.graph.id.Id) BytesId(com.baidu.hugegraph.computer.core.graph.id.BytesId) ConnectionId(com.baidu.hugegraph.computer.core.network.ConnectionId) IdList(com.baidu.hugegraph.computer.core.graph.value.IdList) Test(org.junit.Test)

Aggregations

MessageRecvManager (com.baidu.hugegraph.computer.core.receiver.MessageRecvManager)7 SortManager (com.baidu.hugegraph.computer.core.sort.sorting.SortManager)5 FileManager (com.baidu.hugegraph.computer.core.store.FileManager)5 InetSocketAddress (java.net.InetSocketAddress)5 ConnectionId (com.baidu.hugegraph.computer.core.network.ConnectionId)4 Managers (com.baidu.hugegraph.computer.core.manager.Managers)3 NetworkBuffer (com.baidu.hugegraph.computer.core.network.buffer.NetworkBuffer)3 MessageSendManager (com.baidu.hugegraph.computer.core.sender.MessageSendManager)3 RecvSortManager (com.baidu.hugegraph.computer.core.sort.sorting.RecvSortManager)3 SendSortManager (com.baidu.hugegraph.computer.core.sort.sorting.SendSortManager)3 Test (org.junit.Test)3 ConnectionManager (com.baidu.hugegraph.computer.core.network.connection.ConnectionManager)2 TransportConnectionManager (com.baidu.hugegraph.computer.core.network.connection.TransportConnectionManager)2 Before (org.junit.Before)2 WorkerAggrManager (com.baidu.hugegraph.computer.core.aggregator.WorkerAggrManager)1 TransportException (com.baidu.hugegraph.computer.core.common.exception.TransportException)1 FileGraphPartition (com.baidu.hugegraph.computer.core.compute.FileGraphPartition)1 MockMessageSender (com.baidu.hugegraph.computer.core.compute.MockMessageSender)1 Config (com.baidu.hugegraph.computer.core.config.Config)1 BytesId (com.baidu.hugegraph.computer.core.graph.id.BytesId)1