This project has retired. For details please refer to its
Attic page.
GiraphStats xref
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 super(context, GROUP_NAME);
115 counters = new GiraphHadoopCounter[NUM_COUNTERS];
116 counters[SUPERSTEP] = getCounter(SUPERSTEP_NAME);
117 counters[VERTICES] = getCounter(VERTICES_NAME);
118 counters[FINISHED_VERTICES] = getCounter(FINISHED_VERTICES_NAME);
119 counters[EDGES] = getCounter(EDGES_NAME);
120 counters[SENT_MESSAGES] = getCounter(SENT_MESSAGES_NAME);
121 counters[SENT_MESSAGE_BYTES] = getCounter(SENT_MESSAGE_BYTES_NAME);
122 counters[CURRENT_WORKERS] = getCounter(CURRENT_WORKERS_NAME);
123 counters[CURRENT_MASTER_TASK_PARTITION] =
124 getCounter(CURRENT_MASTER_PARTITION_TASK_NAME);
125 counters[LAST_CHECKPOINTED_SUPERSTEP] =
126 getCounter(LAST_CHECKPOINTED_SUPERSTEP_NAME);
127 counters[AGG_SENT_MESSAGES] =
128 getCounter(AGGREGATE_SENT_MESSAGES_NAME);
129 counters[AGG_SENT_MESSAGE_BYTES] =
130 getCounter(AGGREGATE_SENT_MESSAGE_BYTES_NAME);
131 counters[OOC_BYTES_LOADED] = getCounter(OOC_BYTES_LOADED_NAME);
132 counters[OOC_BYTES_STORED] = getCounter(OOC_BYTES_STORED_NAME);
133 counters[LOWEST_GRAPH_PERCENTAGE_IN_MEMORY] =
134 getCounter(LOWEST_GRAPH_PERCENTAGE_IN_MEMORY_NAME);
135 counters[LOWEST_GRAPH_PERCENTAGE_IN_MEMORY].setValue(100);
136 }
137
138
139
140
141
142
143 public static void init(Context context) {
144 INSTANCE = new GiraphStats(context);
145 }
146
147
148
149
150
151
152 public static GiraphStats getInstance() {
153 return INSTANCE;
154 }
155
156
157
158
159
160
161
162
163 public List<CustomCounter> getCounterList() {
164 List<CustomCounter> counterList = new ArrayList<>();
165 for (int i = 0; i < counters.length; i++) {
166 counterList.add(new CustomCounter(GROUP_NAME,
167 counters[i].getDisplayName(),
168 CustomCounter.Aggregation.SUM, counters[i].getValue()));
169 }
170 return counterList;
171 }
172
173
174
175
176
177
178 public GiraphHadoopCounter getSuperstepCounter() {
179 return counters[SUPERSTEP];
180 }
181
182
183
184
185
186
187 public GiraphHadoopCounter getVertices() {
188 return counters[VERTICES];
189 }
190
191
192
193
194
195
196 public GiraphHadoopCounter getFinishedVertexes() {
197 return counters[FINISHED_VERTICES];
198 }
199
200
201
202
203
204
205 public GiraphHadoopCounter getEdges() {
206 return counters[EDGES];
207 }
208
209
210
211
212
213
214 public GiraphHadoopCounter getSentMessages() {
215 return counters[SENT_MESSAGES];
216 }
217
218
219
220
221
222
223 public GiraphHadoopCounter getSentMessageBytes() {
224 return counters[SENT_MESSAGE_BYTES];
225 }
226
227
228
229
230
231
232 public GiraphHadoopCounter getAggregateSentMessages() {
233 return counters[AGG_SENT_MESSAGES];
234 }
235
236
237
238
239
240
241 public GiraphHadoopCounter getAggregateSentMessageBytes() {
242 return counters[AGG_SENT_MESSAGE_BYTES];
243 }
244
245
246
247
248
249
250 public GiraphHadoopCounter getCurrentWorkers() {
251 return counters[CURRENT_WORKERS];
252 }
253
254
255
256
257
258
259 public GiraphHadoopCounter getCurrentMasterTaskPartition() {
260 return counters[CURRENT_MASTER_TASK_PARTITION];
261 }
262
263
264
265
266
267
268 public GiraphHadoopCounter getLastCheckpointedSuperstep() {
269 return counters[LAST_CHECKPOINTED_SUPERSTEP];
270 }
271
272
273
274
275
276
277 public GiraphHadoopCounter getAggregateOOCBytesLoaded() {
278 return counters[OOC_BYTES_LOADED];
279 }
280
281
282
283
284
285
286 public GiraphHadoopCounter getAggregateOOCBytesStored() {
287 return counters[OOC_BYTES_STORED];
288 }
289
290 public GiraphHadoopCounter getLowestGraphPercentageInMemory() {
291 return counters[LOWEST_GRAPH_PERCENTAGE_IN_MEMORY];
292 }
293
294 @Override
295 public Iterator<GiraphHadoopCounter> iterator() {
296 return Arrays.asList(counters).iterator();
297 }
298 }