1 /*
2 * Licensed to the Apache Software Foundation (ASF) under one
3 * or more contributor license agreements. See the NOTICE file
4 * distributed with this work for additional information
5 * regarding copyright ownership. The ASF licenses this file
6 * to you under the Apache License, Version 2.0 (the
7 * "License"); you may not use this file except in compliance
8 * with the License. You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 */
18
19 package org.apache.giraph.worker;
20
21 import javax.annotation.concurrent.NotThreadSafe;
22
23 /**
24 * Stats about a worker's progress
25 */
26 @NotThreadSafe
27 public class WorkerProgressStats {
28 /** Superstep which worker is executing, Long.MAX_VALUE if it's output */
29 protected long currentSuperstep = -1;
30
31 /** How many vertices were loaded until now */
32 protected long verticesLoaded = 0;
33 /** How many vertex input splits were loaded until now */
34 protected int vertexInputSplitsLoaded = 0;
35 /** Whether worker finished loading vertices */
36 protected boolean loadingVerticesDone = false;
37 /** How many edges were loaded */
38 protected long edgesLoaded = 0;
39 /** How many edge input splits were loaded until now */
40 protected int edgeInputSplitsLoaded = 0;
41 /** Whether worker finished loading edges until now */
42 protected boolean loadingEdgesDone = false;
43
44 /** How many vertices are there to compute in current superstep */
45 protected long verticesToCompute = 0;
46 /** How many vertices were computed in current superstep until now */
47 protected long verticesComputed = 0;
48 /** How many partitions are there to compute in current superstep */
49 protected int partitionsToCompute = 0;
50 /** How many partitions were computed in current superstep until now */
51 protected int partitionsComputed = 0;
52
53 /** Whether all compute supersteps are done */
54 protected boolean computationDone = false;
55
56 /** How many vertices are there to store */
57 protected long verticesToStore = 0;
58 /** How many vertices were stored until now */
59 protected long verticesStored = 0;
60 /** How many partitions are there to store */
61 protected int partitionsToStore = 0;
62 /** How many partitions were stored until now */
63 protected int partitionsStored = 0;
64 /** Whether worker finished storing data */
65 protected boolean storingDone = false;
66
67 /** Id of the mapper */
68 protected int taskId;
69
70 /** Free memory */
71 protected double freeMemoryMB;
72 /** Fraction of memory that's free */
73 protected double freeMemoryFraction;
74
75 /** Lowest percentage of graph in memory throughout the execution so far */
76 protected int lowestGraphPercentageInMemory = 100;
77
78 public boolean isInputSuperstep() {
79 return currentSuperstep == -1;
80 }
81
82 public boolean isComputeSuperstep() {
83 return currentSuperstep >= 0 && currentSuperstep < Long.MAX_VALUE;
84 }
85
86 public boolean isOutputSuperstep() {
87 return currentSuperstep == Long.MAX_VALUE;
88 }
89 }