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());
}
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());
}
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());
}
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());
}
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;
}
Aggregations