Classes in this File | Line Coverage | Branch Coverage | Complexity | ||||
WorkerClient |
|
| 1.0;1 |
1 | /* | |
2 | * Licensed to the Apache Software Foundation (ASF) under one | |
3 | * or more contributor license agreements. See the NOTICE file | |
4 | * distributed with this work for additional information | |
5 | * regarding copyright ownership. The ASF licenses this file | |
6 | * to you under the Apache License, Version 2.0 (the | |
7 | * "License"); you may not use this file except in compliance | |
8 | * with the License. You may obtain a copy of the License at | |
9 | * | |
10 | * http://www.apache.org/licenses/LICENSE-2.0 | |
11 | * | |
12 | * Unless required by applicable law or agreed to in writing, software | |
13 | * distributed under the License is distributed on an "AS IS" BASIS, | |
14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | |
15 | * See the License for the specific language governing permissions and | |
16 | * limitations under the License. | |
17 | */ | |
18 | ||
19 | package org.apache.giraph.comm; | |
20 | ||
21 | import org.apache.giraph.comm.flow_control.FlowControl; | |
22 | import org.apache.giraph.comm.requests.WritableRequest; | |
23 | ||
24 | import org.apache.giraph.partition.PartitionOwner; | |
25 | import org.apache.hadoop.io.Writable; | |
26 | import org.apache.hadoop.io.WritableComparable; | |
27 | ||
28 | import java.io.IOException; | |
29 | ||
30 | /** | |
31 | * Public interface for workers to establish connections and send aggregated | |
32 | * requests. | |
33 | * | |
34 | * @param <I> Vertex id | |
35 | * @param <V> Vertex value | |
36 | * @param <E> Edge value | |
37 | */ | |
38 | @SuppressWarnings("rawtypes") | |
39 | public interface WorkerClient<I extends WritableComparable, | |
40 | V extends Writable, E extends Writable> { | |
41 | ||
42 | /** | |
43 | * Setup the client. | |
44 | */ | |
45 | /*if[HADOOP_NON_SECURE] | |
46 | void setup(); | |
47 | else[HADOOP_NON_SECURE]*/ | |
48 | /** | |
49 | * Setup the client. | |
50 | * | |
51 | * @param authenticate whether to SASL authenticate with server or not: | |
52 | * set by giraph.authenticate configuration option. | |
53 | */ | |
54 | void setup(boolean authenticate); | |
55 | /*end[HADOOP_NON_SECURE]*/ | |
56 | ||
57 | /** | |
58 | * Lookup PartitionOwner for a vertex. | |
59 | * | |
60 | * @param vertexId id to look up. | |
61 | * @return PartitionOwner holding the vertex. | |
62 | */ | |
63 | PartitionOwner getVertexPartitionOwner(I vertexId); | |
64 | ||
65 | /** | |
66 | * Make sure that all the connections to workers and master have been | |
67 | * established. | |
68 | */ | |
69 | void openConnections(); | |
70 | ||
71 | /** | |
72 | * Send a request to a remote server (should be already connected) | |
73 | * | |
74 | * @param destTaskId Destination worker id | |
75 | * @param request Request to send | |
76 | */ | |
77 | void sendWritableRequest(int destTaskId, WritableRequest request); | |
78 | ||
79 | /** | |
80 | * Wait until all the outstanding requests are completed. | |
81 | */ | |
82 | void waitAllRequests(); | |
83 | ||
84 | /** | |
85 | * Closes all connections. | |
86 | * | |
87 | * @throws IOException | |
88 | */ | |
89 | void closeConnections() throws IOException; | |
90 | ||
91 | /*if[HADOOP_NON_SECURE] | |
92 | else[HADOOP_NON_SECURE]*/ | |
93 | /** | |
94 | * Authenticates, as client, with another BSP worker, as server. | |
95 | * | |
96 | * @throws IOException | |
97 | */ | |
98 | void authenticate() throws IOException; | |
99 | /*end[HADOOP_NON_SECURE]*/ | |
100 | ||
101 | /** | |
102 | * @return the flow control used in sending requests | |
103 | */ | |
104 | FlowControl getFlowControl(); | |
105 | } |