This project has retired. For details please refer to its Attic page.
MasterClient xref
View Javadoc

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 java.io.IOException;
22  
23  import org.apache.giraph.comm.flow_control.FlowControl;
24  import org.apache.giraph.comm.requests.WritableRequest;
25  import org.apache.hadoop.io.Writable;
26  
27  /**
28   * Interface for master to send messages to workers
29   */
30  public interface MasterClient {
31    /**
32     * Make sure that all the connections to workers have been established.
33     */
34    void openConnections();
35  
36    /**
37     * Sends aggregator to its owner
38     *
39     * @param name Name of the object
40     * @param type Global communication type
41     * @param value Object value
42     * @throws IOException
43     */
44    void sendToOwner(String name, GlobalCommType type, Writable value)
45      throws IOException;
46  
47    /**
48     * Flush aggregated values cache.
49     */
50    void finishSendingValues() throws IOException;
51  
52    /**
53     * Flush all outgoing messages.  This will synchronously ensure that all
54     * messages have been send and delivered prior to returning.
55     */
56    void flush();
57  
58    /**
59     * Send a request to a remote server (should be already connected)
60     *
61     * @param destTaskId Destination worker id
62     * @param request Request to send
63     */
64    void sendWritableRequest(int destTaskId, WritableRequest request);
65  
66    /**
67     * Closes all connections.
68     */
69    void closeConnections();
70  
71    /**
72     * Get the reference to the flow control policy used for sending requests
73     *
74     * @return reference to the flow control policy
75     */
76    FlowControl getFlowControl();
77  }
78