1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.graph; |
20 | |
|
21 | |
import java.io.DataInput; |
22 | |
import java.io.DataOutput; |
23 | |
import java.io.IOException; |
24 | |
|
25 | |
import org.apache.giraph.graph.partition.PartitionStats; |
26 | |
import org.apache.hadoop.io.Writable; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | 436 | public class GlobalStats implements Writable { |
32 | |
|
33 | 436 | private long vertexCount = 0; |
34 | |
|
35 | 436 | private long finishedVertexCount = 0; |
36 | |
|
37 | 436 | private long edgeCount = 0; |
38 | |
|
39 | 436 | private long messageCount = 0; |
40 | |
|
41 | 436 | private boolean haltComputation = false; |
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
public void addPartitionStats(PartitionStats partitionStats) { |
49 | 218 | this.vertexCount += partitionStats.getVertexCount(); |
50 | 218 | this.finishedVertexCount += partitionStats.getFinishedVertexCount(); |
51 | 218 | this.edgeCount += partitionStats.getEdgeCount(); |
52 | 218 | } |
53 | |
|
54 | |
public long getVertexCount() { |
55 | 653 | return vertexCount; |
56 | |
} |
57 | |
|
58 | |
public long getFinishedVertexCount() { |
59 | 435 | return finishedVertexCount; |
60 | |
} |
61 | |
|
62 | |
public long getEdgeCount() { |
63 | 436 | return edgeCount; |
64 | |
} |
65 | |
|
66 | |
public long getMessageCount() { |
67 | 255 | return messageCount; |
68 | |
} |
69 | |
|
70 | |
public boolean getHaltComputation() { |
71 | 436 | return haltComputation; |
72 | |
} |
73 | |
|
74 | |
public void setHaltComputation(boolean value) { |
75 | 24 | haltComputation = value; |
76 | 24 | } |
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
public void addMessageCount(long messageCount) { |
84 | 218 | this.messageCount += messageCount; |
85 | 218 | } |
86 | |
|
87 | |
@Override |
88 | |
public void readFields(DataInput input) throws IOException { |
89 | 218 | vertexCount = input.readLong(); |
90 | 218 | finishedVertexCount = input.readLong(); |
91 | 218 | edgeCount = input.readLong(); |
92 | 218 | messageCount = input.readLong(); |
93 | 218 | haltComputation = input.readBoolean(); |
94 | 218 | } |
95 | |
|
96 | |
@Override |
97 | |
public void write(DataOutput output) throws IOException { |
98 | 218 | output.writeLong(vertexCount); |
99 | 218 | output.writeLong(finishedVertexCount); |
100 | 218 | output.writeLong(edgeCount); |
101 | 218 | output.writeLong(messageCount); |
102 | 218 | output.writeBoolean(haltComputation); |
103 | 218 | } |
104 | |
|
105 | |
@Override |
106 | |
public String toString() { |
107 | 436 | return "(vtx=" + vertexCount + ",finVtx=" + |
108 | |
finishedVertexCount + ",edges=" + edgeCount + ",msgCount=" + |
109 | |
messageCount + ",haltComputation=" + haltComputation + ")"; |
110 | |
} |
111 | |
} |