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 org.apache.hadoop.hbase.CellScanner; 022import org.apache.hadoop.hbase.HBaseInterfaceAudience; 023import org.apache.yetus.audience.InterfaceAudience; 024import org.apache.yetus.audience.InterfaceStability; 025 026import org.apache.hbase.thirdparty.com.google.protobuf.BlockingService; 027import org.apache.hbase.thirdparty.com.google.protobuf.Descriptors.MethodDescriptor; 028import org.apache.hbase.thirdparty.com.google.protobuf.Message; 029 030import org.apache.hadoop.hbase.shaded.protobuf.generated.RPCProtos.RequestHeader; 031 032/** 033 * Interface of all necessary to carry out a RPC method invocation on the server. 034 */ 035@InterfaceAudience.LimitedPrivate({ HBaseInterfaceAudience.COPROC, HBaseInterfaceAudience.PHOENIX }) 036@InterfaceStability.Evolving 037public interface RpcCall extends RpcCallContext { 038 039 /** Returns The service of this call. */ 040 BlockingService getService(); 041 042 /** Returns The service method. */ 043 MethodDescriptor getMethod(); 044 045 /** Returns The call parameter message. */ 046 Message getParam(); 047 048 /** Returns The CellScanner that can carry input and result payload. */ 049 CellScanner getCellScanner(); 050 051 /** Returns The timestamp when the call is constructed. */ 052 long getReceiveTime(); 053 054 /** Returns The time when the call starts to be executed. */ 055 long getStartTime(); 056 057 /** 058 * Set the time when the call starts to be executed. 059 */ 060 void setStartTime(long startTime); 061 062 /** Returns The timeout of this call. */ 063 int getTimeout(); 064 065 /** Returns The Priority of this call. */ 066 int getPriority(); 067 068 /** 069 * Return the deadline of this call. If we can not complete this call in time, we can throw a 070 * TimeoutIOException and RPCServer will drop it. 071 * @return The system timestamp of deadline. 072 */ 073 long getDeadline(); 074 075 /** 076 * Used to calculate the request call queue size. If the total request call size exceeds a limit, 077 * the call will be rejected. 078 * @return The raw size of this call. 079 */ 080 long getSize(); 081 082 /** Returns The request header of this call. */ 083 RequestHeader getHeader(); 084 085 /** Returns Port of remote address in this call */ 086 int getRemotePort(); 087 088 /** 089 * Set the response resulting from this RPC call. 090 * @param param The result message as response. 091 * @param cells The CellScanner that possibly carries the payload. 092 * @param errorThrowable The error Throwable resulting from the call. 093 * @param error Extra error message. 094 */ 095 void setResponse(Message param, CellScanner cells, Throwable errorThrowable, String error); 096 097 /** 098 * Send the response of this RPC call. Implementation provides the underlying facility 099 * (connection, etc) to send. n 100 */ 101 void sendResponseIfReady() throws IOException; 102 103 /** 104 * Do the necessary cleanup after the call if needed. 105 */ 106 void cleanup(); 107 108 /** Returns A short string format of this call without possibly lengthy params */ 109 String toShortString(); 110}