Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add capability to configure DNS lookup latency WARN threshold #204

Open
wants to merge 1 commit into
base: next
Choose a base branch
from
Open
Show file tree
Hide file tree
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
12 changes: 9 additions & 3 deletions src/Config.java
Original file line number Diff line number Diff line change
Expand Up @@ -314,7 +314,7 @@ private void loadSystemAndDefaults() {
default_map.put("hbase.ipc.client.connection.idle_read_timeout", "0");
default_map.put("hbase.ipc.client.connection.idle_write_timeout", "0");

/**
/*
* How many different counters do we want to keep in memory for buffering.
* Each entry requires storing the table name, row key, family name and
* column qualifier, plus 4 small objects.
Expand All @@ -327,6 +327,11 @@ private void loadSystemAndDefaults() {
* to expect they'd tune this value to cater to their unusual requirements.
*/
default_map.put("hbase.increments.buffer_size", "65535");

/*
* HBaseClient will logs WARN if DNS-lookup takes longer than this threshold.
*/
default_map.put("hbase.dns.latency_warn_threshold_nanos", "3000000");

/* --- HBase configs (same names as their HTable counter parts ---
* Note that the defaults may differ though */
Expand All @@ -335,7 +340,8 @@ private void loadSystemAndDefaults() {
default_map.put("hbase.zookeeper.znode.parent", "/hbase");
default_map.put("hbase.zookeeper.session.timeout", "5000");
default_map.put("hbase.client.retries.number", "10");
/** Note that HBase's client defaults to 60 seconds. We default to 0 for
/*
* Note that HBase's client defaults to 60 seconds. We default to 0 for
* AsyncHBase backwards compatibility. This may change in the future.
*/
default_map.put("hbase.rpc.timeout", "0");
Expand Down Expand Up @@ -408,4 +414,4 @@ private void loadHashMap(final Properties props) {
}
}

}
}
19 changes: 12 additions & 7 deletions src/HBaseClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -466,6 +466,9 @@ public final class HBaseClient {

/** Whether or not increments are batched. */
private boolean increment_buffer_durable = false;

/** WARN threshold of DNS lookup latency */
private final long dns_latency_warn_threshold_nanos;

// ------------------------ //
// Client usage statistics. //
Expand Down Expand Up @@ -596,6 +599,7 @@ public HBaseClient(final String quorum_spec, final String base_path,
nsre_low_watermark = config.getInt("hbase.nsre.low_watermark");
nsre_high_watermark = config.getInt("hbase.nsre.high_watermark");
jitter_percent = config.getInt("hbase.rpcs.jitter");
dns_latency_warn_threshold_nanos = config.getLong("hbase.dns.latency_warn_threshold_nanos");
if (config.properties.containsKey("hbase.increments.durable")) {
increment_buffer_durable = config.getBoolean("hbase.increments.durable");
}
Expand Down Expand Up @@ -675,6 +679,7 @@ public HBaseClient(final Config config,
nsre_low_watermark = config.getInt("hbase.nsre.low_watermark");
nsre_high_watermark = config.getInt("hbase.nsre.high_watermark");
jitter_percent = config.getInt("hbase.rpcs.jitter");
dns_latency_warn_threshold_nanos = config.getLong("hbase.dns.latency_warn_threshold_nanos");

if (config.properties.containsKey("hbase.increments.durable")) {
increment_buffer_durable = config.getBoolean("hbase.increments.durable");
Expand Down Expand Up @@ -2700,7 +2705,7 @@ private RegionLocation toRegionLocation(final ArrayList<KeyValue> meta_row) {
+ " doesn't contain `:' to separate the `host:port'"
+ Bytes.pretty(hostport), kv);
}
host = getIP(new String(hostport, 0, colon));
host = getIP(new String(hostport, 0, colon), dns_latency_warn_threshold_nanos);
try {
port = parsePortNumber(new String(hostport, colon + 1,
hostport.length - colon - 1));
Expand Down Expand Up @@ -3320,7 +3325,7 @@ RegionClient discoverRegion(final ArrayList<KeyValue> meta_row) {
+ " doesn't contain `:' to separate the `host:port'"
+ Bytes.pretty(hostport), kv);
}
host = getIP(new String(hostport, 0, colon));
host = getIP(new String(hostport, 0, colon), dns_latency_warn_threshold_nanos);
try {
port = parsePortNumber(new String(hostport, colon + 1,
hostport.length - colon - 1));
Expand Down Expand Up @@ -4303,7 +4308,7 @@ private InetSocketAddress slowSearchClientIP(final RegionClient client) {
LOG.error("WTF? Should never happen! No `:' found in " + hostport);
return null;
}
final String host = getIP(hostport.substring(0, lastColon));
final String host = getIP(hostport.substring(0, lastColon), dns_latency_warn_threshold_nanos);
int port;
try {
port = parsePortNumber(hostport.substring(lastColon + 1,
Expand Down Expand Up @@ -4795,7 +4800,7 @@ protected RegionClient handleRootZnode(final byte[] data) {
}
final int port = parsePortNumber(new String(data, firstsep + 1,
portend - firstsep - 1));
final String ip = getIP(host);
final String ip = getIP(host, dns_latency_warn_threshold_nanos);
if (ip == null) {
LOG.error("Couldn't resolve the IP of the -ROOT- region from "
+ host + " in \"" + Bytes.pretty(data) + '"');
Expand Down Expand Up @@ -4840,7 +4845,7 @@ protected RegionClient handleMetaZnode(final byte[] data) {
final ZooKeeperPB.MetaRegionServer meta =
ZooKeeperPB.MetaRegionServer.newBuilder()
.mergeFrom(data, offset, data.length - offset).build();
ip = getIP(meta.getServer().getHostName());
ip = getIP(meta.getServer().getHostName(), dns_latency_warn_threshold_nanos);
port = meta.getServer().getPort();
} catch (InvalidProtocolBufferException e) {
LOG.error("Failed to parse the protobuf in " + Bytes.pretty(data), e);
Expand Down Expand Up @@ -4898,7 +4903,7 @@ private boolean getRootRegion() {
* @return The IP address associated with the given hostname,
* or {@code null} if the address couldn't be resolved.
*/
private static String getIP(final String host) {
private static String getIP(final String host, final long latencyWarnThresholdNanos) {
final long start = System.nanoTime();
try {
boolean preferV6 = Boolean.valueOf(
Expand Down Expand Up @@ -4928,7 +4933,7 @@ private static String getIP(final String host) {
if (latency > 500000/*ns*/ && LOG.isDebugEnabled()) {
LOG.debug("Resolved IP of `" + host + "' to "
+ ip + " in " + latency + "ns");
} else if (latency >= 3000000/*ns*/) {
} else if (latency >= latencyWarnThresholdNanos) {
LOG.warn("Slow DNS lookup! Resolved IP of `" + host + "' to "
+ ip + " in " + latency + "ns");
}
Expand Down