You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by al...@apache.org on 2018/01/11 14:47:32 UTC

[2/3] brooklyn-server git commit: Cleanup mutex handling in AbstractSoftwareProcessSshDriver

Cleanup mutex handling in AbstractSoftwareProcessSshDriver

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

Branch: refs/heads/master
Commit: f341f290a6dd82ca923afe9615563db3c2446eb9
Parents: fe2c435
Author: Alasdair Hodge <gi...@alasdairhodge.co.uk>
Authored: Thu Jan 11 13:13:01 2018 +0000
Committer: Alasdair Hodge <gi...@alasdairhodge.co.uk>
Committed: Thu Jan 11 13:13:01 2018 +0000

----------------------------------------------------------------------
 .../base/AbstractSoftwareProcessSshDriver.java    | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/f341f290/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java
index c071acd..f6885c2 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessSshDriver.java
@@ -27,7 +27,6 @@ import java.util.List;
 import java.util.Map;
 import java.util.Set;
 
-import com.google.common.base.Joiner;
 import org.apache.brooklyn.api.entity.EntityLocal;
 import org.apache.brooklyn.api.entity.drivers.downloads.DownloadResolver;
 import org.apache.brooklyn.config.ConfigKey;
@@ -46,6 +45,7 @@ import org.apache.brooklyn.location.ssh.SshMachineLocation;
 import org.apache.brooklyn.util.core.internal.ssh.SshTool;
 import org.apache.brooklyn.util.core.internal.ssh.sshj.SshjTool;
 import org.apache.brooklyn.util.core.json.ShellEnvironmentSerializer;
+import org.apache.brooklyn.util.core.mutex.WithMutexes;
 import org.apache.brooklyn.util.core.task.DynamicTasks;
 import org.apache.brooklyn.util.core.task.Tasks;
 import org.apache.brooklyn.util.core.task.system.ProcessTaskWrapper;
@@ -60,6 +60,7 @@ import org.apache.brooklyn.util.time.Duration;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
+import com.google.common.base.Joiner;
 import com.google.common.base.Predicates;
 import com.google.common.collect.ImmutableList;
 import com.google.common.collect.ImmutableSet;
@@ -293,27 +294,31 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
 
     @Override
     public void copyInstallResources() {
-        getLocation().acquireMutex("installing " + elvis(entity, this), "installation lock at host for files and templates");
+        final WithMutexes mutexSupport = getLocation().mutexes();
+        final String mutexId = "installing " + elvis(entity, this);
+        mutexSupport.acquireMutex(mutexId, "installation lock at host for files and templates");
         try {
             super.copyInstallResources();
         } catch (Exception e) {
             log.warn("Error copying install resources", e);
             throw Exceptions.propagate(e);
         } finally {
-            getLocation().releaseMutex("installing " + elvis(entity, this));
+            mutexSupport.releaseMutex(mutexId);
         }
     }
 
     @Override
     public void copyCustomizeResources() {
-        getLocation().acquireMutex("customizing " + elvis(entity, this), "installation lock at host for files and templates");
+        final WithMutexes mutexSupport = getLocation().mutexes();
+        final String mutexId = "customizing " + elvis(entity, this);
+        mutexSupport.acquireMutex(mutexId, "installation lock at host for files and templates");
         try {
             super.copyCustomizeResources();
         } catch (Exception e) {
             log.warn("Error copying customize resources", e);
             throw Exceptions.propagate(e);
         } finally {
-            getLocation().releaseMutex("customizing " + elvis(entity, this));
+            mutexSupport.releaseMutex(mutexId);
         }
     }
 
@@ -565,7 +570,8 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
             }
             if (INSTALLING.equals(phase)) {
                 // mutexId should be global because otherwise package managers will contend with each other
-                s.useMutex(getLocation(), "installation lock at host", "installing "+elvis(entity,this));
+                final String mutexId = "installation lock at host";
+                s.useMutex(getLocation().mutexes(), mutexId, "installing "+elvis(entity,this));
                 s.header.append(
                         "export INSTALL_DIR=\""+getInstallDir()+"\"",
                         "mkdir -p $INSTALL_DIR",