HBASE-26286: Add support for specifying store file tracker when restoring or cloning...
[hbase.git] / hbase-server / src / main / java / org / apache / hadoop / hbase / ipc / RpcCallContext.java
blob6a4d3a29a52d179d9b3668beb1550d2b7234b39e
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
10 * http://www.apache.org/licenses/LICENSE-2.0
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.
18 package org.apache.hadoop.hbase.ipc;
20 import java.net.InetAddress;
21 import java.util.Optional;
23 import org.apache.yetus.audience.InterfaceAudience;
24 import org.apache.hadoop.hbase.shaded.protobuf.generated.HBaseProtos.VersionInfo;
25 import org.apache.hadoop.hbase.security.User;
27 /**
28 * Interface of all necessary to carry out a RPC service invocation on the server. This interface
29 * focus on the information needed or obtained during the actual execution of the service method.
31 @InterfaceAudience.Private
32 public interface RpcCallContext {
33 /**
34 * Check if the caller who made this IPC call has disconnected.
35 * If called from outside the context of IPC, this does nothing.
36 * @return < 0 if the caller is still connected. The time in ms
37 * since the disconnection otherwise
39 long disconnectSince();
41 /**
42 * If the client connected and specified a codec to use, then we will use this codec making
43 * cellblocks to return. If the client did not specify a codec, we assume it does not support
44 * cellblocks and will return all content protobuf'd (though it makes our serving slower).
45 * We need to ask this question per call because a server could be hosting both clients that
46 * support cellblocks while fielding requests from clients that do not.
47 * @return True if the client supports cellblocks, else return all content in pb
49 boolean isClientCellBlockSupported();
51 /**
52 * Returns the user credentials associated with the current RPC request or not present if no
53 * credentials were provided.
54 * @return A User
56 Optional<User> getRequestUser();
58 /**
59 * @return Current request's user name or not present if none ongoing.
61 default Optional<String> getRequestUserName() {
62 return getRequestUser().map(User::getShortName);
65 /**
66 * @return Address of remote client in this call
68 InetAddress getRemoteAddress();
70 /**
71 * @return the client version info, or null if the information is not present
73 VersionInfo getClientVersionInfo();
75 /**
76 * Sets a callback which has to be executed at the end of this RPC call. Such a callback is an
77 * optional one for any Rpc call.
79 * @param callback
81 void setCallBack(RpcCallback callback);
83 boolean isRetryImmediatelySupported();
85 /**
86 * The size of response cells that have been accumulated so far.
87 * This along with the corresponding increment call is used to ensure that multi's or
88 * scans dont get too excessively large
90 long getResponseCellSize();
92 /**
93 * Add on the given amount to the retained cell size.
95 * This is not thread safe and not synchronized at all. If this is used by more than one thread
96 * then everything will break. Since this is called for every row synchronization would be too
97 * onerous.
99 void incrementResponseCellSize(long cellSize);
101 long getResponseBlockSize();
103 void incrementResponseBlockSize(long blockSize);
105 long getResponseExceptionSize();
106 void incrementResponseExceptionSize(long exceptionSize);