brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject [1/5] incubator-brooklyn git commit: Update to RiakNode to fix issue with Clocker and cluster resize
Date Tue, 24 Mar 2015 14:34:56 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master 89b621b1b -> e4542255a


Update to RiakNode to fix issue with Clocker and cluster resize


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

Branch: refs/heads/master
Commit: 6e258d1329e9046dbf1ccb26f3c4252e2e67f63b
Parents: e08d320
Author: Andrew Kennedy <grkvlt@apache.org>
Authored: Mon Mar 23 16:16:23 2015 +0000
Committer: Andrew Kennedy <grkvlt@apache.org>
Committed: Mon Mar 23 16:16:23 2015 +0000

----------------------------------------------------------------------
 .../entity/nosql/riak/RiakNodeImpl.java         | 20 +++---
 .../entity/nosql/riak/RiakNodeSshDriver.java    | 65 ++++++++++----------
 2 files changed, 43 insertions(+), 42 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6e258d13/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java
----------------------------------------------------------------------
diff --git a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java
index 0667a7a..caa6c81 100644
--- a/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java
+++ b/software/nosql/src/main/java/brooklyn/entity/nosql/riak/RiakNodeImpl.java
@@ -43,6 +43,9 @@ import brooklyn.util.guava.Functionals;
 
 import com.google.common.base.Function;
 import com.google.common.base.Functions;
