Search in sources :

Example 6 with PartitionStat

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

the class EtcdBspTest method testInput.

@Test
public void testInput() throws InterruptedException {
    // If both two threads reach countDown, it means no exception is thrown.
    WorkerStat workerStat = new WorkerStat();
    workerStat.add(new PartitionStat(0, 100L, 200L, 0L));
    workerStat.add(new PartitionStat(1, 200L, 300L, 0L));
    CountDownLatch countDownLatch = new CountDownLatch(2);
    this.executorService.submit(() -> {
        this.bsp4Master.masterResumeDone(-1);
        this.bsp4Master.waitWorkersInputDone();
        this.bsp4Master.masterInputDone();
        List<WorkerStat> workerStats = this.bsp4Master.waitWorkersStepDone(-1);
        Assert.assertEquals(1, workerStats.size());
        Assert.assertEquals(workerStat, workerStats.get(0));
        countDownLatch.countDown();
    });
    this.executorService.submit(() -> {
        int firstSuperStep = this.bsp4Worker.waitMasterResumeDone();
        Assert.assertEquals(-1, firstSuperStep);
        this.bsp4Worker.workerInputDone();
        this.bsp4Worker.waitMasterInputDone();
        this.bsp4Worker.workerStepDone(-1, workerStat);
        countDownLatch.countDown();
    });
    countDownLatch.await();
}
Also used : PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) WorkerStat(com.baidu.hugegraph.computer.core.worker.WorkerStat) CountDownLatch(java.util.concurrent.CountDownLatch) Test(org.junit.Test)

Example 7 with PartitionStat

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

the class SuperstepStatTest method testReadWrite.

@Test
public void testReadWrite() throws IOException {
    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 stat1ReadObj = new SuperstepStat();
    UnitTestBase.assertEqualAfterWriteAndRead(stat1, stat1ReadObj);
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) Test(org.junit.Test)

Example 8 with PartitionStat

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

the class SuperstepStatTest method testToString.

@Test
public void testToString() {
    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);
    String str = "SuperstepStat{\"vertexCount\":4,\"edgeCount\":3,\"" + "finishedVertexCount\":2,\"messageSendCount\":5,\"" + "messageSendBytes\":6,\"messageRecvCount\":7,\"" + "messageRecvBytes\":8,\"active\":true}";
    Assert.assertEquals(str, stat.toString());
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) Test(org.junit.Test)

Example 9 with PartitionStat

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

the class WorkerStat method read.

@Override
public void read(RandomAccessInput in) throws IOException {
    this.workerId = in.readInt();
    int size = in.readInt();
    this.partitionStats = new ArrayList<>(size);
    for (int i = 0; i < size; i++) {
        PartitionStat stat = new PartitionStat();
        stat.read(in);
        this.partitionStats.add(stat);
    }
}
Also used : PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat)

Example 10 with PartitionStat

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

the class WorkerStat method write.

@Override
public void write(RandomAccessOutput out) throws IOException {
    out.writeInt(this.workerId);
    out.writeInt(this.partitionStats.size());
    for (PartitionStat stat : this.partitionStats) {
        stat.write(out);
    }
}
Also used : PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat)

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