You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@whirr.apache.org by as...@apache.org on 2012/05/13 21:48:50 UTC
svn commit: r1337972 - in /whirr/trunk: CHANGES.txt
core/src/main/java/org/apache/whirr/Cluster.java
core/src/main/java/org/apache/whirr/net/FastDnsResolver.java
services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopConfigurationBuilder.java
Author: asavu
Date: Sun May 13 19:48:49 2012
New Revision: 1337972
URL: http://svn.apache.org/viewvc?rev=1337972&view=rev
Log:
WHIRR-459. DNS Failure when trying to spawn HBase cluster (Alex Heneveld via asavu)
Modified:
whirr/trunk/CHANGES.txt
whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java
whirr/trunk/core/src/main/java/org/apache/whirr/net/FastDnsResolver.java
whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopConfigurationBuilder.java
Modified: whirr/trunk/CHANGES.txt
URL: http://svn.apache.org/viewvc/whirr/trunk/CHANGES.txt?rev=1337972&r1=1337971&r2=1337972&view=diff
==============================================================================
--- whirr/trunk/CHANGES.txt (original)
+++ whirr/trunk/CHANGES.txt Sun May 13 19:48:49 2012
@@ -121,6 +121,8 @@ Trunk (unreleased changes)
WHIRR-590. ssh port timeout fails the whole cluster (Doug Daniels via asavu)
+ WHIRR-459. DNS Failure when trying to spawn HBase cluster (Alex Heneveld via asavu)
+
Release 0.7.1 - 2012-02-23
IMPROVEMENTS
Modified: whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java?rev=1337972&r1=1337971&r2=1337972&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/Cluster.java Sun May 13 19:48:49 2012
@@ -30,6 +30,8 @@ import org.apache.whirr.net.DnsResolver;
import org.apache.whirr.net.FastDnsResolver;
import org.jclouds.compute.domain.NodeMetadata;
import org.jclouds.domain.Credentials;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.google.common.base.Objects;
import com.google.common.base.Predicate;
@@ -44,6 +46,8 @@ import com.google.common.net.InetAddress
*/
public class Cluster {
+ private static final Logger LOG = LoggerFactory.getLogger(Cluster.class);
+
/**
* This class represents a real node running in a cluster. An instance has
* one or more roles.
@@ -81,6 +85,9 @@ public class Cluster {
this.id = checkNotNull(id, "id");
this.nodeMetadata = nodeMetadata;
this.dnsResolver = dnsResolver;
+
+ LOG.debug("constructed instance {} with IP public {}, private {}, and DNS resolver {}",
+ new Object[] { this, publicIp, privateIp, dnsResolver });
}
public Credentials getLoginCredentials() {
@@ -110,7 +117,13 @@ public class Cluster {
public synchronized String getPublicHostName() throws IOException {
if (publicHostName == null) {
+ LOG.debug("resolving public hostname of {} (public {}, private {})", new Object[] { this, publicIp, privateIp });
publicHostName = dnsResolver.apply(publicIp);
+ LOG.debug("resolved public hostname of {} as {}", this, publicHostName);
+ if (publicHostName.matches("[0-9\\.]+") && nodeMetadata.getHostname()!=null && !nodeMetadata.getHostname().isEmpty()) {
+ LOG.debug("overriding public hostname of {} from {} (unresolved) to {}", new Object[] { this, publicHostName, nodeMetadata.getHostname() });
+ publicHostName = nodeMetadata.getHostname();
+ }
}
return publicHostName;
}
@@ -121,7 +134,9 @@ public class Cluster {
public synchronized String getPrivateHostName() throws IOException {
if (privateHostName == null) {
+ LOG.debug("resolving private hostname of {} (public {}, private {})", new Object[] { this, publicIp, privateIp });
privateHostName = dnsResolver.apply(privateIp);
+ LOG.debug("resolved private hostname of {} as {}", this, privateHostName);
}
return privateHostName;
}
Modified: whirr/trunk/core/src/main/java/org/apache/whirr/net/FastDnsResolver.java
URL: http://svn.apache.org/viewvc/whirr/trunk/core/src/main/java/org/apache/whirr/net/FastDnsResolver.java?rev=1337972&r1=1337971&r2=1337972&view=diff
==============================================================================
--- whirr/trunk/core/src/main/java/org/apache/whirr/net/FastDnsResolver.java (original)
+++ whirr/trunk/core/src/main/java/org/apache/whirr/net/FastDnsResolver.java Sun May 13 19:48:49 2012
@@ -24,6 +24,8 @@ import java.io.IOException;
import java.net.InetSocketAddress;
import java.net.SocketTimeoutException;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import org.xbill.DNS.DClass;
import org.xbill.DNS.ExtendedResolver;
import org.xbill.DNS.Message;
@@ -39,6 +41,9 @@ import org.xbill.DNS.Type;
*/
public class FastDnsResolver implements DnsResolver {
+ private static final Logger LOG = LoggerFactory
+ .getLogger(FastDnsResolver.class);
+
private int timeoutInSeconds;
public FastDnsResolver() {
@@ -70,8 +75,8 @@ public class FastDnsResolver implements
Record[] answers = response.getSectionArray(Section.ANSWER);
if (answers.length == 0) {
+ LOG.warn("no answer to DNS resolution attempt for "+hostIp+"; using fallback");
return fallback(hostIp);
-
} else {
String reverseAddress = answers[0].rdataToString();
return reverseAddress.endsWith(".") ? reverseAddress.substring(0, reverseAddress.length() - 1) : reverseAddress;
@@ -80,7 +85,9 @@ public class FastDnsResolver implements
return hostIp; /* same response as standard Java on timeout */
} catch(IOException e) {
- throw new DnsException(e);
+ // suggests eg firewall block DNS lookup or similar
+ LOG.warn("error in DNS resolution attempt for "+hostIp+" ("+e+"); using fallback");
+ return fallback(hostIp);
}
}
Modified: whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopConfigurationBuilder.java
URL: http://svn.apache.org/viewvc/whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopConfigurationBuilder.java?rev=1337972&r1=1337971&r2=1337972&view=diff
==============================================================================
--- whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopConfigurationBuilder.java (original)
+++ whirr/trunk/services/hadoop/src/main/java/org/apache/whirr/service/hadoop/HadoopConfigurationBuilder.java Sun May 13 19:48:49 2012
@@ -36,9 +36,13 @@ import org.apache.whirr.ClusterSpec;
import org.jclouds.compute.domain.Hardware;
import org.jclouds.compute.domain.Processor;
import org.jclouds.scriptbuilder.domain.Statement;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
public class HadoopConfigurationBuilder {
-
+
+ private static final Logger LOG = LoggerFactory.getLogger(HadoopConfigurationBuilder.class);
+
private static final String WHIRR_HADOOP_DEFAULT_PROPERTIES =
"whirr-hadoop-default.properties";
@@ -88,6 +92,7 @@ public class HadoopConfigurationBuilder
Instance namenode = cluster
.getInstanceMatching(role(HadoopNameNodeClusterActionHandler.ROLE));
+ LOG.debug("hadoop building common configuration, with hostname "+namenode.getPublicHostName());
config.setProperty("fs.default.name", String.format("hdfs://%s:8020/",
namenode.getPublicHostName()));
return config;