+import com.google.common.collect.ContiguousSet;
+import com.google.common.collect.DiscreteDomain;
+import com.google.common.collect.Range;
 import com.google.common.net.HostAndPort;
 
 public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode {
@@ -68,9 +71,9 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode
{
     }
 
     public boolean isPackageDownloadUrlProvided() {
-        AttributeSensorAndConfigKey[] downloadProperties = {DOWNLOAD_URL_RHEL_CENTOS, DOWNLOAD_URL_UBUNTU,
DOWNLOAD_URL_DEBIAN};
-        for(AttributeSensorAndConfigKey property : downloadProperties) {
-            if(!((ConfigurationSupportInternal)config()).getRaw(property).isAbsent()) {
+        AttributeSensorAndConfigKey[] downloadProperties = { DOWNLOAD_URL_RHEL_CENTOS, DOWNLOAD_URL_UBUNTU,
DOWNLOAD_URL_DEBIAN };
+        for (AttributeSensorAndConfigKey property : downloadProperties) {
+            if (!((ConfigurationSupportInternal) config()).getRaw(property).isAbsent()) {
                 return true;
             }
         }
@@ -90,12 +93,11 @@ public class RiakNodeImpl extends SoftwareProcessImpl implements RiakNode
{
         int erlangRangeStart = getConfig(ERLANG_PORT_RANGE_START).iterator().next();
         int erlangRangeEnd = getConfig(ERLANG_PORT_RANGE_END).iterator().next();
 
-        Set<Integer> newPorts = MutableSet.<Integer>copyOf(super.getRequiredOpenPorts());
-        newPorts.remove(erlangRangeStart);
-        newPorts.remove(erlangRangeEnd);
-        for (int i = erlangRangeStart; i <= erlangRangeEnd; i++)
-            newPorts.add(i);
-        return newPorts;
+        Set<Integer> ports = MutableSet.copyOf(super.getRequiredOpenPorts());
+        Set<Integer> erlangPorts = ContiguousSet.create(Range.open(erlangRangeStart,
erlangRangeEnd), DiscreteDomain.integers());
+        ports.addAll(erlangPorts);
+
+        return ports;
     }
 
     @Override

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/6e258d13/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 544c39a..658d836 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
@@ -81,6 +81,14 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
     public void preInstall() {
         resolver = Entities.newDownloader(this);
         setExpandedInstallDir(Os.mergePaths(getInstallDir(), resolver.getUnpackedDirectoryName(format("riak-%s",
getVersion()))));
+
+        // Set package install attribute
+        OsDetails osDetails = getMachine().getMachineDetails().getOsDetails();
+        if (osDetails.isLinux()) {
+            entity.setAttribute(RiakNode.RIAK_PACKAGE_INSTALL, true);
+        } else if (osDetails.isMac()) {
+            entity.setAttribute(RiakNode.RIAK_PACKAGE_INSTALL, false);
+        }
     }
 
     @Override
@@ -92,14 +100,12 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
         OsDetails osDetails = getMachine().getMachineDetails().getOsDetails();
         List<String> commands = Lists.newLinkedList();
         if (osDetails.isLinux()) {
-            if(getEntity().isPackageDownloadUrlProvided()) {
-                commands.addAll(installLinuxFromPackageUrl(getExpandedInstallDir()));
+            if (getEntity().isPackageDownloadUrlProvided()) {
+                commands.addAll(installLinuxFromPackageUrl());
             } else {
                 commands.addAll(installFromPackageCloud());
             }
-            entity.setAttribute(RiakNode.RIAK_PACKAGE_INSTALL, true);
         } else if (osDetails.isMac()) {
-            entity.setAttribute(RiakNode.RIAK_PACKAGE_INSTALL, false);
             commands.addAll(installMac());
         } else if (osDetails.isWindows()) {
             throw new UnsupportedOperationException("RiakNode not supported on Windows instances");
@@ -108,29 +114,26 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
                     getMachine() + ". Details: " + getMachine().getMachineDetails().getOsDetails());
         }
 
-        try {
-            newScript(INSTALLING)
-                    .body.append(commands)
-                    .failIfBodyEmpty()
-                    .failOnNonZeroResultCode()
-                    .inessential()
+        int result = newScript(INSTALLING)
+                .body.append(commands)
+                .failIfBodyEmpty()
+                .execute();
+
+        if (result != 0 && osDetails.isLinux()) {
+            result = newScript(INSTALLING_FALLBACK)
+                    .body.append(installLinuxFromPackageUrl())
                     .execute();
-        } catch(RuntimeException e) {
-            if (osDetails.isLinux()) {
-                newScript(INSTALLING_FALLBACK).body
-                        .append(installLinuxFromPackageUrl(getExpandedInstallDir()))
-                        .failIfBodyEmpty()
-                        .failOnNonZeroResultCode()
-                        .execute();
-            }
         }
 
-        checkRiakOnPath();
+        if (result != 0) {
+            throw new IllegalStateException(String.format("Install failed with result %d",
result));
+        }
     }
 
-    private List<String> installLinuxFromPackageUrl(String expandedInstallDir) {
+    private List<String> installLinuxFromPackageUrl() {
         DynamicTasks.queueIfPossible(SshTasks.dontRequireTtyForSudo(getMachine(), SshTasks.OnFailingTask.WARN_OR_IF_DYNAMIC_FAIL_MARKING_INESSENTIAL)).orSubmitAndBlock();
 
+        String expandedInstallDir = getExpandedInstallDir();
         String installBin = Urls.mergePaths(expandedInstallDir, "bin");
         String saveAsYum = "riak.rpm";
         String saveAsApt = "riak.deb";
@@ -152,7 +155,7 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
         }
         String apt = chainGroup(
                 //debian fix
-                "export PATH=$PATH:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
+                "export PATH=" + sbinPath,
                 "which apt-get",
                 ok(sudo("apt-get -y --allow-unauthenticated install logrotate libpam0g-dev
libssl0.9.8")),
                 "export OS_NAME=" + Strings.toLowerCase(osDetails.getName()),
@@ -177,19 +180,11 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
         OsDetails osDetails = getMachine().getMachineDetails().getOsDetails();
         return ImmutableList.<String>builder()
                 .add(osDetails.getName().toLowerCase().contains("debian") ? addSbinPathCommand()
: "")
-                .add(ifNotExecutable("curl", Joiner.on('\n').join(installCurl())))
+                .add(ifNotExecutable("curl", INSTALL_CURL))
                 .addAll(ifExecutableElse("yum", installDebianBased(), installRpmBased()))
                 .build();
     }
 
-    public List<String> installCurl() {
-        return ImmutableList.<String>builder()
-                .add(ifExecutableElse("yum",
-                        BashCommands.sudo("apt-get install --assume-yes curl"),
-                        BashCommands.sudo("yum install -y curl")))
-                .build();
-    }
-
     private ImmutableList<String> installDebianBased() {
         return ImmutableList.<String>builder()
                 .add("curl https://packagecloud.io/install/repositories/basho/riak/script.deb
| " + BashCommands.sudo("bash"))
@@ -206,7 +201,7 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
 
     protected List<String> installMac() {
         String saveAs = resolver.getFilename();
-        String url = entity.getAttribute(RiakNode.DOWNLOAD_URL_MAC).toString();
+        String url = entity.getAttribute(RiakNode.DOWNLOAD_URL_MAC);
         return ImmutableList.<String>builder()
                 .add(INSTALL_TAR)
                 .add(INSTALL_CURL)
@@ -217,6 +212,8 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
 
     @Override
     public void customize() {
+        checkRiakOnPath();
+
         //create entity's runDir
         newScript(CUSTOMIZING).execute();
 
@@ -250,7 +247,9 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
         //    commands.add(sudo("launchctl limit maxfiles 4096 32768"));
         if (osDetails.isMac()) {
             commands.add("ulimit -n 4096");
-        } else if (osDetails.isLinux() && isVersion1()) {
+        }
+
+        if (osDetails.isLinux() && isVersion1()) {
             commands.add(sudo("chown -R riak:riak " + getRiakEtcDir()));
         }
 
@@ -320,7 +319,7 @@ public class RiakNodeSshDriver extends AbstractSoftwareProcessSshDriver
implemen
 
     @Override
     public void stop() {
-        leaveCluster("");
+        leaveCluster(""); // No node name means this node will leave
 
         String command = format("%s stop", getRiakCmd());
         command = isPackageInstall() ? sudo(command) : command;


Mime
View raw message