1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.apache.giraph.partition; |
19 | |
|
20 | |
import java.io.DataInput; |
21 | |
import java.io.DataOutput; |
22 | |
import java.io.IOException; |
23 | |
|
24 | |
import org.apache.hadoop.io.Writable; |
25 | |
|
26 | |
|
27 | |
|
28 | |
|
29 | |
|
30 | |
public class PartitionStats implements Writable { |
31 | |
|
32 | 0 | private int partitionId = -1; |
33 | |
|
34 | 0 | private long vertexCount = 0; |
35 | |
|
36 | 0 | private long finishedVertexCount = 0; |
37 | |
|
38 | 0 | private long edgeCount = 0; |
39 | |
|
40 | 0 | private long messagesSentCount = 0; |
41 | |
|
42 | 0 | private long messageBytesSentCount = 0; |
43 | |
|
44 | |
|
45 | |
|
46 | |
|
47 | |
private long computeMs; |
48 | |
|
49 | |
private String workerHostnameId; |
50 | |
|
51 | |
|
52 | |
|
53 | |
|
54 | 0 | public PartitionStats() { } |
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
|
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
public PartitionStats(int partitionId, |
68 | |
long vertexCount, |
69 | |
long finishedVertexCount, |
70 | |
long edgeCount, |
71 | |
long messagesSentCount, |
72 | |
long messageBytesSentCount, |
73 | 0 | String workerHostnameId) { |
74 | 0 | this.partitionId = partitionId; |
75 | 0 | this.vertexCount = vertexCount; |
76 | 0 | this.finishedVertexCount = finishedVertexCount; |
77 | 0 | this.edgeCount = edgeCount; |
78 | 0 | this.messagesSentCount = messagesSentCount; |
79 | 0 | this.messageBytesSentCount = messageBytesSentCount; |
80 | 0 | this.workerHostnameId = workerHostnameId; |
81 | 0 | } |
82 | |
|
83 | |
|
84 | |
|
85 | |
|
86 | |
|
87 | |
|
88 | |
public void setPartitionId(int partitionId) { |
89 | 0 | this.partitionId = partitionId; |
90 | 0 | } |
91 | |
|
92 | |
|
93 | |
|
94 | |
|
95 | |
|
96 | |
|
97 | |
public int getPartitionId() { |
98 | 0 | return partitionId; |
99 | |
} |
100 | |
|
101 | |
|
102 | |
|
103 | |
|
104 | |
public void incrVertexCount() { |
105 | 0 | ++vertexCount; |
106 | 0 | } |
107 | |
|
108 | |
|
109 | |
|
110 | |
|
111 | |
|
112 | |
|
113 | |
public long getVertexCount() { |
114 | 0 | return vertexCount; |
115 | |
} |
116 | |
|
117 | |
|
118 | |
|
119 | |
|
120 | |
public void incrFinishedVertexCount() { |
121 | 0 | ++finishedVertexCount; |
122 | 0 | } |
123 | |
|
124 | |
|
125 | |
|
126 | |
|
127 | |
|
128 | |
|
129 | |
public long getFinishedVertexCount() { |
130 | 0 | return finishedVertexCount; |
131 | |
} |
132 | |
|
133 | |
|
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
public void addEdgeCount(long edgeCount) { |
139 | 0 | this.edgeCount += edgeCount; |
140 | 0 | } |
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | |
|
146 | |
|
147 | |
public long getEdgeCount() { |
148 | 0 | return edgeCount; |
149 | |
} |
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
public void addMessagesSentCount(long messagesSentCount) { |
157 | 0 | this.messagesSentCount += messagesSentCount; |
158 | 0 | } |
159 | |
|
160 | |
|
161 | |
|
162 | |
|
163 | |
|
164 | |
|
165 | |
public long getMessagesSentCount() { |
166 | 0 | return messagesSentCount; |
167 | |
} |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
public void addMessageBytesSentCount(long messageBytesSentCount) { |
175 | 0 | this.messageBytesSentCount += messageBytesSentCount; |
176 | 0 | } |
177 | |
|
178 | |
|
179 | |
|
180 | |
|
181 | |
|
182 | |
|
183 | |
public long getMessageBytesSentCount() { |
184 | 0 | return messageBytesSentCount; |
185 | |
} |
186 | |
|
187 | |
public long getComputeMs() { |
188 | 0 | return computeMs; |
189 | |
} |
190 | |
|
191 | |
public void setComputeMs(long computeMs) { |
192 | 0 | this.computeMs = computeMs; |
193 | 0 | } |
194 | |
|
195 | |
public String getWorkerHostnameId() { |
196 | 0 | return workerHostnameId; |
197 | |
} |
198 | |
|
199 | |
@Override |
200 | |
public void readFields(DataInput input) throws IOException { |
201 | 0 | partitionId = input.readInt(); |
202 | 0 | vertexCount = input.readLong(); |
203 | 0 | finishedVertexCount = input.readLong(); |
204 | 0 | edgeCount = input.readLong(); |
205 | 0 | messagesSentCount = input.readLong(); |
206 | 0 | messageBytesSentCount = input.readLong(); |
207 | 0 | computeMs = input.readLong(); |
208 | 0 | workerHostnameId = input.readUTF(); |
209 | 0 | } |
210 | |
|
211 | |
@Override |
212 | |
public void write(DataOutput output) throws IOException { |
213 | 0 | output.writeInt(partitionId); |
214 | 0 | output.writeLong(vertexCount); |
215 | 0 | output.writeLong(finishedVertexCount); |
216 | 0 | output.writeLong(edgeCount); |
217 | 0 | output.writeLong(messagesSentCount); |
218 | 0 | output.writeLong(messageBytesSentCount); |
219 | 0 | output.writeLong(computeMs); |
220 | 0 | output.writeUTF(workerHostnameId); |
221 | 0 | } |
222 | |
|
223 | |
@Override |
224 | |
public String toString() { |
225 | 0 | return "(id=" + partitionId + ",vtx=" + vertexCount + ",finVtx=" + |
226 | |
finishedVertexCount + ",edges=" + edgeCount + ",msgsSent=" + |
227 | |
messagesSentCount + ",msgBytesSent=" + |
228 | |
messageBytesSentCount + ",computeMs=" + computeMs + |
229 | |
")"; |
230 | |
} |
231 | |
} |