Search in sources :

Example 16 with PartitionStat

use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.

the class SuperstepStatTest method testActive.

@Test
public void testActive() {
    SuperstepStat stat = new SuperstepStat();
    PartitionStat partitionStat = new PartitionStat(1, 4L, 3L, 2L);
    partitionStat.mergeSendMessageStat(new MessageStat(5L, 6L));
    partitionStat.mergeRecvMessageStat(new MessageStat(7L, 8L));
    stat.increase(partitionStat);
    stat.increase(partitionStat);
    Assert.assertTrue(stat.active());
    stat.inactivate();
    Assert.assertFalse(stat.active());
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) Test(org.junit.Test)

Example 17 with PartitionStat

use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.

the class SuperstepStatTest method testHashCode.

@Test
public void testHashCode() {
    SuperstepStat stat1 = new SuperstepStat();
    PartitionStat partitionStat = new PartitionStat(1, 4L, 3L, 2L);
    partitionStat.mergeSendMessageStat(new MessageStat(5L, 6L));
    partitionStat.mergeRecvMessageStat(new MessageStat(7L, 8L));
    stat1.increase(partitionStat);
    stat1.increase(partitionStat);
    SuperstepStat stat2 = new SuperstepStat();
    stat2.increase(partitionStat);
    stat2.increase(partitionStat);
    SuperstepStat stat3 = new SuperstepStat();
    Assert.assertEquals(stat1.hashCode(), stat2.hashCode());
    Assert.assertNotEquals(stat1.hashCode(), stat3.hashCode());
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) Test(org.junit.Test)

Example 18 with PartitionStat

use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.

the class SuperstepStatTest method testIncreaseWorkerStat.

@Test
public void testIncreaseWorkerStat() {
    SuperstepStat stat = new SuperstepStat();
    PartitionStat partitionStat1 = new PartitionStat(1, 4L, 3L, 2L);
    partitionStat1.mergeSendMessageStat(new MessageStat(5L, 6L));
    partitionStat1.mergeRecvMessageStat(new MessageStat(7L, 8L));
    PartitionStat partitionStat2 = new PartitionStat(2, 14L, 13L, 12L);
    partitionStat2.mergeSendMessageStat(new MessageStat(15L, 16L));
    partitionStat2.mergeRecvMessageStat(new MessageStat(17L, 18L));
    WorkerStat workerStat = new WorkerStat();
    workerStat.add(partitionStat1);
    workerStat.add(partitionStat2);
    stat.increase(workerStat);
    Assert.assertEquals(18, stat.vertexCount());
    Assert.assertEquals(16, stat.edgeCount());
    Assert.assertEquals(14L, stat.finishedVertexCount());
    Assert.assertEquals(20L, stat.messageSendCount());
    Assert.assertEquals(22L, stat.messageSendBytes());
    Assert.assertEquals(24L, stat.messageRecvCount());
    Assert.assertEquals(26L, stat.messageRecvBytes());
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) WorkerStat(com.baidu.hugegraph.computer.core.worker.WorkerStat) Test(org.junit.Test)

Example 19 with PartitionStat

use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.

the class SuperstepStatTest method testIncreasePartitionStat.

@Test
public void testIncreasePartitionStat() {
    SuperstepStat stat = new SuperstepStat();
    PartitionStat partitionStat = new PartitionStat(1, 4L, 3L, 2L);
    partitionStat.mergeSendMessageStat(new MessageStat(5L, 6L));
    partitionStat.mergeRecvMessageStat(new MessageStat(7L, 8L));
    stat.increase(partitionStat);
    stat.increase(partitionStat);
    Assert.assertEquals(partitionStat.vertexCount() * 2L, stat.vertexCount());
    Assert.assertEquals(partitionStat.edgeCount() * 2L, stat.edgeCount());
    Assert.assertEquals(partitionStat.finishedVertexCount() * 2L, stat.finishedVertexCount());
    Assert.assertEquals(partitionStat.messageSendCount() * 2L, stat.messageSendCount());
    Assert.assertEquals(partitionStat.messageSendBytes() * 2L, stat.messageSendBytes());
    Assert.assertEquals(partitionStat.messageRecvCount() * 2L, stat.messageRecvCount());
    Assert.assertEquals(partitionStat.messageRecvBytes() * 2L, stat.messageRecvBytes());
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) Test(org.junit.Test)

