Updated Branches:
  refs/heads/branch-0.8 b55db5dce -> a1eca5ef4

WHIRR-672 - Allow eager caching of instance hostname based on pre-provision 
instance metadata. Contributed by Graham Gear.


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

Branch: refs/heads/branch-0.8
Commit: a1eca5ef4628aeff2cff0c85d171964fe24d5ad3
Parents: b55db5d
Author: Tom White <tomwh...@apache.org>
Authored: Mon Oct 29 15:10:52 2012 -0700
Committer: Tom White <tomwh...@apache.org>
Committed: Mon Oct 29 15:11:14 2012 -0700

----------------------------------------------------------------------
 CHANGES.txt                                      |    9 +++++-
 core/src/main/java/org/apache/whirr/Cluster.java |   24 ++++++++++++----
 2 files changed, 26 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/whirr/blob/a1eca5ef/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 9139948..0efb717 100644
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -1,6 +1,13 @@
 Apache Whirr Change Log
 
-Release 0.8.1 (unreleased changes)
+Release 0.8.2 (unreleased changes)
+
+  IMPROVEMENTS
+
+    WHIRR-672 - Allow eager caching of instance hostname based on pre-provision
+    instance metadata. (Graham Gear via tomwhite)
+
+Release 0.8.1 - 2012-10-19
 
   NEW FEATURES
 

http://git-wip-us.apache.org/repos/asf/whirr/blob/a1eca5ef/core/src/main/java/org/apache/whirr/Cluster.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/whirr/Cluster.java 
b/core/src/main/java/org/apache/whirr/Cluster.java
index 237ed47..e15f128 100644
--- a/core/src/main/java/org/apache/whirr/Cluster.java
+++ b/core/src/main/java/org/apache/whirr/Cluster.java
@@ -30,6 +30,7 @@ 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.jclouds.domain.internal.ResourceMetadataImpl;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -117,12 +118,23 @@ 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();
+        if ((nodeMetadata instanceof ResourceMetadataImpl)
+          && ((ResourceMetadataImpl) nodeMetadata).getLocation() != null
+          && "stub".equals(((ResourceMetadataImpl) 
nodeMetadata).getLocation().getId())
+          && nodeMetadata.getName() != null && 
!nodeMetadata.getName().isEmpty()) {
+          LOG.debug("assuming stub public hostname of {} to {}", new Object[] 
{ this, nodeMetadata.getName() });
+          publicHostName = nodeMetadata.getName();
+        } else {
+          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.getName() != 
null
+            && !nodeMetadata.getName().isEmpty()) {
+            LOG.debug("overriding public hostname of {} from {} (unresolved) 
to {}", new Object[] { this,
+              publicHostName, nodeMetadata.getName() });
+            publicHostName = nodeMetadata.getName();
+          }
         }
       }
       return publicHostName;

Reply via email to