From 5bc06555292d28e0e53861f4b51300c38db1184e Mon Sep 17 00:00:00 2001 From: tedyu Date: Fri, 1 Jul 2016 03:14:51 -0700 Subject: [PATCH] HBASE-16114 Get regionLocation of required regions only for MR jobs (Thiruvel Thirumoolan) --- .../hbase/mapreduce/TableInputFormatBase.java | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java index 8d59016911a..148f367135a 100644 --- a/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java +++ b/hbase-server/src/main/java/org/apache/hadoop/hbase/mapreduce/TableInputFormatBase.java @@ -276,20 +276,6 @@ extends InputFormat { if ( !includeRegionInSplit(keys.getFirst()[i], keys.getSecond()[i])) { continue; } - HRegionLocation location = regionLocator.getRegionLocation(keys.getFirst()[i], false); - // The below InetSocketAddress creation does a name resolution. - InetSocketAddress isa = new InetSocketAddress(location.getHostname(), location.getPort()); - if (isa.isUnresolved()) { - LOG.warn("Failed resolve " + isa); - } - InetAddress regionAddress = isa.getAddress(); - String regionLocation; - try { - regionLocation = reverseDNS(regionAddress); - } catch (NamingException e) { - LOG.warn("Cannot resolve the host name for " + regionAddress + " because of " + e); - regionLocation = location.getHostname(); - } byte[] startRow = scan.getStartRow(); byte[] stopRow = scan.getStopRow(); @@ -306,6 +292,21 @@ extends InputFormat { keys.getSecond()[i].length > 0 ? keys.getSecond()[i] : stopRow; + HRegionLocation location = regionLocator.getRegionLocation(keys.getFirst()[i], false); + // The below InetSocketAddress creation does a name resolution. + InetSocketAddress isa = new InetSocketAddress(location.getHostname(), location.getPort()); + if (isa.isUnresolved()) { + LOG.warn("Failed resolve " + isa); + } + InetAddress regionAddress = isa.getAddress(); + String regionLocation; + try { + regionLocation = reverseDNS(regionAddress); + } catch (NamingException e) { + LOG.warn("Cannot resolve the host name for " + regionAddress + " because of " + e); + regionLocation = location.getHostname(); + } + byte[] regionName = location.getRegionInfo().getRegionName(); String encodedRegionName = location.getRegionInfo().getEncodedName(); long regionSize = sizeCalculator.getRegionSize(regionName);