brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject [2/4] git commit: Fixes for subnetHostname in Riak for Clocker
Date Mon, 03 Nov 2014 18:39:31 GMT
Fixes for subnetHostname in Riak for Clocker


Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/1c17e735
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/1c17e735
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/1c17e735

Branch: refs/heads/master
Commit: 1c17e735a1c027ae91c7dc00bdb1a12dd655f16d
Parents: 4abc623
Author: Andrew Kennedy <grkvlt@apache.org>
Authored: Mon Nov 3 15:00:03 2014 +0000
Committer: Andrew Kennedy <grkvlt@apache.org>
Committed: Mon Nov 3 17:40:51 2014 +0000

----------------------------------------------------------------------
 .../jclouds/JcloudsSshMachineLocation.java       | 19 +++----------------
 .../basic/AbstractSoftwareProcessSshDriver.java  |  2 ++
 .../entity/nosql/riak/RiakNodeDriver.java        |  2 --
 .../entity/nosql/riak/RiakNodeSshDriver.java     | 19 +++++--------------
 4 files changed, 10 insertions(+), 32 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1c17e735/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
----------------------------------------------------------------------
diff --git a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
index d218ec2..e0ceffc 100644
--- a/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
+++ b/locations/jclouds/src/main/java/brooklyn/location/jclouds/JcloudsSshMachineLocation.java
@@ -160,24 +160,11 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements
Has
         return node.getPrivateAddresses();
     }
 
-    /** returns the hostname (or sometimes IP) for use by peers in the same subnet,
-     * defaulting to public hostname if nothing special
-     * <p>
-     * for use e.g. in clouds like amazon where other machines
-     * in the same subnet need to use a different IP
-     */
+    /** In most clouds, the public hostname is the only way to ensure VMs in different zones
can access each other. */
     @Override
     public String getSubnetHostname() {
         String publicHostname = jcloudsParent.getPublicHostname(node, Optional.<HostAndPort>absent(),
getAllConfigBag());
-        
-        if ("aws-ec2".equals(jcloudsParent.getProvider())) {
-            // prefer hostname over IP for aws (resolves to private ip in subnet, and to
public from outside)
-            if (!Networking.isValidIp4(publicHostname)) {
-                return publicHostname; // assume it's a hostname; could check for ip6!
-            }
-        }
-        Optional<String> privateAddress = getPrivateAddress();
-        return privateAddress.isPresent() ? privateAddress.get() : publicHostname;
+        return publicHostname;
     }
 
     @Override
@@ -186,7 +173,7 @@ public class JcloudsSshMachineLocation extends SshMachineLocation implements
Has
         if (privateAddress.isPresent()) {
             return privateAddress.get();
         }
-        
+
         String hostname = jcloudsParent.getPublicHostname(node, Optional.<HostAndPort>absent(),
getAllConfigBag());
         if (hostname != null && !Networking.isValidIp4(hostname)) {
             try {

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1c17e735/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
index ffab96b..0e54a20 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
@@ -258,6 +258,8 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
     public SshMachineLocation getMachine() { return getLocation(); }
     public String getHostname() { return entity.getAttribute(Attributes.HOSTNAME); }
     public String getAddress() { return entity.getAttribute(Attributes.ADDRESS); }
+    public String getSubnetHostname() { return entity.getAttribute(Attributes.SUBNET_HOSTNAME);
}
+    public String getSubnetAddress() { return entity.getAttribute(Attributes.SUBNET_ADDRESS);
}
 
     protected Map<String, Object> getSshFlags() {
         return SshEffectorTasks.getSshFlags(getEntity(), getMachine());

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1c17e735/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeDriver.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeDriver.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeDriver.java
index 7275bbf..3669c1c 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeDriver.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeDriver.java
@@ -22,8 +22,6 @@ import brooklyn.entity.basic.SoftwareProcessDriver;
 
 public interface RiakNodeDriver extends SoftwareProcessDriver {
 
-    public String getSubnetHostname();
-
     public String getRiakEtcDir();
 
     public void joinCluster(String nodeName);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/1c17e735/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
index a596e6f..830a798 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeSshDriver.java
@@ -103,11 +103,8 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
     }
 
     private List<String> installLinux(String expandedInstallDir) {
-
         DynamicTasks.queueIfPossible(SshTasks.dontRequireTtyForSudo(getMachine(), SshTasks.OnFailingTask.WARN_OR_IF_DYNAMIC_FAIL_MARKING_INESSENTIAL)).orSubmitAndBlock();
 
-        isPackageInstall = true;
-
         String installBin = Urls.mergePaths(expandedInstallDir, "bin");
         String saveAsYum = "riak.rpm";
         String saveAsApt = "riak.deb";
@@ -203,7 +200,7 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
         customizeScript.failOnNonZeroResultCode().execute();
 
         //set the riak node name
-        entity.setAttribute(RiakNode.RIAK_NODE_NAME, format("riak@%s", getEntity().getAttribute(Attributes.SUBNET_HOSTNAME)));
+        entity.setAttribute(RiakNode.RIAK_NODE_NAME, format("riak@%s", getSubnetHostname()));
     }
 
     @Override
@@ -231,11 +228,10 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
 
     @Override
     public void stop() {
-
         leaveCluster();
 
         String command = format("%s stop", getRiakCmd());
-        command = isPackageInstall ? "sudo " + command : command;
+        command = isPackageInstall ? sudo(command) : command;
 
         ScriptHelper stopScript = newScript(ImmutableMap.of(USE_PID_FILE, false), STOPPING)
                 .body.append(command);
@@ -248,7 +244,7 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
 
         int result = stopScript.failOnNonZeroResultCode().execute();
         if (result != 0) {
-            newScript(ImmutableMap.of(USE_PID_FILE, ""), STOPPING).execute();
+            newScript(ImmutableMap.of(USE_PID_FILE, false), STOPPING).execute();
         }
     }
 
@@ -335,7 +331,6 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
 
     @Override
     public void commitCluster() {
-
         if (hasJoinedCluster()) {
             ScriptHelper commitClusterScript = newScript("commitCluster")
                     .body.append(sudo(format("%s cluster plan", getRiakAdminCmd())))
@@ -366,10 +361,10 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
 
 
             String stopCommand = format("%s stop", getRiakCmd());
-            stopCommand = isPackageInstall ? "sudo " + stopCommand : stopCommand;
+            stopCommand = isPackageInstall ? sudo(stopCommand) : stopCommand;
 
             String startCommand = format("%s start >/dev/null 2>&1 < /dev/null
&", getRiakCmd());
-            startCommand = isPackageInstall ? "sudo " + startCommand : startCommand;
+            startCommand = isPackageInstall ? sudo(startCommand) : startCommand;
 
             ScriptHelper recoverNodeScript = newScript("recoverNode")
                     .body.append(stopCommand)
@@ -394,10 +389,6 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
         }
     }
 
-    public String getSubnetHostname() {
-        return getEntity().getAttribute(Attributes.SUBNET_HOSTNAME);
-    }
-
     private Boolean hasJoinedCluster() {
         return ((RiakNode) entity).hasJoinedCluster();
     }


Mime
View raw message