brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From grk...@apache.org
Subject [01/14] git commit: Added install resources configuration as complement to runtime resources
Date Mon, 06 Oct 2014 11:56:33 GMT
Repository: incubator-brooklyn
Updated Branches:
  refs/heads/master cad129e19 -> 1680ef502


Added install resources configuration as complement to runtime resources


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

Branch: refs/heads/master
Commit: f22adab592bc2b8a5120d00fbaffc2989158d1ad
Parents: cad129e
Author: Andrew Kennedy <grkvlt@apache.org>
Authored: Tue Sep 16 12:21:05 2014 +0100
Committer: Andrew Kennedy <grkvlt@apache.org>
Committed: Sun Oct 5 23:46:58 2014 +0100

----------------------------------------------------------------------
 .../entity/basic/BrooklynConfigKeys.java        |  8 +--
 .../basic/AbstractSoftwareProcessDriver.java    | 22 ++++++---
 .../basic/AbstractSoftwareProcessSshDriver.java | 52 ++++++++++++++++----
 .../brooklyn/entity/basic/SoftwareProcess.java  | 29 ++++++++---
 .../entity/basic/SoftwareProcessDriver.java     |  4 +-
 .../java/JavaSoftwareProcessSshDriver.java      |  4 +-
 6 files changed, 88 insertions(+), 31 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f22adab5/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java b/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java
