Search in sources :

Example 11 with MessageStat

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

the class SuperstepStatTest method testEquals.

@Test
public void testEquals() {
    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, stat2);
    Assert.assertNotEquals(stat1, stat3);
    Assert.assertNotEquals(stat1, new Object());
    stat1.inactivate();
    Assert.assertFalse(stat1.active());
    Assert.assertNotEquals(stat1, stat2);
}
Also used : MessageStat(com.baidu.hugegraph.computer.core.receiver.MessageStat) PartitionStat(com.baidu.hugegraph.computer.core.graph.partition.PartitionStat) Test(org.junit.Test)

Example 12 with MessageStat

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

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

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

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

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