This project has retired. For details please refer to its
Attic page.
PairedPieceAndStage xref
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.internal;
19
20 import java.util.List;
21
22 import org.apache.giraph.block_app.framework.api.BlockMasterApi;
23 import org.apache.giraph.block_app.framework.api.BlockWorkerContextReceiveApi;
24 import org.apache.giraph.block_app.framework.api.BlockWorkerContextSendApi;
25 import org.apache.giraph.block_app.framework.api.BlockWorkerReceiveApi;
26 import org.apache.giraph.block_app.framework.api.BlockWorkerSendApi;
27 import org.apache.giraph.block_app.framework.piece.AbstractPiece;
28 import org.apache.giraph.block_app.framework.piece.AbstractPiece.InnerVertexSender;
29 import org.apache.giraph.block_app.framework.piece.interfaces.VertexReceiver;
30 import org.apache.hadoop.io.Writable;
31
32
33
34
35
36
37 @SuppressWarnings({ "rawtypes", "unchecked" })
38 public class PairedPieceAndStage<S> {
39 private final AbstractPiece piece;
40 private final S executionStage;
41
42 public PairedPieceAndStage(AbstractPiece piece, S executionStage) {
43 this.piece = piece;
44 this.executionStage = executionStage;
45 }
46
47 public S nextExecutionStage() {
48
49 return piece != null ?
50 (S) piece.nextExecutionStage(executionStage) : executionStage;
51 }
52
53 public S getExecutionStage() {
54 return executionStage;
55 }
56
57 public void registerReducers(BlockMasterApi masterApi) {
58 if (piece != null) {
59 piece.wrappedRegisterReducers(masterApi, executionStage);
60 }
61 }
62
63 public InnerVertexSender getVertexSender(BlockWorkerSendApi sendApi) {
64 if (piece != null) {
65 return piece.getWrappedVertexSender(sendApi, executionStage);
66 }
67 return null;
68 }
69
70 public void masterCompute(BlockMasterApi masterApi) {
71 if (piece != null) {
72 piece.masterCompute(masterApi, executionStage);
73 }
74 }
75
76 public VertexReceiver getVertexReceiver(
77 BlockWorkerReceiveApi receiveApi) {
78 if (piece != null) {
79 return piece.getVertexReceiver(receiveApi, executionStage);
80 }
81 return null;
82 }
83
84 public void workerContextSend(
85 BlockWorkerContextSendApi workerContextApi, Object workerValue) {
86 if (piece != null) {
87 piece.workerContextSend(workerContextApi, executionStage, workerValue);
88 }
89 }
90
91 public void workerContextReceive(
92 BlockWorkerContextReceiveApi workerContextApi,
93 Object workerValue, List<Writable> workerMessages) {
94 if (piece != null) {
95 piece.workerContextReceive(
96 workerContextApi, executionStage, workerValue, workerMessages);
97 }
98 }
99
100
101
102
103 public AbstractPiece getPiece() {
104 return piece;
105 }
106
107 @Override
108 public String toString() {
109 return "Piece " + piece + " in stage " + executionStage;
110 }
111 }