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.comm.ServerData; |
22 | |
import org.apache.giraph.partition.Partition; |
23 | |
import org.apache.hadoop.io.Writable; |
24 | |
import org.apache.hadoop.io.WritableComparable; |
25 | |
import org.apache.log4j.Logger; |
26 | |
|
27 | |
import java.io.DataInput; |
28 | |
import java.io.DataOutput; |
29 | |
import java.io.IOException; |
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
@SuppressWarnings("rawtypes") |
40 | |
public class SendVertexRequest<I extends WritableComparable, |
41 | |
V extends Writable, E extends Writable> extends |
42 | |
WritableRequest<I, V, E> implements WorkerRequest<I, V, E> { |
43 | |
|
44 | 0 | private static final Logger LOG = |
45 | 0 | Logger.getLogger(SendVertexRequest.class); |
46 | |
|
47 | |
private Partition<I, V, E> partition; |
48 | |
|
49 | |
|
50 | |
|
51 | |
|
52 | 0 | public SendVertexRequest() { } |
53 | |
|
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | 0 | public SendVertexRequest(Partition<I, V, E> partition) { |
60 | 0 | this.partition = partition; |
61 | 0 | } |
62 | |
|
63 | |
@Override |
64 | |
public void readFieldsRequest(DataInput input) throws IOException { |
65 | 0 | partition = getConf().createPartition(-1, null); |
66 | 0 | partition.readFields(input); |
67 | 0 | } |
68 | |
|
69 | |
@Override |
70 | |
public void writeRequest(DataOutput output) throws IOException { |
71 | 0 | partition.write(output); |
72 | 0 | } |
73 | |
|
74 | |
@Override |
75 | |
public RequestType getType() { |
76 | 0 | return RequestType.SEND_VERTEX_REQUEST; |
77 | |
} |
78 | |
|
79 | |
@Override |
80 | |
public void doRequest(ServerData<I, V, E> serverData) { |
81 | 0 | serverData.getPartitionStore().addPartition(partition); |
82 | 0 | } |
83 | |
|
84 | |
@Override |
85 | |
public int getSerializedSize() { |
86 | 0 | return WritableRequest.UNKNOWN_SIZE; |
87 | |
} |
88 | |
} |
89 | |
|