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