001/* 002 * Licensed to the Apache Software Foundation (ASF) under one 003 * or more contributor license agreements. See the NOTICE file 004 * distributed with this work for additional information 005 * regarding copyright ownership. The ASF licenses this file 006 * to you under the Apache License, Version 2.0 (the 007 * "License"); you may not use this file except in compliance 008 * with the License. You may obtain a copy of the License at 009 * 010 * http://www.apache.org/licenses/LICENSE-2.0 011 * 012 * Unless required by applicable law or agreed to in writing, software 013 * distributed under the License is distributed on an "AS IS" BASIS, 014 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 015 * See the License for the specific language governing permissions and 016 * limitations under the License. 017 */ 018package org.apache.hadoop.hbase.ipc; 019 020import java.io.IOException; 021import java.util.Map; 022import org.apache.hadoop.conf.Configuration; 023import org.apache.hadoop.hbase.CellScanner; 024import org.apache.hadoop.hbase.HBaseInterfaceAudience; 025import org.apache.yetus.audience.InterfaceAudience; 026import org.apache.yetus.audience.InterfaceStability; 027 028import org.apache.hbase.thirdparty.com.google.protobuf.BlockingService; 029import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor; 030import org.apache.hbase.thirdparty.com.google.protobuf.Message; 031 032import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader; 033 034/** 035 * Interface of all necessary to carry out a RPC method invocation on the server. 036 */ 037@InterfaceAudience.LimitedPrivate({ HBaseInterfaceAudience.COPROC, HBaseInterfaceAudience.PHOENIX }) 038@InterfaceStability.Evolving 039public interface RpcCall extends RpcCallContext { 040 041 /** Returns The service of this call. */ 042 BlockingService getService(); 043 044 /** Returns The service method. */ 045 MethodDescriptor getMethod(); 046 047 /** Returns The call parameter message. */ 048 Message getParam(); 049 050 /** Returns The CellScanner that can carry input and result payload. */ 051 CellScanner getCellScanner(); 052 053 /** Returns The timestamp when the call is constructed. */ 054 long getReceiveTime(); 055 056 /** Returns The time when the call starts to be executed. */ 057 long getStartTime(); 058 059 /** 060 * Set the time when the call starts to be executed. 061 */ 062 void setStartTime(long startTime); 063 064 /** Returns The timeout of this call. */ 065 int getTimeout(); 066 067 /** Returns The Priority of this call. */ 068 int getPriority(); 069 070 /** 071 * Return the deadline of this call. If we can not complete this call in time, we can throw a 072 * TimeoutIOException and RPCServer will drop it. 073 * @return The system timestamp of deadline. 074 */ 075 long getDeadline(); 076 077 /** 078 * Used to calculate the request call queue size. If the total request call size exceeds a limit, 079 * the call will be rejected. 080 * @return The raw size of this call. 081 */ 082 long getSize(); 083 084 /** Returns The request header of this call. */ 085 RequestHeader getHeader(); 086 087 /** 088 * Returns the map of attributes specified when building the Connection. 089 * @see org.apache.hadoop.hbase.client.ConnectionFactory#createConnection(Configuration, 090 * ExecutorService, User, Map) 091 */ 092 Map<String, byte[]> getConnectionAttributes(); 093 094 /** 095 * Returns the map of attributes specified when building the request. This map is lazily evaluated 096 * so if you only need a single attribute then it may be cheaper to use 097 * {@link #getRequestAttribute(String)} 098 * @see org.apache.hadoop.hbase.client.TableBuilder#setRequestAttribute(String, byte[]) 099 */ 100 Map<String, byte[]> getRequestAttributes(); 101 102 /** 103 * Returns a single request attribute value, or null if no value is present. If you need many 104 * request attributes then you should fetch the lazily evaluated map via 105 * {@link #getRequestAttributes()} 106 * @see org.apache.hadoop.hbase.client.TableBuilder#setRequestAttribute(String, byte[]) 107 */ 108 byte[] getRequestAttribute(String key); 109 110 /** Returns Port of remote address in this call */ 111 int getRemotePort(); 112 113 /** 114 * Set the response resulting from this RPC call. 115 * @param param The result message as response. 116 * @param cells The CellScanner that possibly carries the payload. 117 * @param errorThrowable The error Throwable resulting from the call. 118 * @param error Extra error message. 119 */ 120 void setResponse(Message param, CellScanner cells, Throwable errorThrowable, String error); 121 122 /** 123 * Send the response of this RPC call. Implementation provides the underlying facility 124 * (connection, etc) to send. 125 */ 126 void sendResponseIfReady() throws IOException; 127 128 /** 129 * Do the necessary cleanup after the call if needed. 130 */ 131 void cleanup(); 132 133 /** Returns A short string format of this call without possibly lengthy params */ 134 String toShortString(); 135 136 void updateFsReadTime(long latencyMillis); 137 138 long getFsReadTime(); 139}