1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.apache.giraph.block_app.migration; |
19 | |
|
20 | |
import java.io.DataInput; |
21 | |
import java.io.DataOutput; |
22 | |
import java.io.IOException; |
23 | |
import java.util.Iterator; |
24 | |
|
25 | |
import org.apache.giraph.block_app.framework.api.BlockWorkerSendApi; |
26 | |
import org.apache.giraph.conf.TypesHolder; |
27 | |
import org.apache.giraph.edge.Edge; |
28 | |
import org.apache.giraph.edge.OutEdges; |
29 | |
import org.apache.giraph.graph.Vertex; |
30 | |
import org.apache.giraph.worker.WorkerAggregatorDelegator; |
31 | |
import org.apache.giraph.worker.WorkerGlobalCommUsage; |
32 | |
import org.apache.hadoop.io.Writable; |
33 | |
import org.apache.hadoop.io.WritableComparable; |
34 | |
|
35 | |
|
36 | |
|
37 | |
|
38 | |
|
39 | |
|
40 | |
|
41 | |
|
42 | |
|
43 | |
|
44 | |
|
45 | |
|
46 | |
@SuppressWarnings("rawtypes") |
47 | 0 | public class MigrationAbstractComputation<I extends WritableComparable, |
48 | |
V extends Writable, E extends Writable, M1 extends Writable, |
49 | |
M2 extends Writable> extends WorkerAggregatorDelegator<I, V, E> |
50 | |
implements TypesHolder<I, V, E, M1, M2>, Writable { |
51 | |
private BlockWorkerSendApi<I, V, E, M2> api; |
52 | |
private MigrationWorkerContext workerContext; |
53 | |
private long superstep; |
54 | |
|
55 | |
final void init( |
56 | |
BlockWorkerSendApi<I, V, E, M2> workerApi, |
57 | |
MigrationWorkerContext workerContext, |
58 | |
long superstep) { |
59 | 0 | this.api = workerApi; |
60 | 0 | this.workerContext = workerContext; |
61 | 0 | this.superstep = superstep; |
62 | 0 | setWorkerGlobalCommUsage((WorkerGlobalCommUsage) workerApi); |
63 | 0 | setConf(workerApi.getConf()); |
64 | 0 | } |
65 | |
|
66 | |
public void compute(Vertex<I, V, E> vertex, |
67 | |
Iterable<M1> messages) throws IOException { |
68 | 0 | } |
69 | |
|
70 | |
@Override |
71 | |
public void readFields(DataInput in) throws IOException { |
72 | 0 | } |
73 | |
|
74 | |
@Override |
75 | |
public void write(DataOutput out) throws IOException { |
76 | 0 | } |
77 | |
|
78 | |
public void preSuperstep() { |
79 | 0 | } |
80 | |
|
81 | |
public void postSuperstep() { |
82 | 0 | } |
83 | |
|
84 | |
@SuppressWarnings("deprecation") |
85 | |
public long getTotalNumVertices() { |
86 | 0 | return api.getTotalNumVertices(); |
87 | |
} |
88 | |
|
89 | |
@SuppressWarnings("deprecation") |
90 | |
public long getTotalNumEdges() { |
91 | 0 | return api.getTotalNumEdges(); |
92 | |
} |
93 | |
|
94 | |
public void sendMessage(I id, M2 message) { |
95 | 0 | api.sendMessage(id, message); |
96 | 0 | } |
97 | |
|
98 | |
public final void sendMessageToAllEdges(Vertex<I, V, E> vertex, M2 message) { |
99 | 0 | api.sendMessageToAllEdges(vertex, message); |
100 | 0 | } |
101 | |
|
102 | |
public final void sendMessageToMultipleEdges( |
103 | |
Iterator<I> vertexIdIterator, M2 message) { |
104 | 0 | api.sendMessageToMultipleEdges(vertexIdIterator, message); |
105 | 0 | } |
106 | |
|
107 | |
public final void addVertexRequest(I id, V value, |
108 | |
OutEdges<I, E> edges) throws IOException { |
109 | 0 | api.addVertexRequest(id, value, edges); |
110 | 0 | } |
111 | |
|
112 | |
public final void addVertexRequest(I id, V value) throws IOException { |
113 | 0 | api.addVertexRequest(id, value); |
114 | 0 | } |
115 | |
|
116 | |
public final void removeVertexRequest(I vertexId) throws IOException { |
117 | 0 | api.removeVertexRequest(vertexId); |
118 | 0 | } |
119 | |
|
120 | |
public final void addEdgeRequest(I sourceVertexId, |
121 | |
Edge<I, E> edge) throws IOException { |
122 | 0 | api.addEdgeRequest(sourceVertexId, edge); |
123 | 0 | } |
124 | |
|
125 | |
public final void removeEdgesRequest(I sourceVertexId, |
126 | |
I targetVertexId) throws IOException { |
127 | 0 | api.removeEdgesRequest(sourceVertexId, targetVertexId); |
128 | 0 | } |
129 | |
|
130 | |
@SuppressWarnings("unchecked") |
131 | |
public <W extends MigrationWorkerContext> W getWorkerContext() { |
132 | 0 | return (W) workerContext; |
133 | |
} |
134 | |
|
135 | |
|
136 | |
|
137 | |
|
138 | |
|
139 | |
|
140 | |
|
141 | |
|
142 | |
|
143 | |
|
144 | |
|
145 | 0 | public static class MigrationBasicComputation<I extends WritableComparable, |
146 | |
V extends Writable, E extends Writable, M extends Writable> |
147 | |
extends MigrationAbstractComputation<I, V, E, M, M> { |
148 | |
} |
149 | |
|
150 | |
|
151 | |
|
152 | |
|
153 | |
|
154 | |
|
155 | |
|
156 | |
|
157 | |
|
158 | |
|
159 | |
|
160 | 0 | public static class MigrationFullAbstractComputation |
161 | |
<I extends WritableComparable, V extends Writable, E extends Writable, |
162 | |
M1 extends Writable, M2 extends Writable> |
163 | |
extends MigrationAbstractComputation<I, V, E, M1, M2> { |
164 | |
public long getSuperstep() { |
165 | 0 | return super.superstep; |
166 | |
} |
167 | |
} |
168 | |
|
169 | |
|
170 | |
|
171 | |
|
172 | |
|
173 | |
|
174 | |
|
175 | |
|
176 | |
|
177 | |
|
178 | 0 | public static class MigrationFullBasicComputation |
179 | |
<I extends WritableComparable, V extends Writable, E extends Writable, |
180 | |
M extends Writable> |
181 | |
extends MigrationFullAbstractComputation<I, V, E, M, M> { |
182 | |
} |
183 | |
} |