Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
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;
Expand Down Expand Up @@ -89,7 +90,18 @@ protected RpcConnection(Configuration conf, HashedWheelTimer timeoutTimer, Conne
MetricsConnection metrics) throws IOException {
this.timeoutTimer = timeoutTimer;
this.codec = codec;
this.compressor = compressor;
if (compressor != null) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: no need to check if compressor is null because you never read it, and subsequent code is apparently fine with a null value.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Checking if compressor is null is that it can avoid a dns resolution if compressor is null (no compression is configured), which is the common use case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, okay. A comment to this effect would help the casual reader.

// Only enable compression for remote rpcs.
InetSocketAddress remoteAddr = Address.toSocketAddress(remoteId.getAddress());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: this would be easier to read if you extract the isLocal(ConnectionId) logic into an external method. Then you can have a simpler conditional clause. Something like,

    this.compressor = isLocal(remoteId) ? null : compressor;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

will do.

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();
Expand Down