1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.comm.requests; |
20 | |
|
21 | |
import org.apache.giraph.master.MasterGlobalCommHandler; |
22 | |
import org.apache.giraph.partition.PartitionStats; |
23 | |
|
24 | |
import java.io.DataInput; |
25 | |
import java.io.DataOutput; |
26 | |
import java.io.IOException; |
27 | |
import java.util.ArrayList; |
28 | |
import java.util.Collection; |
29 | |
import java.util.List; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
public class PartitionStatsRequest extends WritableRequest |
35 | |
implements MasterRequest { |
36 | |
|
37 | |
private List<PartitionStats> partitionStats; |
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | 0 | public PartitionStatsRequest(Collection<PartitionStats> partitionStats) { |
45 | 0 | this.partitionStats = new ArrayList<>(partitionStats); |
46 | 0 | } |
47 | |
|
48 | |
|
49 | 0 | public PartitionStatsRequest() { |
50 | 0 | } |
51 | |
|
52 | |
@Override |
53 | |
public void doRequest(MasterGlobalCommHandler commHandler) { |
54 | 0 | commHandler.receivedPartitionStats(partitionStats); |
55 | 0 | } |
56 | |
|
57 | |
@Override |
58 | |
public RequestType getType() { |
59 | 0 | return RequestType.PARTITION_STATS_REQUEST; |
60 | |
} |
61 | |
|
62 | |
@Override |
63 | |
void writeRequest(DataOutput output) throws IOException { |
64 | 0 | output.writeInt(partitionStats.size()); |
65 | 0 | for (PartitionStats partitionStat : partitionStats) { |
66 | 0 | partitionStat.write(output); |
67 | 0 | } |
68 | 0 | } |
69 | |
|
70 | |
@Override |
71 | |
void readFieldsRequest(DataInput input) throws IOException { |
72 | 0 | int size = input.readInt(); |
73 | 0 | partitionStats = new ArrayList<>(size); |
74 | 0 | for (int i = 0; i < size; i++) { |
75 | 0 | PartitionStats newPartitionStats = new PartitionStats(); |
76 | 0 | newPartitionStats.readFields(input); |
77 | 0 | partitionStats.add(newPartitionStats); |
78 | |
} |
79 | 0 | } |
80 | |
} |