1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
|
19 | |
package org.apache.giraph.comm; |
20 | |
|
21 | |
import java.io.DataInput; |
22 | |
import java.io.DataOutput; |
23 | |
import java.io.IOException; |
24 | |
import org.apache.giraph.comm.RequestRegistry.Type; |
25 | |
import org.apache.hadoop.conf.Configurable; |
26 | |
import org.apache.hadoop.conf.Configuration; |
27 | |
import org.apache.hadoop.io.Writable; |
28 | |
import org.apache.hadoop.io.WritableComparable; |
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
@SuppressWarnings("rawtypes") |
39 | 43 | public abstract class WritableRequest<I extends WritableComparable, |
40 | |
V extends Writable, E extends Writable, |
41 | |
M extends Writable> implements Writable, Configurable { |
42 | |
|
43 | |
private Configuration conf; |
44 | |
|
45 | 43 | private long requestId = -1; |
46 | |
|
47 | |
public long getRequestId() { |
48 | 6 | return requestId; |
49 | |
} |
50 | |
|
51 | |
public void setRequestId(long requestId) { |
52 | 3 | this.requestId = requestId; |
53 | 3 | } |
54 | |
|
55 | |
|
56 | |
|
57 | |
|
58 | |
|
59 | |
|
60 | |
public abstract Type getType(); |
61 | |
|
62 | |
|
63 | |
|
64 | |
|
65 | |
|
66 | |
|
67 | |
abstract void readFieldsRequest(DataInput input) throws IOException; |
68 | |
|
69 | |
|
70 | |
|
71 | |
|
72 | |
|
73 | |
|
74 | |
abstract void writeRequest(DataOutput output) throws IOException; |
75 | |
|
76 | |
|
77 | |
|
78 | |
|
79 | |
|
80 | |
|
81 | |
public abstract void doRequest(ServerData<I, V, E, M> serverData); |
82 | |
|
83 | |
@Override |
84 | |
public final Configuration getConf() { |
85 | 59 | return conf; |
86 | |
} |
87 | |
|
88 | |
@Override |
89 | |
public final void setConf(Configuration conf) { |
90 | 3 | this.conf = conf; |
91 | 3 | } |
92 | |
|
93 | |
@Override |
94 | |
public final void readFields(DataInput input) throws IOException { |
95 | 3 | requestId = input.readLong(); |
96 | 3 | readFieldsRequest(input); |
97 | 3 | } |
98 | |
|
99 | |
@Override |
100 | |
public final void write(DataOutput output) throws IOException { |
101 | 3 | output.writeLong(requestId); |
102 | 3 | writeRequest(output); |
103 | 3 | } |
104 | |
} |