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