Use interface for AttributeSensorAndConfigKey
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/11332d34 Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/11332d34 Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/11332d34 Branch: refs/heads/master Commit: 11332d34f3c23321c1cf38c62d4a593e35ae2b91 Parents: 7b288f2 Author: Andrew Kennedy <[email protected]> Authored: Fri Aug 29 17:40:22 2014 +0100 Committer: Andrew Kennedy <[email protected]> Committed: Sat Aug 30 17:27:08 2014 +0100 ---------------------------------------------------------------------- .../brooklyn/entity/basic/SoftwareProcess.java | 5 +-- .../entity/basic/VanillaSoftwareProcess.java | 44 ++++++++++++-------- 2 files changed, 28 insertions(+), 21 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/11332d34/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 765a819..2d7347b 100644 --- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java +++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java @@ -25,7 +25,6 @@ import brooklyn.entity.Entity; import brooklyn.entity.trait.Startable; import brooklyn.event.AttributeSensor; import brooklyn.event.basic.AttributeSensorAndConfigKey; -import brooklyn.event.basic.BasicAttributeSensorAndConfigKey; import brooklyn.event.basic.MapConfigKey; import brooklyn.event.basic.Sensors; import brooklyn.location.MachineProvisioningLocation; @@ -82,10 +81,10 @@ public interface SoftwareProcess extends Entity, Startable { ConfigKey<String> SUGGESTED_VERSION = BrooklynConfigKeys.SUGGESTED_VERSION; @SetFromFlag("downloadUrl") - BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = Attributes.DOWNLOAD_URL; + AttributeSensorAndConfigKey<String,String> DOWNLOAD_URL = Attributes.DOWNLOAD_URL; @SetFromFlag("downloadAddonUrls") - BasicAttributeSensorAndConfigKey<Map<String,String>> DOWNLOAD_ADDON_URLS = Attributes.DOWNLOAD_ADDON_URLS; + AttributeSensorAndConfigKey<Map<String,String>,Map<String,String>> DOWNLOAD_ADDON_URLS = Attributes.DOWNLOAD_ADDON_URLS; @SetFromFlag("installLabel") ConfigKey<String> INSTALL_UNIQUE_LABEL = BrooklynConfigKeys.INSTALL_UNIQUE_LABEL; http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/11332d34/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java ---------------------------------------------------------------------- diff --git a/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java b/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java index c722f90..9e9e171 100644 --- a/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java +++ b/software/base/src/main/java/brooklyn/entity/basic/VanillaSoftwareProcess.java @@ -20,38 +20,46 @@ package brooklyn.entity.basic; import brooklyn.config.ConfigKey; import brooklyn.entity.proxying.ImplementedBy; -import brooklyn.event.basic.BasicAttributeSensorAndConfigKey; +import brooklyn.event.basic.AttributeSensorAndConfigKey; /** - * downloads and unpacks the archive indicated (optionally), - * then runs the management commands (scripts) indicated - * (relative to the root of the archive if supplied, otherwise in a tmp working dir) to manage + * A {@link SoftwareProcess} entity that runs commands from an archive. * <p> - * uses config keys to identify the files / commands to use + * Downloads and unpacks the archive indicated (optionally) then runs the management commands (scripts) indicated + * (relative to the root of the archive if supplied, otherwise in a tmp working dir) to manage. Uses config keys + * to identify the files or commands to use. * <p> - * in simplest mode, simply provide either: + * In the simplest mode, simply provide either: + * <ul> * <li> an archive in {@link #DOWNLOAD_URL} containing a <code>./start.sh</code> * <li> a start command to invoke in {@link #LAUNCH_COMMAND} + * </ul> + * The only constraint is that the start command must write the PID into the file pointed to by the injected environment + * variable {@code PID_FILE} unless one of the options below is supported. * <p> - * the only constraint is that the start command must write the PID into the file pointed to by the injected environment variable PID_FILE, - * unless one of the options below is supported. + * The start command can be a complex bash command, downloading and unpacking files, and handling the {@code PID_FILE} requirement. + * For example {@code export MY_PID_FILE=$PID_FILE ; ./my_start.sh} or {@code nohup ./start.sh & ; echo $! > $PID_FILE ; sleep 5}. + * </pre> + * You can supply both {@link #DOWNLOAD_URL} and {@link #LAUNCH_COMMAND} configuration as well.. * <p> - * the start command can be a complex bash command, downloading and unpacking files, and/or handling the PID_FILE requirement - * (e.g. <code>export MY_PID_FILE=$PID_FILE ; ./my_start.sh</code> or <code>nohup ./start.sh & ; echo $! > $PID_FILE ; sleep 5</code>), - * and of course you can supply both {@link #DOWNLOAD_URL} and {@link #LAUNCH_COMMAND}. - * <p> - * by default the PID is used to stop the process (kill followed by kill -9 if needed) and restart (process stop followed by process start), - * but it is possible to override this behavior through config keys: - * <li> a custom {@link #CHECK_RUNNING_COMMAND} - * <li> a custom {@link #STOP_COMMAND} - * <li> specify which {@link SoftwareProcess#PID_FILE} to use + * By default the PID is used to stop the process using {@code kill} followed by {@code kill -9} if needed and restart + * is implemented by stopping the process and then running {@link VanillaSoftwareProcessSshDriver#launch()}, but it is + * possible to override this behavior through config keys: + * <ul> + * <li> A custom {@link #CHECK_RUNNING_COMMAND} + * <li> A custom {@link #STOP_COMMAND} + * <li> A different {@link SoftwareProcess#PID_FILE} to use + * <li> */ @ImplementedBy(VanillaSoftwareProcessImpl.class) public interface VanillaSoftwareProcess extends SoftwareProcess { - BasicAttributeSensorAndConfigKey<String> DOWNLOAD_URL = SoftwareProcess.DOWNLOAD_URL; + + AttributeSensorAndConfigKey<String, String> DOWNLOAD_URL = SoftwareProcess.DOWNLOAD_URL; + ConfigKey<String> SUGGESTED_VERSION = ConfigKeys.newConfigKeyWithDefault(SoftwareProcess.SUGGESTED_VERSION, "0.0.0"); ConfigKey<String> LAUNCH_COMMAND = ConfigKeys.newStringConfigKey("launch.command", "command to run to launch the process", "./start.sh"); ConfigKey<String> CHECK_RUNNING_COMMAND = ConfigKeys.newStringConfigKey("checkRunning.command", "command to determine whether the process is running"); ConfigKey<String> STOP_COMMAND = ConfigKeys.newStringConfigKey("stop.command", "command to run to stop the process"); + }
