1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.worker; |
20 | |
|
21 | |
import com.facebook.swift.codec.ThriftField; |
22 | |
import com.facebook.swift.codec.ThriftStruct; |
23 | |
import org.apache.giraph.utils.MemoryUtils; |
24 | |
|
25 | |
import javax.annotation.concurrent.ThreadSafe; |
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
|
31 | |
@ThreadSafe |
32 | |
@ThriftStruct |
33 | |
public final class WorkerProgress extends WorkerProgressStats { |
34 | |
|
35 | 0 | private static final WorkerProgress INSTANCE = new WorkerProgress(); |
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | 0 | public WorkerProgress() { |
42 | 0 | } |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
|
48 | |
|
49 | |
public static WorkerProgress get() { |
50 | 0 | return INSTANCE; |
51 | |
} |
52 | |
|
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
public synchronized void addVerticesLoaded(long verticesLoaded) { |
60 | 0 | this.verticesLoaded += verticesLoaded; |
61 | 0 | } |
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
public synchronized void incrementVertexInputSplitsLoaded() { |
67 | 0 | vertexInputSplitsLoaded++; |
68 | 0 | } |
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
public synchronized void finishLoadingVertices() { |
74 | 0 | loadingVerticesDone = true; |
75 | 0 | } |
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
|
82 | |
|
83 | |
public synchronized void addEdgesLoaded(long edgesLoaded) { |
84 | 0 | this.edgesLoaded += edgesLoaded; |
85 | 0 | } |
86 | |
|
87 | |
|
88 | |
|
89 | |
|
90 | |
public synchronized void incrementEdgeInputSplitsLoaded() { |
91 | 0 | edgeInputSplitsLoaded++; |
92 | 0 | } |
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
public synchronized void finishLoadingEdges() { |
98 | 0 | loadingEdgesDone = true; |
99 | 0 | } |
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
|
105 | |
|
106 | |
|
107 | |
|
108 | |
public synchronized void startSuperstep(long superstep, |
109 | |
long verticesToCompute, int partitionsToCompute) { |
110 | 0 | this.currentSuperstep = superstep; |
111 | 0 | this.verticesToCompute = verticesToCompute; |
112 | 0 | this.partitionsToCompute = partitionsToCompute; |
113 | 0 | verticesComputed = 0; |
114 | 0 | partitionsComputed = 0; |
115 | 0 | } |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
|
121 | |
|
122 | |
|
123 | |
public synchronized void addVerticesComputed(long verticesComputed) { |
124 | 0 | this.verticesComputed += verticesComputed; |
125 | 0 | } |
126 | |
|
127 | |
|
128 | |
|
129 | |
|
130 | |
public synchronized void incrementPartitionsComputed() { |
131 | 0 | partitionsComputed++; |
132 | 0 | } |
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
public synchronized void startStoring(long verticesToStore, |
141 | |
int partitionsToStore) { |
142 | 0 | computationDone = true; |
143 | 0 | verticesToCompute = 0; |
144 | 0 | verticesComputed = 0; |
145 | 0 | partitionsToCompute = 0; |
146 | 0 | partitionsComputed = 0; |
147 | 0 | currentSuperstep = Long.MAX_VALUE; |
148 | 0 | this.verticesToStore = verticesToStore; |
149 | 0 | this.partitionsToStore = partitionsToStore; |
150 | 0 | } |
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
public synchronized void addVerticesStored(long verticesStored) { |
159 | 0 | this.verticesStored += verticesStored; |
160 | 0 | } |
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
public synchronized void incrementPartitionsStored() { |
166 | 0 | partitionsStored++; |
167 | 0 | } |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
public synchronized void finishStoring() { |
173 | 0 | storingDone = true; |
174 | 0 | } |
175 | |
|
176 | |
|
177 | |
|
178 | |
|
179 | |
public synchronized void updateMemory() { |
180 | 0 | freeMemoryMB = MemoryUtils.freePlusUnallocatedMemoryMB(); |
181 | 0 | freeMemoryFraction = MemoryUtils.freeMemoryFraction(); |
182 | 0 | } |
183 | |
|
184 | |
|
185 | |
|
186 | |
|
187 | |
|
188 | |
|
189 | |
|
190 | |
public synchronized void updateLowestGraphPercentageInMemory(int fraction) { |
191 | 0 | lowestGraphPercentageInMemory = |
192 | 0 | Math.min(lowestGraphPercentageInMemory, fraction); |
193 | 0 | } |
194 | |
|
195 | |
@ThriftField(1) |
196 | |
public synchronized long getCurrentSuperstep() { |
197 | 0 | return currentSuperstep; |
198 | |
} |
199 | |
|
200 | |
@ThriftField(2) |
201 | |
public synchronized long getVerticesLoaded() { |
202 | 0 | return verticesLoaded; |
203 | |
} |
204 | |
|
205 | |
@ThriftField(3) |
206 | |
public synchronized int getVertexInputSplitsLoaded() { |
207 | 0 | return vertexInputSplitsLoaded; |
208 | |
} |
209 | |
|
210 | |
@ThriftField(4) |
211 | |
public synchronized boolean isLoadingVerticesDone() { |
212 | 0 | return loadingVerticesDone; |
213 | |
} |
214 | |
|
215 | |
@ThriftField(5) |
216 | |
public synchronized long getEdgesLoaded() { |
217 | 0 | return edgesLoaded; |
218 | |
} |
219 | |
|
220 | |
@ThriftField(6) |
221 | |
public synchronized int getEdgeInputSplitsLoaded() { |
222 | 0 | return edgeInputSplitsLoaded; |
223 | |
} |
224 | |
|
225 | |
@ThriftField(7) |
226 | |
public synchronized boolean isLoadingEdgesDone() { |
227 | 0 | return loadingEdgesDone; |
228 | |
} |
229 | |
|
230 | |
@ThriftField(8) |
231 | |
public synchronized long getVerticesToCompute() { |
232 | 0 | return verticesToCompute; |
233 | |
} |
234 | |
|
235 | |
@ThriftField(9) |
236 | |
public synchronized long getVerticesComputed() { |
237 | 0 | return verticesComputed; |
238 | |
} |
239 | |
|
240 | |
@ThriftField(10) |
241 | |
public synchronized int getPartitionsToCompute() { |
242 | 0 | return partitionsToCompute; |
243 | |
} |
244 | |
|
245 | |
@ThriftField(11) |
246 | |
public synchronized int getPartitionsComputed() { |
247 | 0 | return partitionsComputed; |
248 | |
} |
249 | |
|
250 | |
@ThriftField(12) |
251 | |
public synchronized boolean isComputationDone() { |
252 | 0 | return computationDone; |
253 | |
} |
254 | |
|
255 | |
@ThriftField(13) |
256 | |
public synchronized long getVerticesToStore() { |
257 | 0 | return verticesToStore; |
258 | |
} |
259 | |
|
260 | |
@ThriftField(14) |
261 | |
public synchronized long getVerticesStored() { |
262 | 0 | return verticesStored; |
263 | |
} |
264 | |
|
265 | |
@ThriftField(15) |
266 | |
public synchronized int getPartitionsToStore() { |
267 | 0 | return partitionsToStore; |
268 | |
} |
269 | |
|
270 | |
@ThriftField(16) |
271 | |
public synchronized int getPartitionsStored() { |
272 | 0 | return partitionsStored; |
273 | |
} |
274 | |
|
275 | |
@ThriftField(17) |
276 | |
public synchronized boolean isStoringDone() { |
277 | 0 | return storingDone; |
278 | |
} |
279 | |
|
280 | |
@ThriftField(18) |
281 | |
public synchronized int getTaskId() { |
282 | 0 | return taskId; |
283 | |
} |
284 | |
|
285 | |
@ThriftField(19) |
286 | |
public synchronized double getFreeMemoryMB() { |
287 | 0 | return freeMemoryMB; |
288 | |
} |
289 | |
|
290 | |
@ThriftField(20) |
291 | |
public synchronized double getFreeMemoryFraction() { |
292 | 0 | return freeMemoryFraction; |
293 | |
} |
294 | |
|
295 | |
@ThriftField(21) |
296 | |
public synchronized int getLowestGraphPercentageInMemory() { |
297 | 0 | return lowestGraphPercentageInMemory; |
298 | |
} |
299 | |
|
300 | |
public synchronized boolean isInputSuperstep() { |
301 | 0 | return currentSuperstep == -1; |
302 | |
} |
303 | |
|
304 | |
public synchronized boolean isComputeSuperstep() { |
305 | 0 | return currentSuperstep >= 0 && currentSuperstep < Long.MAX_VALUE; |
306 | |
} |
307 | |
|
308 | |
public synchronized boolean isOutputSuperstep() { |
309 | 0 | return currentSuperstep == Long.MAX_VALUE; |
310 | |
} |
311 | |
|
312 | |
@ThriftField |
313 | |
public void setCurrentSuperstep(long currentSuperstep) { |
314 | 0 | this.currentSuperstep = currentSuperstep; |
315 | 0 | } |
316 | |
|
317 | |
@ThriftField |
318 | |
public void setVerticesLoaded(long verticesLoaded) { |
319 | 0 | this.verticesLoaded = verticesLoaded; |
320 | 0 | } |
321 | |
|
322 | |
@ThriftField |
323 | |
public void setVertexInputSplitsLoaded(int vertexInputSplitsLoaded) { |
324 | 0 | this.vertexInputSplitsLoaded = vertexInputSplitsLoaded; |
325 | 0 | } |
326 | |
|
327 | |
@ThriftField |
328 | |
public void setLoadingVerticesDone(boolean loadingVerticesDone) { |
329 | 0 | this.loadingVerticesDone = loadingVerticesDone; |
330 | 0 | } |
331 | |
|
332 | |
@ThriftField |
333 | |
public void setEdgesLoaded(long edgesLoaded) { |
334 | 0 | this.edgesLoaded = edgesLoaded; |
335 | 0 | } |
336 | |
|
337 | |
@ThriftField |
338 | |
public void setEdgeInputSplitsLoaded(int edgeInputSplitsLoaded) { |
339 | 0 | this.edgeInputSplitsLoaded = edgeInputSplitsLoaded; |
340 | 0 | } |
341 | |
|
342 | |
@ThriftField |
343 | |
public void setLoadingEdgesDone(boolean loadingEdgesDone) { |
344 | 0 | this.loadingEdgesDone = loadingEdgesDone; |
345 | 0 | } |
346 | |
|
347 | |
@ThriftField |
348 | |
public void setVerticesToCompute(long verticesToCompute) { |
349 | 0 | this.verticesToCompute = verticesToCompute; |
350 | 0 | } |
351 | |
|
352 | |
@ThriftField |
353 | |
public void setVerticesComputed(long verticesComputed) { |
354 | 0 | this.verticesComputed = verticesComputed; |
355 | 0 | } |
356 | |
|
357 | |
@ThriftField |
358 | |
public void setPartitionsToCompute(int partitionsToCompute) { |
359 | 0 | this.partitionsToCompute = partitionsToCompute; |
360 | 0 | } |
361 | |
|
362 | |
@ThriftField |
363 | |
public void setPartitionsComputed(int partitionsComputed) { |
364 | 0 | this.partitionsComputed = partitionsComputed; |
365 | 0 | } |
366 | |
|
367 | |
@ThriftField |
368 | |
public void setComputationDone(boolean computationDone) { |
369 | 0 | this.computationDone = computationDone; |
370 | 0 | } |
371 | |
|
372 | |
@ThriftField |
373 | |
public void setVerticesToStore(long verticesToStore) { |
374 | 0 | this.verticesToStore = verticesToStore; |
375 | 0 | } |
376 | |
|
377 | |
@ThriftField |
378 | |
public void setVerticesStored(long verticesStored) { |
379 | 0 | this.verticesStored = verticesStored; |
380 | 0 | } |
381 | |
|
382 | |
@ThriftField |
383 | |
public void setPartitionsToStore(int partitionsToStore) { |
384 | 0 | this.partitionsToStore = partitionsToStore; |
385 | 0 | } |
386 | |
|
387 | |
@ThriftField |
388 | |
public void setPartitionsStored(int partitionsStored) { |
389 | 0 | this.partitionsStored = partitionsStored; |
390 | 0 | } |
391 | |
|
392 | |
@ThriftField |
393 | |
public void setStoringDone(boolean storingDone) { |
394 | 0 | this.storingDone = storingDone; |
395 | 0 | } |
396 | |
|
397 | |
@ThriftField |
398 | |
public void setFreeMemoryMB(double freeMemoryMB) { |
399 | 0 | this.freeMemoryMB = freeMemoryMB; |
400 | 0 | } |
401 | |
|
402 | |
@ThriftField |
403 | |
public void setFreeMemoryFraction(double freeMemoryFraction) { |
404 | 0 | this.freeMemoryFraction = freeMemoryFraction; |
405 | 0 | } |
406 | |
|
407 | |
@ThriftField |
408 | |
public synchronized void setTaskId(int taskId) { |
409 | 0 | this.taskId = taskId; |
410 | 0 | } |
411 | |
|
412 | |
@ThriftField |
413 | |
public synchronized void setLowestGraphPercentageInMemory( |
414 | |
int lowestGraphPercentageInMemory) { |
415 | 0 | this.lowestGraphPercentageInMemory = lowestGraphPercentageInMemory; |
416 | 0 | } |
417 | |
} |