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;
19
20 import static com.google.common.base.Preconditions.checkNotNull;
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44 public class BlockApiHandle {
45 private transient BlockMasterApi masterApi;
46 private transient BlockWorkerReceiveApi workerReceiveApi;
47 private transient BlockWorkerSendApi workerSendApi;
48 private transient BlockWorkerContextReceiveApi workerContextReceiveApi;
49 private transient BlockWorkerContextSendApi workerContextSendApi;
50
51 public void setMasterApi(BlockMasterApi api) {
52 this.masterApi = api;
53 }
54
55 public void setWorkerReceiveApi(BlockWorkerReceiveApi api) {
56 this.workerReceiveApi = api;
57 }
58
59 public void setWorkerSendApi(BlockWorkerSendApi api) {
60 this.workerSendApi = api;
61 }
62
63 public void setWorkerContextReceiveApi(BlockWorkerContextReceiveApi api) {
64 this.workerContextReceiveApi = api;
65 }
66
67 public void setWorkerContextSendApi(BlockWorkerContextSendApi api) {
68 this.workerContextSendApi = api;
69 }
70
71 public boolean isMasterApiSet() {
72 return masterApi != null;
73 }
74
75 public boolean isWorkerReceiveApiSet() {
76 return workerReceiveApi != null;
77 }
78
79 public boolean isWorkerSendApiSet() {
80 return workerSendApi != null;
81 }
82
83 public boolean isWorkerContextReceiveApiSet() {
84 return workerContextReceiveApi != null;
85 }
86
87 public boolean isWorkerContextSendApiSet() {
88 return workerContextSendApi != null;
89 }
90
91 public BlockMasterApi getMasterApi() {
92 checkNotNull(masterApi,
93 "BlockMasterApi not valid in this context.");
94 return masterApi;
95 }
96
97 public BlockWorkerReceiveApi getWorkerReceiveApi() {
98 checkNotNull(workerReceiveApi,
99 "BlockWorkerReceiveApi not valid in this context.");
100 return workerReceiveApi;
101 }
102
103 public BlockWorkerSendApi getWorkerSendApi() {
104 checkNotNull(workerSendApi,
105 "BlockWorkerSendApi not valid in this context.");
106 return workerSendApi;
107 }
108
109 public BlockWorkerContextReceiveApi getWorkerContextReceiveApi() {
110 checkNotNull(workerContextReceiveApi,
111 "BlockWorkerContextReceiveApi not valid in this context");
112 return workerContextReceiveApi;
113 }
114
115 public BlockWorkerContextSendApi getWorkerContextSendApi() {
116 checkNotNull(workerContextSendApi,
117 "BlockWorkerContextSendApi not valid in this context");
118 return workerContextSendApi;
119 }
120 }