1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.counters; |
20 | |
|
21 | |
import org.apache.hadoop.mapreduce.Mapper.Context; |
22 | |
|
23 | |
import java.util.ArrayList; |
24 | |
import java.util.Arrays; |
25 | |
import java.util.Iterator; |
26 | |
import java.util.List; |
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
public class GiraphStats extends HadoopCountersBase { |
32 | |
|
33 | |
public static final String GROUP_NAME = "Giraph Stats"; |
34 | |
|
35 | |
public static final String SUPERSTEP_NAME = "Superstep"; |
36 | |
|
37 | |
public static final String VERTICES_NAME = "Aggregate vertices"; |
38 | |
|
39 | |
public static final String FINISHED_VERTICES_NAME = |
40 | |
"Aggregate finished vertices"; |
41 | |
|
42 | |
public static final String EDGES_NAME = "Aggregate edges"; |
43 | |
|
44 | |
public static final String SENT_MESSAGES_NAME = "Sent messages"; |
45 | |
|
46 | |
public static final String SENT_MESSAGE_BYTES_NAME = "Sent message bytes"; |
47 | |
|
48 | |
public static final String AGGREGATE_SENT_MESSAGES_NAME |
49 | |
= "Aggregate sent messages"; |
50 | |
|
51 | |
public static final String AGGREGATE_SENT_MESSAGE_BYTES_NAME |
52 | |
= "Aggregate sent message bytes"; |
53 | |
|
54 | |
public static final String CURRENT_WORKERS_NAME = "Current workers"; |
55 | |
|
56 | |
public static final String CURRENT_MASTER_PARTITION_TASK_NAME = |
57 | |
"Current master task partition"; |
58 | |
|
59 | |
public static final String LAST_CHECKPOINTED_SUPERSTEP_NAME = |
60 | |
"Last checkpointed superstep"; |
61 | |
|
62 | |
public static final String OOC_BYTES_LOADED_NAME = |
63 | |
"Aggregate bytes loaded from local disks (out-of-core)"; |
64 | |
|
65 | |
public static final String OOC_BYTES_STORED_NAME = |
66 | |
"Aggregate bytes stored to local disks (out-of-core)"; |
67 | |
|
68 | |
public static final String LOWEST_GRAPH_PERCENTAGE_IN_MEMORY_NAME = |
69 | |
"Lowest percentage of graph in memory so far (out-of-core)"; |
70 | |
|
71 | |
|
72 | |
private static GiraphStats INSTANCE; |
73 | |
|
74 | |
|
75 | |
private static final int SUPERSTEP = 0; |
76 | |
|
77 | |
private static final int VERTICES = 1; |
78 | |
|
79 | |
private static final int FINISHED_VERTICES = 2; |
80 | |
|
81 | |
private static final int EDGES = 3; |
82 | |
|
83 | |
private static final int SENT_MESSAGES = 4; |
84 | |
|
85 | |
private static final int CURRENT_WORKERS = 5; |
86 | |
|
87 | |
private static final int CURRENT_MASTER_TASK_PARTITION = 6; |
88 | |
|
89 | |
private static final int LAST_CHECKPOINTED_SUPERSTEP = 7; |
90 | |
|
91 | |
private static final int SENT_MESSAGE_BYTES = 8; |
92 | |
|
93 | |
private static final int AGG_SENT_MESSAGES = 9; |
94 | |
|
95 | |
private static final int AGG_SENT_MESSAGE_BYTES = 10; |
96 | |
|
97 | |
private static final int OOC_BYTES_LOADED = 11; |
98 | |
|
99 | |
private static final int OOC_BYTES_STORED = 12; |
100 | |
|
101 | |
private static final int LOWEST_GRAPH_PERCENTAGE_IN_MEMORY = 13; |
102 | |
|
103 | |
private static final int NUM_COUNTERS = 14; |
104 | |
|
105 | |
|
106 | |
private final GiraphHadoopCounter[] counters; |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
private GiraphStats(Context context) { |
114 | 0 | super(context, GROUP_NAME); |
115 | 0 | counters = new GiraphHadoopCounter[NUM_COUNTERS]; |
116 | 0 | counters[SUPERSTEP] = getCounter(SUPERSTEP_NAME); |
117 | 0 | counters[VERTICES] = getCounter(VERTICES_NAME); |
118 | 0 | counters[FINISHED_VERTICES] = getCounter(FINISHED_VERTICES_NAME); |
119 | 0 | counters[EDGES] = getCounter(EDGES_NAME); |
120 | 0 | counters[SENT_MESSAGES] = getCounter(SENT_MESSAGES_NAME); |
121 | 0 | counters[SENT_MESSAGE_BYTES] = getCounter(SENT_MESSAGE_BYTES_NAME); |
122 | 0 | counters[CURRENT_WORKERS] = getCounter(CURRENT_WORKERS_NAME); |
123 | 0 | counters[CURRENT_MASTER_TASK_PARTITION] = |
124 | 0 | getCounter(CURRENT_MASTER_PARTITION_TASK_NAME); |
125 | 0 | counters[LAST_CHECKPOINTED_SUPERSTEP] = |
126 | 0 | getCounter(LAST_CHECKPOINTED_SUPERSTEP_NAME); |
127 | 0 | counters[AGG_SENT_MESSAGES] = |
128 | 0 | getCounter(AGGREGATE_SENT_MESSAGES_NAME); |
129 | 0 | counters[AGG_SENT_MESSAGE_BYTES] = |
130 | 0 | getCounter(AGGREGATE_SENT_MESSAGE_BYTES_NAME); |
131 | 0 | counters[OOC_BYTES_LOADED] = getCounter(OOC_BYTES_LOADED_NAME); |
132 | 0 | counters[OOC_BYTES_STORED] = getCounter(OOC_BYTES_STORED_NAME); |
133 | 0 | counters[LOWEST_GRAPH_PERCENTAGE_IN_MEMORY] = |
134 | 0 | getCounter(LOWEST_GRAPH_PERCENTAGE_IN_MEMORY_NAME); |
135 | 0 | counters[LOWEST_GRAPH_PERCENTAGE_IN_MEMORY].setValue(100); |
136 | 0 | } |
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
public static void init(Context context) { |
144 | 0 | INSTANCE = new GiraphStats(context); |
145 | 0 | } |
146 | |
|
147 | |
|
148 | |
|
149 | |
|
150 | |
|
151 | |
|
152 | |
public static GiraphStats getInstance() { |
153 | 0 | return INSTANCE; |
154 | |
} |
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
public List<CustomCounter> getCounterList() { |
164 | 0 | List<CustomCounter> counterList = new ArrayList<>(); |
165 | 0 | for (int i = 0; i < counters.length; i++) { |
166 | 0 | counterList.add(new CustomCounter(GROUP_NAME, |
167 | 0 | counters[i].getDisplayName(), |
168 | 0 | CustomCounter.Aggregation.SUM, counters[i].getValue())); |
169 | |
} |
170 | 0 | return counterList; |
171 | |
} |
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | |
public GiraphHadoopCounter getSuperstepCounter() { |
179 | 0 | return counters[SUPERSTEP]; |
180 | |
} |
181 | |
|
182 | |
|
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
public GiraphHadoopCounter getVertices() { |
188 | 0 | return counters[VERTICES]; |
189 | |
} |
190 | |
|
191 | |
|
192 | |
|
193 | |
|
194 | |
|
195 | |
|
196 | |
public GiraphHadoopCounter getFinishedVertexes() { |
197 | 0 | return counters[FINISHED_VERTICES]; |
198 | |
} |
199 | |
|
200 | |
|
201 | |
|
202 | |
|
203 | |
|
204 | |
|
205 | |
public GiraphHadoopCounter getEdges() { |
206 | 0 | return counters[EDGES]; |
207 | |
} |
208 | |
|
209 | |
|
210 | |
|
211 | |
|
212 | |
|
213 | |
|
214 | |
public GiraphHadoopCounter getSentMessages() { |
215 | 0 | return counters[SENT_MESSAGES]; |
216 | |
} |
217 | |
|
218 | |
|
219 | |
|
220 | |
|
221 | |
|
222 | |
|
223 | |
public GiraphHadoopCounter getSentMessageBytes() { |
224 | 0 | return counters[SENT_MESSAGE_BYTES]; |
225 | |
} |
226 | |
|
227 | |
|
228 | |
|
229 | |
|
230 | |
|
231 | |
|
232 | |
public GiraphHadoopCounter getAggregateSentMessages() { |
233 | 0 | return counters[AGG_SENT_MESSAGES]; |
234 | |
} |
235 | |
|
236 | |
|
237 | |
|
238 | |
|
239 | |
|
240 | |
|
241 | |
public GiraphHadoopCounter getAggregateSentMessageBytes() { |
242 | 0 | return counters[AGG_SENT_MESSAGE_BYTES]; |
243 | |
} |
244 | |
|
245 | |
|
246 | |
|
247 | |
|
248 | |
|
249 | |
|
250 | |
public GiraphHadoopCounter getCurrentWorkers() { |
251 | 0 | return counters[CURRENT_WORKERS]; |
252 | |
} |
253 | |
|
254 | |
|
255 | |
|
256 | |
|
257 | |
|
258 | |
|
259 | |
public GiraphHadoopCounter getCurrentMasterTaskPartition() { |
260 | 0 | return counters[CURRENT_MASTER_TASK_PARTITION]; |
261 | |
} |
262 | |
|
263 | |
|
264 | |
|
265 | |
|
266 | |
|
267 | |
|
268 | |
public GiraphHadoopCounter getLastCheckpointedSuperstep() { |
269 | 0 | return counters[LAST_CHECKPOINTED_SUPERSTEP]; |
270 | |
} |
271 | |
|
272 | |
|
273 | |
|
274 | |
|
275 | |
|
276 | |
|
277 | |
public GiraphHadoopCounter getAggregateOOCBytesLoaded() { |
278 | 0 | return counters[OOC_BYTES_LOADED]; |
279 | |
} |
280 | |
|
281 | |
|
282 | |
|
283 | |
|
284 | |
|
285 | |
|
286 | |
public GiraphHadoopCounter getAggregateOOCBytesStored() { |
287 | 0 | return counters[OOC_BYTES_STORED]; |
288 | |
} |
289 | |
|
290 | |
public GiraphHadoopCounter getLowestGraphPercentageInMemory() { |
291 | 0 | return counters[LOWEST_GRAPH_PERCENTAGE_IN_MEMORY]; |
292 | |
} |
293 | |
|
294 | |
@Override |
295 | |
public Iterator<GiraphHadoopCounter> iterator() { |
296 | 0 | return Arrays.asList(counters).iterator(); |
297 | |
} |
298 | |
} |