View Javadoc

1   /*
2    *
3    * Licensed to the Apache Software Foundation (ASF) under one
4    * or more contributor license agreements.  See the NOTICE file
5    * distributed with this work for additional information
6    * regarding copyright ownership.  The ASF licenses this file
7    * to you under the Apache License, Version 2.0 (the
8    * "License"); you may not use this file except in compliance
9    * with the License.  You may obtain a copy of the License at
10   *
11   * http://www.apache.org/licenses/LICENSE-2.0
12   *
13   * Unless required by applicable law or agreed to in writing, software
14   * distributed under the License is distributed on an "AS IS" BASIS,
15   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16   * See the License for the specific language governing permissions and
17   * limitations under the License.
18   */
19  
20  package org.apache.hadoop.hbase.ipc;
21  
22  import java.io.IOException;
23  import java.lang.reflect.Method;
24  import java.net.InetSocketAddress;
25  
26  import org.apache.hadoop.classification.InterfaceAudience;
27  import org.apache.hadoop.hbase.CellScanner;
28  import org.apache.hadoop.hbase.IpcProtocol;
29  import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
30  import org.apache.hadoop.hbase.protobuf.generated.RPCProtos.RequestHeader;
31  import org.apache.hadoop.hbase.util.Pair;
32  
33  import com.google.common.base.Function;
34  import com.google.protobuf.Message;
35  
36  @InterfaceAudience.Private
37  public interface RpcServer {
38    // TODO: Needs cleanup.  Why a 'start', and then a 'startThreads' and an 'openServer'?
39    // Also, the call takes a RpcRequestBody, an already composed combination of
40    // rpc Request and metadata.  Should disentangle metadata and rpc Request Message.
41  
42    void setSocketSendBufSize(int size);
43  
44    void start();
45  
46    void stop();
47  
48    void join() throws InterruptedException;
49  
50    InetSocketAddress getListenerAddress();
51  
52    /** Called for each call.
53     * @param method Method to invoke.
54     * @param param parameter
55     * @param receiveTime time
56     * @param status
57     * @return Message Protobuf response Message and optionally the Cells that make up the response.
58     * @throws java.io.IOException e
59     */
60    Pair<Message, CellScanner> call(Class<? extends IpcProtocol> protocol, Method method,
61      Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
62    throws IOException;
63  
64    void setErrorHandler(HBaseRPCErrorHandler handler);
65  
66    void openServer();
67  
68    void startThreads();
69  
70    /**
71     * Returns the metrics instance for reporting RPC call statistics
72     */
73    MetricsHBaseServer getMetrics();
74  
75    public void setQosFunction(Function<Pair<RequestHeader, Message>, Integer> newFunc);
76  }