Search in sources :

Example 6 with MessageStat

use of com.baidu.hugegraph.computer.core.receiver.MessageStat 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 7 with MessageStat

use of com.baidu.hugegraph.computer.core.receiver.MessageStat 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 8 with MessageStat

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

the class PartitionStatTest method testHashCode.

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

Example 9 with MessageStat

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

the class PartitionStatTest method testConstructor.

@Test
public void testConstructor() {
    PartitionStat stat1 = new PartitionStat();
    Assert.assertEquals(0, stat1.partitionId());
    Assert.assertEquals(0L, stat1.vertexCount());
    Assert.assertEquals(0L, stat1.edgeCount());
    Assert.assertEquals(0L, stat1.finishedVertexCount());
    Assert.assertEquals(0L, stat1.messageSendCount());
    Assert.assertEquals(0L, stat1.messageSendBytes());
    Assert.assertEquals(0L, stat1.messageRecvCount());
    Assert.assertEquals(0L, stat1.messageRecvBytes());
    PartitionStat stat2 = new PartitionStat(1, 4L, 3L, 2L);
    stat2.mergeSendMessageStat(new MessageStat(5L, 6L));
    stat2.mergeRecvMessageStat(new MessageStat(7L, 8L));
    Assert.assertEquals(1, stat2.partitionId());
    Assert.assertEquals(4L, stat2.vertexCount());
    Assert.assertEquals(3L, stat2.edgeCount());
    Assert.assertEquals(2L, stat2.finishedVertexCount());
    Assert.assertEquals(5L, stat2.messageSendCount());
    Assert.assertEquals(6L, stat2.messageSendBytes());
    Assert.assertEquals(7L, stat2.messageRecvCount());
    Assert.assertEquals(8L, stat2.messageRecvBytes());
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) Test(org.junit.Test)

Example 10 with MessageStat

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

the class WorkerStatTest method testToString.

@Test
public void testToString() {
    PartitionStat stat1 = new PartitionStat(0, 1L, 2L, 0L);
    PartitionStat stat2 = new PartitionStat(1, 4L, 3L, 2L);
    stat2.mergeSendMessageStat(new MessageStat(5L, 6L));
    stat2.mergeRecvMessageStat(new MessageStat(7L, 8L));
    WorkerStat workerStat = new WorkerStat();
    workerStat.add(stat1);
    workerStat.add(stat2);
    String str = "WorkerStat{\"workerId\":0," + "\"partitionStats\":[{\"partitionId\":0," + "\"vertexCount\":1,\"edgeCount\":2,\"" + "finishedVertexCount\":0," + "\"messageSendCount\":0,\"messageSendBytes\":0," + "\"messageRecvCount\":0,\"messageRecvBytes\":0}," + "{\"partitionId\":1,\"vertexCount\":4," + "\"edgeCount\":3,\"finishedVertexCount\":2," + "\"messageSendCount\":5,\"messageSendBytes\":6," + "\"messageRecvCount\":7,\"messageRecvBytes\":8}]}";
    Assert.assertEquals(str, workerStat.toString());
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) Test(org.junit.Test)

Aggregations

MessageStat (com.baidu.hugegraph.computer.core.receiver.MessageStat)19 Test (org.junit.Test)14 PartitionStat (com.baidu.hugegraph.computer.core.graph.partition.PartitionStat)10 Map (java.util.Map)4 ComputerException (com.baidu.hugegraph.computer.core.common.exception.ComputerException)3 WorkerStat (com.baidu.hugegraph.computer.core.worker.WorkerStat)3 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 CompletableFuture (java.util.concurrent.CompletableFuture)2 ExecutionException (java.util.concurrent.ExecutionException)2 Future (java.util.concurrent.Future)2 TimeoutException (java.util.concurrent.TimeoutException)2 Consumers (com.baidu.hugegraph.computer.core.util.Consumers)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1