index 0f99497..479cd98 100644
--- a/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java
+++ b/core/src/main/java/brooklyn/entity/basic/BrooklynConfigKeys.java
@@ -106,16 +106,18 @@ public class BrooklynConfigKeys {
     /** @deprecated since 0.7.0; use {@link #RUN_DIR} */
     public static final ConfigKey<String> SUGGESTED_RUN_DIR = RUN_DIR.getConfigKey();
 
-    /**
-     * Intention is to use this with DependentConfiguration.attributeWhenReady, to allow
an entity's start
+    /*
+     * Intention is to use these with DependentConfiguration.attributeWhenReady, to allow
an entity's start
      * to block until dependents are ready. This is particularly useful when we want to block
until a dependent
      * component is up, but this entity does not care about the dependent component's actual
config values.
      */
+
     public static final ConfigKey<Boolean> START_LATCH = newBooleanConfigKey("start.latch",
"Latch for blocking start until ready");
     public static final ConfigKey<Boolean> SETUP_LATCH = newBooleanConfigKey("setup.latch",
"Latch for blocking setup until ready");
+    public static final ConfigKey<Boolean> INSTALL_RESOURCES_LATCH = newBooleanConfigKey("resources.install.latch",
"Latch for blocking install resources until ready");
     public static final ConfigKey<Boolean> INSTALL_LATCH = newBooleanConfigKey("install.latch",
"Latch for blocking install until ready");
+    public static final ConfigKey<Boolean> RUNTIME_RESOURCES_LATCH = newBooleanConfigKey("resources.runtime.latch",
"Latch for blocking runtime resources until ready");
     public static final ConfigKey<Boolean> CUSTOMIZE_LATCH = newBooleanConfigKey("customize.latch",
"Latch for blocking customize until ready");
-    public static final ConfigKey<Boolean> RESOURCES_LATCH = newBooleanConfigKey("resources.latch",
"Latch for blocking resources until ready");
     public static final ConfigKey<Boolean> LAUNCH_LATCH = newBooleanConfigKey("launch.latch",
"Latch for blocking launch until ready");
 
     public static final ConfigKey<Duration> START_TIMEOUT = newConfigKey(

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f22adab5/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
index c32e1fc..b2485b9 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessDriver.java
@@ -67,8 +67,8 @@ public abstract class AbstractSoftwareProcessDriver implements SoftwareProcessDr
 
     /**
      * Start the entity.
-     *
-     * this installs, configures and launches the application process. However,
+     * <p>
+     * This installs, configures and launches the application process. However,
      * users can also call the {@link #install()}, {@link #customize()} and
      * {@link #launch()} steps independently. The {@link #postLaunch()} will
      * be called after the {@link #launch()} metheod is executed, but the
@@ -96,6 +96,11 @@ public abstract class AbstractSoftwareProcessDriver implements SoftwareProcessDr
                 setup();
             }});
 
+            DynamicTasks.queue("installResources", new Runnable() { public void run() {
+                waitForConfigKey(BrooklynConfigKeys.INSTALL_RESOURCES_LATCH);
+                installResources();
+            }});
+
             DynamicTasks.queue("install", new Runnable() { public void run() {
                 waitForConfigKey(BrooklynConfigKeys.INSTALL_LATCH);
                 install();
@@ -108,16 +113,16 @@ public abstract class AbstractSoftwareProcessDriver implements SoftwareProcessDr
             }});
         };
 
+        DynamicTasks.queue("runtimeResources", new Runnable() { public void run() {
+            waitForConfigKey(BrooklynConfigKeys.RUNTIME_RESOURCES_LATCH);
+            runtimeResources();
+        }});
+
         DynamicTasks.queue("customize", new Runnable() { public void run() {
             waitForConfigKey(BrooklynConfigKeys.CUSTOMIZE_LATCH);
             customize();
         }});
 
-        DynamicTasks.queue("resources", new Runnable() { public void run() {
-            waitForConfigKey(BrooklynConfigKeys.RESOURCES_LATCH);
-            resources();
-        }});
-
         if (Strings.isNonBlank(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND)))
{
             DynamicTasks.queue("pre-launch command", new Runnable() { public void run() {
                 runPreLaunchCommand(entity.getConfig(BrooklynConfigKeys.PRE_LAUNCH_COMMAND));
@@ -150,10 +155,11 @@ public abstract class AbstractSoftwareProcessDriver implements SoftwareProcessDr
 
     public abstract void runPreInstallCommand(String command);
     public abstract void setup();
+    public abstract void installResources();
     public abstract void install();
     public abstract void runPostInstallCommand(String command);
+    public abstract void runtimeResources();
     public abstract void customize();
-    public abstract void resources();
     public abstract void runPreLaunchCommand(String command);
     public abstract void launch();
     public abstract void runPostLaunchCommand(String command);

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f22adab5/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 213fb32..ba520a0 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/AbstractSoftwareProcessSshDriver.java
@@ -43,6 +43,7 @@ import brooklyn.entity.software.SshEffectorTasks;
 import brooklyn.event.feed.ConfigToAttributes;
 import brooklyn.location.basic.SshMachineLocation;
 import brooklyn.util.collections.MutableMap;
+import brooklyn.util.exceptions.Exceptions;
 import brooklyn.util.guava.Maybe;
 import brooklyn.util.internal.ssh.SshTool;
 import brooklyn.util.internal.ssh.sshj.SshjTool;
@@ -284,29 +285,62 @@ public abstract class AbstractSoftwareProcessSshDriver extends AbstractSoftwareP
     }
 
     @Override
-    public void resources() {
-        Map runtimeFiles = entity.getConfig(SoftwareProcess.RUNTIME_FILES);
-        copyResources(runtimeFiles);
+    public void installResources() {
+        try {
+            getLocation().acquireMutex("installing "+elvis(entity,this),  "installation lock
at host");
+
+            getLocation().execCommands("create install directory", ImmutableList.of("mkdir
-p " + getInstallDir()));
+
+            Map installFiles = entity.getConfig(SoftwareProcess.INSTALL_FILES);
+            if (installFiles != null && installFiles.size() > 0) {
+                copyResources(installFiles);
+            }
 
-        Map runtimeTemplates = entity.getConfig(SoftwareProcess.RUNTIME_TEMPLATES);
-        copyTemplates(runtimeTemplates);
+            Map installTemplates = entity.getConfig(SoftwareProcess.INSTALL_TEMPLATES);
+            if (installTemplates != null && installTemplates.size() > 0) {
+                copyTemplates(installTemplates);
+            }
+        } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+        } finally {
+            getLocation().releaseMutex("installing "+elvis(entity,this));
+        }
     }
-    
+
+    @Override
+    public void runtimeResources() {
+        try {
+            getLocation().execCommands("create run directory", ImmutableList.of("mkdir -p
" + getRunDir()));
+
+            Map runtimeFiles = entity.getConfig(SoftwareProcess.RUNTIME_FILES);
+            if (runtimeFiles != null && runtimeFiles.size() > 0) {
+                copyResources(runtimeFiles);
+            }
+
+            Map runtimeTemplates = entity.getConfig(SoftwareProcess.RUNTIME_TEMPLATES);
+            if (runtimeTemplates != null && runtimeTemplates.size() > 0) {
+                copyTemplates(runtimeTemplates);
+            }
+        } catch (Exception e) {
+            Exceptions.propagateIfFatal(e);
+        }
+    }
+
     @Override
     public void runPreInstallCommand(String command) {
         execute(ImmutableList.of(command), "running pre-install commands");
     }
-    
+
     @Override
     public void runPostInstallCommand(String command) {
         execute(ImmutableList.of(command), "running post-install commands");
     }
-    
+
     @Override
     public void runPreLaunchCommand(String command) {
         execute(ImmutableList.of(command), "running pre-launch commands");
     }
-    
+
     @Override
     public void runPostLaunchCommand(String command) {
         execute(ImmutableList.of(command), "running post-launch commands");

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f22adab5/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
index f43f35e..675d953 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
@@ -50,15 +50,18 @@ public interface SoftwareProcess extends Entity, Startable {
     @SetFromFlag("setupLatch")
     ConfigKey<Boolean> SETUP_LATCH = BrooklynConfigKeys.SETUP_LATCH;
 
+    @SetFromFlag("installResourcesLatch")
+    ConfigKey<Boolean> INSTALL_RESOURCES_LATCH = BrooklynConfigKeys.INSTALL_RESOURCES_LATCH;
+
     @SetFromFlag("installLatch")
     ConfigKey<Boolean> INSTALL_LATCH = BrooklynConfigKeys.INSTALL_LATCH;
 
+    @SetFromFlag("runtimeResourcesLatch")
+    ConfigKey<Boolean> RUNTIME_RESOURCES_LATCH = BrooklynConfigKeys.RUNTIME_RESOURCES_LATCH;
+
     @SetFromFlag("customizeLatch")
     ConfigKey<Boolean> CUSTOMIZE_LATCH = BrooklynConfigKeys.CUSTOMIZE_LATCH;
 
-    @SetFromFlag("resourcesLatch")
-    ConfigKey<Boolean> RESOURCES_LATCH = BrooklynConfigKeys.RESOURCES_LATCH;
-
     @SetFromFlag("launchLatch")
     ConfigKey<Boolean> LAUNCH_LATCH = BrooklynConfigKeys.LAUNCH_LATCH;
 
@@ -102,17 +105,29 @@ public interface SoftwareProcess extends Entity, Startable {
     @Deprecated
     ConfigKey<String> SUGGESTED_RUN_DIR = BrooklynConfigKeys.SUGGESTED_RUN_DIR;
 
-    /** Files to be copied to the server, map of "subpath/file.name": "classpath://foo/file.txt"
(or other url) */
+    /** Files to be copied to the server before install. Map of "subpath/file.name" to "classpath://foo/file.txt"
(or other url) */
+    @SuppressWarnings("serial")
+    @SetFromFlag("installFiles")
+    ConfigKey<Map<String, String>> INSTALL_FILES = ConfigKeys.newConfigKey(new
TypeToken<Map<String, String>>() { },
+            "files.install", "Map of files to be copied, before install keyed by destination
name relative to runDir");
+
+    /** Templates to be filled in and then copied to the server before install. See {@link
#INSTALL_FILES}. */
+    @SuppressWarnings("serial")
+    @SetFromFlag("installTemplates")
+    ConfigKey<Map<String, String>> INSTALL_TEMPLATES = ConfigKeys.newConfigKey(new
TypeToken<Map<String, String>>() { },
+            "templates.install", "Map of templates to be filled in and copied before install,
keyed by destination name relative to runDir");
+
+    /** Files to be copied to the server before customisation, map of "subpath/file.name":
"classpath://foo/file.txt" (or other url) */
     @SuppressWarnings("serial")
     @SetFromFlag("runtimeFiles")
     ConfigKey<Map<String, String>> RUNTIME_FILES = ConfigKeys.newConfigKey(new
TypeToken<Map<String, String>>() { },
-            "files.runtime", "Map of files to be copied, keyed by destination name relative
to runDir");
+            "files.runtime", "Map of files to be copied before customisation, keyed by destination
name relative to runDir");
 
-    /** Templates to be filled in and then copied to the server. See {@link #RUNTIME_FILES}.
*/
+    /** Templates to be filled in and then copied to the server before customisation. See
{@link #RUNTIME_FILES}. */
     @SuppressWarnings("serial")
     @SetFromFlag("runtimeTemplates")
     ConfigKey<Map<String, String>> RUNTIME_TEMPLATES = ConfigKeys.newConfigKey(new
TypeToken<Map<String, String>>() { },
-            "templates.runtime", "Map of templates to be filled in and copied, keyed by destination
name relative to runDir");
+            "templates.runtime", "Map of templates to be filled in and copied before customisation,
keyed by destination name relative to runDir");
 
     @SetFromFlag("env")
     MapConfigKey<Object> SHELL_ENVIRONMENT = new MapConfigKey<Object>(Object.class,

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f22adab5/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessDriver.java
b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessDriver.java
index 5c0eb62..2ab2a61 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessDriver.java
@@ -60,13 +60,13 @@ public interface SoftwareProcessDriver extends EntityDriver {
      * @see Startable#restart()
      */
     void restart();
-    
+
     /**
      * Performs software stop (or queues tasks to do this) 
      * @see Startable#stop()
      */
     void stop();
-    
+
     /**
      * Kills the process, ungracefully and immediately where possible (e.g. with `kill -9`).
      */

http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/f22adab5/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
b/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
index 9b3874e..cc6d636 100644
--- a/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
+++ b/software/base/src/main/java/brooklyn/entity/java/JavaSoftwareProcessSshDriver.java
@@ -452,8 +452,8 @@ public abstract class JavaSoftwareProcessSshDriver extends AbstractSoftwareProce
     }
 
     @Override
-    public void resources() {
-        super.resources();
+    public void runtimeResources() {
+        super.runtimeResources();
 
         if (isJmxEnabled()) {
             DynamicTasks.queue("install jmx", new Runnable() { public void run() {


Mime
View raw message