HBASE-25640 Support hbase rpc compression for remote rpc only

This commit is contained in:
Huaxiang Sun 2021-03-31 14:20:59 -07:00
parent 024248994f
commit abc22aa0a6
1 changed files with 13 additions and 1 deletions

View File

@ -31,6 +31,7 @@ import org.apache.hadoop.hbase.security.SecurityInfo;
import org.apache.hadoop.hbase.security.User;
import org.apache.hadoop.hbase.security.provider.SaslClientAuthenticationProvider;
import org.apache.hadoop.hbase.security.provider.SaslClientAuthenticationProviders;
import org.apache.hadoop.hbase.util.Addressing;
import org.apache.hadoop.hbase.util.EnvironmentEdgeManager;
import org.apache.hadoop.hbase.util.Pair;
import org.apache.hadoop.io.compress.CompressionCodec;
@ -89,7 +90,18 @@ abstract class RpcConnection {
MetricsConnection metrics) throws IOException {
this.timeoutTimer = timeoutTimer;
this.codec = codec;
this.compressor = compressor;
if (compressor != null) {
// Only enable compression for remote rpcs.
InetSocketAddress remoteAddr = Address.toSocketAddress(remoteId.getAddress());
if (!remoteAddr.isUnresolved() && Addressing.isLocalAddress(remoteAddr.getAddress())) {
this.compressor = null;
} else {
this.compressor = compressor;
}
} else {
this.compressor = null;
}
this.conf = conf;
this.metrics = metrics;
User ticket = remoteId.getTicket();