incubator-accumulo-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ktur...@apache.org
Subject svn commit: r1243756 - /incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
Date Tue, 14 Feb 2012 00:22:37 GMT
Author: kturner
Date: Tue Feb 14 00:22:35 2012
New Revision: 1243756

URL: http://svn.apache.org/viewvc?rev=1243756&view=rev
Log:
ACCUMULO-395 modified AccumuloInputFormat to return hostnames instead of ip addrs for input
split locations.  Returning ips did not result in mappers running locally.

Modified:
    incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java

Modified: incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
URL: http://svn.apache.org/viewvc/incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java?rev=1243756&r1=1243755&r2=1243756&view=diff
==============================================================================
--- incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
(original)
+++ incubator/accumulo/branches/1.4/src/core/src/main/java/org/apache/accumulo/core/client/mapreduce/InputFormatBase.java
Tue Feb 14 00:22:35 2012
@@ -26,6 +26,7 @@ import java.io.IOException;
 import java.io.UnsupportedEncodingException;
 import java.lang.reflect.InvocationTargetException;
 import java.math.BigInteger;
+import java.net.InetAddress;
 import java.net.URLDecoder;
 import java.net.URLEncoder;
 import java.nio.ByteBuffer;
@@ -990,8 +991,17 @@ public abstract class InputFormatBase<K,
     if (!autoAdjust)
       splitsToAdd = new HashMap<Range,ArrayList<String>>();
     
+    HashMap<String,String> hostNameCache = new HashMap<String,String>();
+
     for (Entry<String,Map<KeyExtent,List<Range>>> tserverBin : binnedRanges.entrySet())
{
-      String location = tserverBin.getKey().split(":", 2)[0];
+      String ip = tserverBin.getKey().split(":", 2)[0];
+      String location = hostNameCache.get(ip);
+      if (location == null) {
+        InetAddress inetAddress = InetAddress.getByName(ip);
+        location = inetAddress.getHostName();
+        hostNameCache.put(ip, location);
+      }
+
       for (Entry<KeyExtent,List<Range>> extentRanges : tserverBin.getValue().entrySet())
{
         Range ke = extentRanges.getKey().toDataRange();
         for (Range r : extentRanges.getValue()) {



Mime
View raw message