1 | |
|
2 | |
|
3 | |
|
4 | |
|
5 | |
|
6 | |
|
7 | |
|
8 | |
|
9 | |
|
10 | |
|
11 | |
|
12 | |
|
13 | |
|
14 | |
|
15 | |
|
16 | |
|
17 | |
|
18 | |
package org.apache.giraph.block_app.framework.api.giraph; |
19 | |
|
20 | |
import org.apache.giraph.block_app.framework.api.BlockWorkerContextReceiveApi; |
21 | |
import org.apache.giraph.block_app.framework.api.BlockWorkerContextSendApi; |
22 | |
import org.apache.giraph.block_app.framework.api.Counter; |
23 | |
import org.apache.giraph.block_app.framework.internal.BlockCounters; |
24 | |
import org.apache.giraph.conf.ImmutableClassesGiraphConfiguration; |
25 | |
import org.apache.giraph.worker.WorkerContext; |
26 | |
import org.apache.hadoop.io.Writable; |
27 | |
import org.apache.hadoop.io.WritableComparable; |
28 | |
|
29 | |
|
30 | |
|
31 | |
|
32 | |
|
33 | |
|
34 | |
|
35 | |
|
36 | 0 | final class BlockWorkerContextApiWrapper |
37 | |
<I extends WritableComparable, WM extends Writable> implements |
38 | |
BlockWorkerContextReceiveApi<I>, BlockWorkerContextSendApi<I, WM> { |
39 | |
private final WorkerContext workerContext; |
40 | |
|
41 | 0 | public BlockWorkerContextApiWrapper(WorkerContext workerContext) { |
42 | 0 | this.workerContext = workerContext; |
43 | 0 | } |
44 | |
|
45 | |
@Override |
46 | |
public ImmutableClassesGiraphConfiguration<?, ?, ?> getConf() { |
47 | 0 | return workerContext.getConf(); |
48 | |
} |
49 | |
|
50 | |
@Override |
51 | |
public int getWorkerCount() { |
52 | 0 | return workerContext.getWorkerCount(); |
53 | |
} |
54 | |
|
55 | |
@Override |
56 | |
public int getMyWorkerIndex() { |
57 | 0 | return workerContext.getMyWorkerIndex(); |
58 | |
} |
59 | |
|
60 | |
@Override |
61 | |
public int getWorkerForVertex(I vertexId) { |
62 | 0 | return workerContext.getWorkerForVertex(vertexId); |
63 | |
} |
64 | |
|
65 | |
@Override |
66 | |
public <A extends Writable> A getAggregatedValue(String name) { |
67 | 0 | return workerContext.getAggregatedValue(name); |
68 | |
} |
69 | |
|
70 | |
@Override |
71 | |
public <A extends Writable> void aggregate(String name, A value) { |
72 | 0 | workerContext.aggregate(name, value); |
73 | 0 | } |
74 | |
|
75 | |
@Override |
76 | |
public void sendMessageToWorker(WM message, int workerIndex) { |
77 | 0 | workerContext.sendMessageToWorker(message, workerIndex); |
78 | 0 | } |
79 | |
|
80 | |
@Override |
81 | |
public <B extends Writable> B getBroadcast(String name) { |
82 | 0 | return workerContext.getBroadcast(name); |
83 | |
} |
84 | |
|
85 | |
@Override |
86 | |
public long getTotalNumEdges() { |
87 | 0 | return workerContext.getTotalNumEdges(); |
88 | |
} |
89 | |
|
90 | |
@Override |
91 | |
public long getTotalNumVertices() { |
92 | 0 | return workerContext.getTotalNumVertices(); |
93 | |
} |
94 | |
|
95 | |
@Override |
96 | |
public Counter getCounter(String group, String name) { |
97 | 0 | return BlockCounters.getCounter(workerContext.getContext(), group, name); |
98 | |
} |
99 | |
|
100 | |
@Override |
101 | |
public void progress() { |
102 | 0 | workerContext.getContext().progress(); |
103 | 0 | } |
104 | |
|
105 | |
@Override |
106 | |
public void setStatus(String status) { |
107 | 0 | workerContext.getContext().setStatus(status); |
108 | 0 | } |
109 | |
} |