giraph-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From clau...@apache.org
Subject git commit: GIRAPH-511
Date Sun, 10 Feb 2013 14:53:19 GMT
Updated Branches:
  refs/heads/trunk ab64a4d0e -> c17a6483c


GIRAPH-511


Project: http://git-wip-us.apache.org/repos/asf/giraph/repo
Commit: http://git-wip-us.apache.org/repos/asf/giraph/commit/c17a6483
Tree: http://git-wip-us.apache.org/repos/asf/giraph/tree/c17a6483
Diff: http://git-wip-us.apache.org/repos/asf/giraph/diff/c17a6483

Branch: refs/heads/trunk
Commit: c17a6483c437600b722a3107cdd473d9d2c551e4
Parents: ab64a4d
Author: Claudio Martella <claudio@apache.org>
Authored: Sun Feb 10 15:52:18 2013 +0100
Committer: Claudio Martella <claudio@apache.org>
Committed: Sun Feb 10 15:52:18 2013 +0100

----------------------------------------------------------------------
 CHANGELOG                                          |    3 +++
 .../java/org/apache/giraph/bsp/BspService.java     |    3 +--
 .../org/apache/giraph/comm/netty/NettyServer.java  |    3 +--
 .../apache/giraph/conf/GiraphConfiguration.java    |   15 +++++++++++++++
 .../org/apache/giraph/conf/GiraphConstants.java    |    5 +++++
 .../org/apache/giraph/zk/ZooKeeperManager.java     |    4 +---
 6 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/giraph/blob/c17a6483/CHANGELOG
----------------------------------------------------------------------
diff --git a/CHANGELOG b/CHANGELOG
index d339945..03417c1 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,6 +1,9 @@
 Giraph Change Log
 
 Release 0.2.0 - unreleased
+
+  GIRAPH-511: DNS interface and nameserver for multi-interface machines (claudio)
+
   GIRAPH-470 (tavoaqp via nitay)
 
   GIRAPH-504: Create PartitionContext (majakabiljo)

http://git-wip-us.apache.org/repos/asf/giraph/blob/c17a6483/giraph-core/src/main/java/org/apache/giraph/bsp/BspService.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/bsp/BspService.java b/giraph-core/src/main/java/org/apache/giraph/bsp/BspService.java
index 822adfb..969e2a5 100644
--- a/giraph-core/src/main/java/org/apache/giraph/bsp/BspService.java
+++ b/giraph-core/src/main/java/org/apache/giraph/bsp/BspService.java
@@ -46,7 +46,6 @@ import org.json.JSONException;
 import org.json.JSONObject;
 
 import java.io.IOException;
-import java.net.InetAddress;
 import java.net.UnknownHostException;
 import java.security.InvalidParameterException;
 import java.util.ArrayList;
@@ -293,7 +292,7 @@ public abstract class BspService<I extends WritableComparable,
               restartedSuperstep);
     }
     try {
-      this.hostname = InetAddress.getLocalHost().getHostName();
+      this.hostname = conf.getLocalHostname();
     } catch (UnknownHostException e) {
       throw new RuntimeException(e);
     }

http://git-wip-us.apache.org/repos/asf/giraph/blob/c17a6483/giraph-core/src/main/java/org/apache/giraph/comm/netty/NettyServer.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/comm/netty/NettyServer.java b/giraph-core/src/main/java/org/apache/giraph/comm/netty/NettyServer.java
index 971c7c5..f31dd4a 100644
--- a/giraph-core/src/main/java/org/apache/giraph/comm/netty/NettyServer.java
+++ b/giraph-core/src/main/java/org/apache/giraph/comm/netty/NettyServer.java
@@ -54,7 +54,6 @@ import org.jboss.netty.handler.execution.MemoryAwareThreadPoolExecutor;
 
 import com.google.common.util.concurrent.ThreadFactoryBuilder;
 
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.UnknownHostException;
 import java.util.concurrent.ExecutorService;
@@ -158,7 +157,7 @@ public class NettyServer {
             "netty-server-worker-%d").build());
 
     try {
-      this.localHostname = InetAddress.getLocalHost().getHostName();
+      this.localHostname = conf.getLocalHostname();
     } catch (UnknownHostException e) {
       throw new IllegalStateException("NettyServer: unable to get hostname");
     }

http://git-wip-us.apache.org/repos/asf/giraph/blob/c17a6483/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java
index dc5c84f..9e129ef 100644
--- a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java
+++ b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConfiguration.java
@@ -18,6 +18,8 @@
 
 package org.apache.giraph.conf;
 
+import java.net.UnknownHostException;
+
 import org.apache.giraph.aggregators.AggregatorWriter;
 import org.apache.giraph.combiner.Combiner;
 import org.apache.giraph.job.DefaultJobObserver;
@@ -35,6 +37,7 @@ import org.apache.giraph.vertex.Vertex;
 import org.apache.giraph.worker.WorkerContext;
 import org.apache.giraph.worker.WorkerObserver;
 import org.apache.hadoop.conf.Configuration;
+import org.apache.hadoop.net.DNS;
 
 /**
  * Adds user methods specific to Giraph.  This will be put into an
@@ -696,4 +699,16 @@ public class GiraphConfiguration extends Configuration
     return getBoolean(GiraphConstants.USE_INPUT_SPLIT_LOCALITY,
         GiraphConstants.USE_INPUT_SPLIT_LOCALITY_DEFAULT);
   }
+
+  /**
+   * Get the local hostname on the given interface.
+   *
+   * @return The local hostname
+   * @throws UnknownHostException
+   */
+  public String getLocalHostname() throws UnknownHostException {
+    return DNS.getDefaultHost(
+        get(GiraphConstants.DNS_INTERFACE, "default"),
+        get(GiraphConstants.DNS_NAMESERVER, "default"));
+  }
 }

http://git-wip-us.apache.org/repos/asf/giraph/blob/c17a6483/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
index e3d8ff3..8797c0e 100644
--- a/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
+++ b/giraph-core/src/main/java/org/apache/giraph/conf/GiraphConstants.java
@@ -595,5 +595,10 @@ public interface GiraphConstants {
    * Hadoop.
    */
   String MAX_TASK_ATTEMPTS = "mapred.map.max.attempts";
+
+  /** Interface to use for hostname resolution */
+  String DNS_INTERFACE = "giraph.dns.interface";
+  /** Server for hostname resolution */
+  String DNS_NAMESERVER = "giraph.dns.nameserver";
 }
 // CHECKSTYLE: resume InterfaceIsTypeCheck

http://git-wip-us.apache.org/repos/asf/giraph/blob/c17a6483/giraph-core/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
----------------------------------------------------------------------
diff --git a/giraph-core/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java b/giraph-core/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
index 611a4bb..add57fc 100644
--- a/giraph-core/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
+++ b/giraph-core/src/main/java/org/apache/giraph/zk/ZooKeeperManager.java
@@ -42,7 +42,6 @@ import java.io.InputStream;
 import java.io.InputStreamReader;
 import java.io.Writer;
 import java.net.ConnectException;
-import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.Socket;
 import java.net.SocketTimeoutException;
@@ -171,8 +170,7 @@ public class ZooKeeperManager {
         GiraphConstants.ZOOKEEPER_SERVER_PORT,
         GiraphConstants.ZOOKEEPER_SERVER_PORT_DEFAULT);
 
-
-    myHostname = InetAddress.getLocalHost().getCanonicalHostName();
+    myHostname = conf.getLocalHostname();
     fs = FileSystem.get(conf);
   }
 


Mime
View raw message