Example 20 with PartitionStat

use of com.baidu.hugegraph.computer.core.graph.partition.PartitionStat in project hugegraph-computer by hugegraph.

the class ComputeManager method compute.

public WorkerStat compute(WorkerContext context, int superstep) {
    this.sendManager.startSend(MessageType.MSG);
    WorkerStat workerStat = new WorkerStat();
    Map<Integer, PartitionStat> stats = new ConcurrentHashMap<>();
    /*
         * Remark: The main thread can perceive the partition compute exception
         * only after all partition compute completed, and only record the last
         * exception.
         */
    Consumers<FileGraphPartition> consumers = new Consumers<>(this.computeExecutor, partition -> {
        PartitionStat stat = partition.compute(context, superstep);
        stats.put(stat.partitionId(), stat);
    });
    consumers.start("partition-compute");
    try {
        for (FileGraphPartition partition : this.partitions.values()) {
            consumers.provide(partition);
        }
        consumers.await();
    } catch (Throwable t) {
        throw new ComputerException("An exception occurred when " + "partition parallel compute", t);
    }
    this.sendManager.finishSend(MessageType.MSG);
    // After compute and send finish signal.
    Map<Integer, MessageStat> recvStats = this.recvManager.messageStats();
    for (Map.Entry<Integer, PartitionStat> entry : stats.entrySet()) {
        PartitionStat partStat = entry.getValue();
        int partitionId = partStat.partitionId();
        MessageStat sendStat = this.sendManager.messageStat(partitionId);
        partStat.mergeSendMessageStat(sendStat);
        MessageStat recvStat = recvStats.get(partitionId);
        if (recvStat != null) {
            partStat.mergeRecvMessageStat(recvStat);
        }
        workerStat.add(partStat);
    }
    return workerStat;
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) Consumers(com.baidu.hugegraph.computer.core.util.Consumers) ComputerException(com.baidu.hugegraph.computer.core.common.exception.ComputerException) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) WorkerStat(com.baidu.hugegraph.computer.core.worker.WorkerStat) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) HashMap(java.util.HashMap) Map(java.util.Map)

Aggregations

PartitionStat (com.baidu.hugegraph.computer.core.graph.partition.PartitionStat)24 Test (org.junit.Test)15 MessageStat (com.baidu.hugegraph.computer.core.receiver.MessageStat)10 WorkerStat (com.baidu.hugegraph.computer.core.worker.WorkerStat)6 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)5 IOException (java.io.IOException)3 HashMap (java.util.HashMap)3 Map (java.util.Map)3 KvEntry (com.baidu.hugegraph.computer.core.store.entry.KvEntry)2 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)2 CountDownLatch (java.util.concurrent.CountDownLatch)2 SuperstepStat (com.baidu.hugegraph.computer.core.graph.SuperstepStat)1 Edges (com.baidu.hugegraph.computer.core.graph.edge.Edges)1 Value (com.baidu.hugegraph.computer.core.graph.value.Value)1 Vertex (com.baidu.hugegraph.computer.core.graph.vertex.Vertex)1 BufferedFileOutput (com.baidu.hugegraph.computer.core.io.BufferedFileOutput)1 ComputerOutput (com.baidu.hugegraph.computer.core.output.ComputerOutput)1 PeekableIterator (com.baidu.hugegraph.computer.core.sort.flusher.PeekableIterator)1 Pointer (com.baidu.hugegraph.computer.core.store.entry.Pointer)1 Consumers (com.baidu.hugegraph.computer.core.util.Consumers)1