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.net.InetSocketAddress;
24  
25  import org.apache.hadoop.classification.InterfaceAudience;
26  import org.apache.hadoop.hbase.CellScanner;
27  import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
28  import org.apache.hadoop.hbase.util.Pair;
29  import org.apache.hadoop.security.authorize.PolicyProvider;
30  
31  import com.google.common.annotations.VisibleForTesting;
32  import com.google.protobuf.BlockingService;
33  import com.google.protobuf.Descriptors.MethodDescriptor;
34  import com.google.protobuf.Message;
35  import com.google.protobuf.ServiceException;
36  
37  /**
38   * RpcServer Interface.
39   * Start calls {@link #openServer()} and then {@link #startThreads()}.  Prefer {@link #start()}
40   * and {@link #stop()}.  Only use {@link #openServer()} and {@link #startThreads()} if in a
41   * situation where you could start getting requests though the server not up and fully
42   * initiaalized.
43   */
44  @InterfaceAudience.Private
45  public interface RpcServerInterface {
46    void start();
47    void openServer();
48    void startThreads();
49    boolean isStarted();
50  
51    void stop();
52    void join() throws InterruptedException;
53  
54    void setSocketSendBufSize(int size);
55    InetSocketAddress getListenerAddress();
56  
57    Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
58      Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
59    throws IOException, ServiceException;
60  
61    void setErrorHandler(HBaseRPCErrorHandler handler);
62    HBaseRPCErrorHandler getErrorHandler();
63  
64    /**
65     * Returns the metrics instance for reporting RPC call statistics
66     */
67    MetricsHBaseServer getMetrics();
68  
69    /**
70     * Add/subtract from the current size of all outstanding calls.  Called on setup of a call to add
71     * call total size and then again at end of a call to remove the call size.
72     * @param diff Change (plus or minus)
73     */
74    void addCallSize(long diff);
75  
76    /**
77     * Refresh authentication manager policy.
78     * @param pp
79     */
80    @VisibleForTesting
81    void refreshAuthManager(PolicyProvider pp);
82  }