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.bsp.checkpoints.CheckpointStatus; |
26 | |
import org.apache.giraph.partition.PartitionStats; |
27 | |
import org.apache.hadoop.io.Writable; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | 0 | public class GlobalStats implements Writable { |
33 | |
|
34 | 0 | private long vertexCount = 0; |
35 | |
|
36 | 0 | private long finishedVertexCount = 0; |
37 | |
|
38 | 0 | private long edgeCount = 0; |
39 | |
|
40 | 0 | private long messageCount = 0; |
41 | |
|
42 | 0 | private long messageBytesCount = 0; |
43 | |
|
44 | 0 | private boolean haltComputation = false; |
45 | |
|
46 | 0 | private long oocStoreBytesCount = 0; |
47 | |
|
48 | 0 | private long oocLoadBytesCount = 0; |
49 | |
|
50 | 0 | private int lowestGraphPercentageInMemory = 100; |
51 | |
|
52 | |
|
53 | |
|
54 | |
|
55 | 0 | private CheckpointStatus checkpointStatus = |
56 | |
CheckpointStatus.NONE; |
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
public void addPartitionStats(PartitionStats partitionStats) { |
64 | 0 | this.vertexCount += partitionStats.getVertexCount(); |
65 | 0 | this.finishedVertexCount += partitionStats.getFinishedVertexCount(); |
66 | 0 | this.edgeCount += partitionStats.getEdgeCount(); |
67 | 0 | } |
68 | |
|
69 | |
public long getVertexCount() { |
70 | 0 | return vertexCount; |
71 | |
} |
72 | |
|
73 | |
public long getFinishedVertexCount() { |
74 | 0 | return finishedVertexCount; |
75 | |
} |
76 | |
|
77 | |
public long getEdgeCount() { |
78 | 0 | return edgeCount; |
79 | |
} |
80 | |
|
81 | |
public long getMessageCount() { |
82 | 0 | return messageCount; |
83 | |
} |
84 | |
|
85 | |
public long getMessageBytesCount() { |
86 | 0 | return messageBytesCount; |
87 | |
} |
88 | |
|
89 | |
public boolean getHaltComputation() { |
90 | 0 | return haltComputation; |
91 | |
} |
92 | |
|
93 | |
public void setHaltComputation(boolean value) { |
94 | 0 | haltComputation = value; |
95 | 0 | } |
96 | |
|
97 | |
public long getOocStoreBytesCount() { |
98 | 0 | return oocStoreBytesCount; |
99 | |
} |
100 | |
|
101 | |
public long getOocLoadBytesCount() { |
102 | 0 | return oocLoadBytesCount; |
103 | |
} |
104 | |
|
105 | |
public CheckpointStatus getCheckpointStatus() { |
106 | 0 | return checkpointStatus; |
107 | |
} |
108 | |
|
109 | |
public void setCheckpointStatus(CheckpointStatus checkpointStatus) { |
110 | 0 | this.checkpointStatus = checkpointStatus; |
111 | 0 | } |
112 | |
|
113 | |
public int getLowestGraphPercentageInMemory() { |
114 | 0 | return lowestGraphPercentageInMemory; |
115 | |
} |
116 | |
|
117 | |
public void setLowestGraphPercentageInMemory( |
118 | |
int lowestGraphPercentageInMemory) { |
119 | 0 | this.lowestGraphPercentageInMemory = lowestGraphPercentageInMemory; |
120 | 0 | } |
121 | |
|
122 | |
|
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
public void addOocLoadBytesCount(long oocLoadBytesCount) { |
128 | 0 | this.oocLoadBytesCount += oocLoadBytesCount; |
129 | 0 | } |
130 | |
|
131 | |
|
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
public void addOocStoreBytesCount(long oocStoreBytesCount) { |
137 | 0 | this.oocStoreBytesCount += oocStoreBytesCount; |
138 | 0 | } |
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
public void addMessageCount(long messageCount) { |
146 | 0 | this.messageCount += messageCount; |
147 | 0 | } |
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
public void addMessageBytesCount(long msgBytesCount) { |
155 | 0 | this.messageBytesCount += msgBytesCount; |
156 | 0 | } |
157 | |
|
158 | |
@Override |
159 | |
public void readFields(DataInput input) throws IOException { |
160 | 0 | vertexCount = input.readLong(); |
161 | 0 | finishedVertexCount = input.readLong(); |
162 | 0 | edgeCount = input.readLong(); |
163 | 0 | messageCount = input.readLong(); |
164 | 0 | messageBytesCount = input.readLong(); |
165 | 0 | oocLoadBytesCount = input.readLong(); |
166 | 0 | oocStoreBytesCount = input.readLong(); |
167 | 0 | lowestGraphPercentageInMemory = input.readInt(); |
168 | 0 | haltComputation = input.readBoolean(); |
169 | 0 | if (input.readBoolean()) { |
170 | 0 | checkpointStatus = CheckpointStatus.values()[input.readInt()]; |
171 | |
} else { |
172 | 0 | checkpointStatus = null; |
173 | |
} |
174 | 0 | } |
175 | |
|
176 | |
@Override |
177 | |
public void write(DataOutput output) throws IOException { |
178 | 0 | output.writeLong(vertexCount); |
179 | 0 | output.writeLong(finishedVertexCount); |
180 | 0 | output.writeLong(edgeCount); |
181 | 0 | output.writeLong(messageCount); |
182 | 0 | output.writeLong(messageBytesCount); |
183 | 0 | output.writeLong(oocLoadBytesCount); |
184 | 0 | output.writeLong(oocStoreBytesCount); |
185 | 0 | output.writeInt(lowestGraphPercentageInMemory); |
186 | 0 | output.writeBoolean(haltComputation); |
187 | 0 | output.writeBoolean(checkpointStatus != null); |
188 | 0 | if (checkpointStatus != null) { |
189 | 0 | output.writeInt(checkpointStatus.ordinal()); |
190 | |
} |
191 | 0 | } |
192 | |
|
193 | |
@Override |
194 | |
public String toString() { |
195 | 0 | return "(vtx=" + vertexCount + ",finVtx=" + |
196 | |
finishedVertexCount + ",edges=" + edgeCount + ",msgCount=" + |
197 | |
messageCount + ",msgBytesCount=" + |
198 | |
messageBytesCount + ",haltComputation=" + haltComputation + |
199 | |
", checkpointStatus=" + checkpointStatus + ')'; |
200 | |
} |
201 | |
} |