1 /** 2 * Licensed to the Apache Software Foundation (ASF) under one 3 * or more contributor license agreements. See the NOTICE file 4 * distributed with this work for additional information 5 * regarding copyright ownership. The ASF licenses this file 6 * to you under the Apache License, Version 2.0 (the 7 * "License"); you may not use this file except in compliance 8 * with the License. You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 package org.apache.hadoop.hbase.ipc; 19 20 import java.net.InetAddress; 21 22 import org.apache.hadoop.hbase.classification.InterfaceAudience; 23 import org.apache.hadoop.hbase.protobuf.generated.HBaseProtos.VersionInfo; 24 import org.apache.hadoop.hbase.security.User; 25 26 @InterfaceAudience.Private 27 public interface RpcCallContext { 28 /** 29 * Check if the caller who made this IPC call has disconnected. 30 * If called from outside the context of IPC, this does nothing. 31 * @return < 0 if the caller is still connected. The time in ms 32 * since the disconnection otherwise 33 */ 34 long disconnectSince(); 35 36 /** 37 * If the client connected and specified a codec to use, then we will use this codec making 38 * cellblocks to return. If the client did not specify a codec, we assume it does not support 39 * cellblocks and will return all content protobuf'd (though it makes our serving slower). 40 * We need to ask this question per call because a server could be hosting both clients that 41 * support cellblocks while fielding requests from clients that do not. 42 * @return True if the client supports cellblocks, else return all content in pb 43 */ 44 boolean isClientCellBlockSupported(); 45 46 /** 47 * Returns the user credentials associated with the current RPC request or 48 * <code>null</code> if no credentials were provided. 49 * @return A User 50 */ 51 User getRequestUser(); 52 53 /** 54 * @return Current request's user name or null if none ongoing. 55 */ 56 String getRequestUserName(); 57 58 /** 59 * @return Address of remote client if a request is ongoing, else null 60 */ 61 InetAddress getRemoteAddress(); 62 63 /** 64 * @return the client version info, or null if the information is not present 65 */ 66 VersionInfo getClientVersionInfo(); 67 68 boolean isRetryImmediatelySupported(); 69 70 /** 71 * The size of response cells that have been accumulated so far. 72 * This along with the corresponding increment call is used to ensure that multi's or 73 * scans dont get too excessively large 74 */ 75 long getResponseCellSize(); 76 77 /** 78 * Add on the given amount to the retained cell size. 79 * 80 * This is not thread safe and not synchronized at all. If this is used by more than one thread 81 * then everything will break. Since this is called for every row synchronization would be too 82 * onerous. 83 */ 84 void incrementResponseCellSize(long cellSize); 85 86 long getResponseBlockSize(); 87 void incrementResponseBlockSize(long blockSize); 88 }