001/*
002 *
003 * Licensed to the Apache Software Foundation (ASF) under one
004 * or more contributor license agreements.  See the NOTICE file
005 * distributed with this work for additional information
006 * regarding copyright ownership.  The ASF licenses this file
007 * to you under the Apache License, Version 2.0 (the
008 * "License"); you may not use this file except in compliance
009 * with the License.  You may obtain a copy of the License at
010 *
011 * http://www.apache.org/licenses/LICENSE-2.0
012 *
013 * Unless required by applicable law or agreed to in writing, software
014 * distributed under the License is distributed on an "AS IS" BASIS,
015 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
016 * See the License for the specific language governing permissions and
017 * limitations under the License.
018 */
019
020package org.apache.hadoop.hbase.ipc;
021
022import java.io.IOException;
023import java.net.InetSocketAddress;
024
025import org.apache.hadoop.conf.Configuration;
026import org.apache.hadoop.hbase.CellScanner;
027import org.apache.hadoop.hbase.io.ByteBuffAllocator;
028import org.apache.hadoop.hbase.monitoring.MonitoredRPCHandler;
029import org.apache.hadoop.hbase.regionserver.RSRpcServices;
030import org.apache.hadoop.hbase.regionserver.slowlog.SlowLogRecorder;
031import org.apache.hadoop.hbase.util.Pair;
032import org.apache.hadoop.security.authorize.PolicyProvider;
033import org.apache.yetus.audience.InterfaceAudience;
034
035import org.apache.hbase.thirdparty.com.google.common.annotations.VisibleForTesting;
036import org.apache.hbase.thirdparty.com.google.protobuf.BlockingService;
037import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor;
038import org.apache.hbase.thirdparty.com.google.protobuf.Message;
039
040@InterfaceAudience.Private
041public interface RpcServerInterface {
042  void start();
043  boolean isStarted();
044
045  void stop();
046  void join() throws InterruptedException;
047
048  void setSocketSendBufSize(int size);
049  InetSocketAddress getListenerAddress();
050
051  /**
052   * @deprecated As of release 1.3, this will be removed in HBase 3.0
053   */
054  @Deprecated
055  Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md,
056    Message param, CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status)
057  throws IOException;
058
059  /**
060   * @deprecated As of release 2.0, this will be removed in HBase 3.0
061   */
062  @Deprecated
063  Pair<Message, CellScanner> call(BlockingService service, MethodDescriptor md, Message param,
064      CellScanner cellScanner, long receiveTime, MonitoredRPCHandler status, long startTime,
065      int timeout) throws IOException;
066
067  Pair<Message, CellScanner> call(RpcCall call, MonitoredRPCHandler status)
068      throws IOException;
069
070  void setErrorHandler(HBaseRPCErrorHandler handler);
071  HBaseRPCErrorHandler getErrorHandler();
072
073  /**
074   * Returns the metrics instance for reporting RPC call statistics
075   */
076  MetricsHBaseServer getMetrics();
077
078  /**
079   * Add/subtract from the current size of all outstanding calls.  Called on setup of a call to add
080   * call total size and then again at end of a call to remove the call size.
081   * @param diff Change (plus or minus)
082   */
083  void addCallSize(long diff);
084
085  /**
086   * Refresh authentication manager policy.
087   * @param pp
088   */
089  @VisibleForTesting
090  void refreshAuthManager(Configuration conf, PolicyProvider pp);
091
092  RpcScheduler getScheduler();
093
094  /**
095   * Allocator to allocate/free the ByteBuffers, those ByteBuffers can be on-heap or off-heap.
096   * @return byte buffer allocator
097   */
098  ByteBuffAllocator getByteBuffAllocator();
099
100  void setRsRpcServices(RSRpcServices rsRpcServices);
101
102  /**
103   * Set Online SlowLog Provider
104   *
105   * @param slowLogRecorder instance of {@link SlowLogRecorder}
106   */
107  void setSlowLogRecorder(final SlowLogRecorder slowLogRecorder);
108
109  /**
110   * @return Retrieve instance of {@link SlowLogRecorder} maintained by RpcServer
111   */
112  SlowLogRecorder getSlowLogRecorder();
113}