From 002937d892d5fa89d18cb3998f5e683a43cc441a Mon Sep 17 00:00:00 2001 From: Yavor Yanchev Date: Wed, 6 Jan 2016 15:08:52 +0200 Subject: [PATCH] Parameterize the start effector - Customize phase will be skipped (as the install phase), if skipInstallation is true --- .../base/AbstractSoftwareProcessDriver.java | 75 ++++++++++--------- .../entity/software/base/SoftwareProcess.java | 7 ++ .../MachineLifecycleEffectorTasks.java | 16 +++- 3 files changed, 60 insertions(+), 38 deletions(-) diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessDriver.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessDriver.java index 59dac4ff8b..dc6bcf0609 100644 --- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessDriver.java +++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/AbstractSoftwareProcessDriver.java @@ -124,48 +124,49 @@ public void start() { Optional entityInstalled = Optional.fromNullable(entity.getConfig(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION)); boolean skipInstall = locationInstalled.or(entityInstalled).or(false); if (!skipInstall) { - DynamicTasks.queue("setup", new Runnable() { public void run() { - waitForConfigKey(BrooklynConfigKeys.SETUP_LATCH); - setup(); - }}); + DynamicTasks.queue("setup", new Runnable() { public void run() { + waitForConfigKey(BrooklynConfigKeys.SETUP_LATCH); + setup(); + }}); + + DynamicTasks.queue("copy-install-resources", new Runnable() { public void run() { + waitForConfigKey(BrooklynConfigKeys.INSTALL_RESOURCES_LATCH); + copyInstallResources(); + }}); + + DynamicTasks.queue("install", new Runnable() { public void run() { + waitForConfigKey(BrooklynConfigKeys.INSTALL_LATCH); + install(); + }}); + + + DynamicTasks.queue("post-install-command", new Runnable() { public void run() { + runPostInstallCommand(); + }}); + + DynamicTasks.queue("customize", new Runnable() { public void run() { + waitForConfigKey(BrooklynConfigKeys.CUSTOMIZE_LATCH); + customize(); + }}); + + DynamicTasks.queue("copy-runtime-resources", new Runnable() { public void run() { + waitForConfigKey(BrooklynConfigKeys.RUNTIME_RESOURCES_LATCH); + copyRuntimeResources(); + }}); + } - DynamicTasks.queue("copy-install-resources", new Runnable() { public void run() { - waitForConfigKey(BrooklynConfigKeys.INSTALL_RESOURCES_LATCH); - copyInstallResources(); + DynamicTasks.queue("pre-launch-command", new Runnable() { public void run() { + runPreLaunchCommand(); }}); - DynamicTasks.queue("install", new Runnable() { public void run() { - waitForConfigKey(BrooklynConfigKeys.INSTALL_LATCH); - install(); + DynamicTasks.queue("launch", new Runnable() { public void run() { + waitForConfigKey(BrooklynConfigKeys.LAUNCH_LATCH); + launch(); }}); - } - - DynamicTasks.queue("post-install-command", new Runnable() { public void run() { - runPostInstallCommand(); - }}); - - DynamicTasks.queue("customize", new Runnable() { public void run() { - waitForConfigKey(BrooklynConfigKeys.CUSTOMIZE_LATCH); - customize(); - }}); - - DynamicTasks.queue("copy-runtime-resources", new Runnable() { public void run() { - waitForConfigKey(BrooklynConfigKeys.RUNTIME_RESOURCES_LATCH); - copyRuntimeResources(); - }}); - DynamicTasks.queue("pre-launch-command", new Runnable() { public void run() { - runPreLaunchCommand(); - }}); - - DynamicTasks.queue("launch", new Runnable() { public void run() { - waitForConfigKey(BrooklynConfigKeys.LAUNCH_LATCH); - launch(); - }}); - - DynamicTasks.queue("post-launch-command", new Runnable() { public void run() { - runPostLaunchCommand(); - }}); + DynamicTasks.queue("post-launch-command", new Runnable() { public void run() { + runPostLaunchCommand(); + }}); } DynamicTasks.queue("post-launch", new Runnable() { public void run() { diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java index b14d6d8e55..e1bd24ada4 100644 --- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java +++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java @@ -308,6 +308,13 @@ private ChildStartableMode(boolean isDisabled, boolean isBackground, boolean isL AttributeSensor PID_FILE = Sensors.newStringSensor("softwareprocess.pid.file", "PID file"); + @Beta + public static class StartSoftwareParameters { + @Beta /** @since 0.9.0 */ + public static final ConfigKey SKIP_INSTALLATION = ConfigKeys.newConfigKey(Boolean.class, "skipInstallation", + "Just launch the process without installation and customization, if stopped; default false", false); + } + @Beta public static class RestartSoftwareParameters { @Beta /** @since 0.7.0 semantics of parameters to restart being explored */ diff --git a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java index 5e0beb6510..b27add1af2 100644 --- a/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java +++ b/brooklyn-server/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java @@ -62,6 +62,7 @@ import org.apache.brooklyn.entity.machine.ProvidesProvisioningFlags; import org.apache.brooklyn.entity.software.base.SoftwareProcess; import org.apache.brooklyn.entity.software.base.SoftwareProcess.RestartSoftwareParameters; +import org.apache.brooklyn.entity.software.base.SoftwareProcess.StartSoftwareParameters; import org.apache.brooklyn.entity.software.base.SoftwareProcess.StopSoftwareParameters; import org.apache.brooklyn.entity.software.base.SoftwareProcess.RestartSoftwareParameters.RestartMachineMode; import org.apache.brooklyn.entity.software.base.SoftwareProcess.StopSoftwareParameters.StopMode; @@ -140,7 +141,10 @@ public void attachLifecycleEffectors(Entity entity) { * the behaviour in this lifecycle class instance. */ public Effector newStartEffector() { - return Effectors.effector(Startable.START).impl(newStartEffectorTask()).build(); + return Effectors.effector(Startable.START) + .parameter(StartSoftwareParameters.SKIP_INSTALLATION) + .impl(newStartEffectorTask()) + .build(); } /** @see {@link #newStartEffector()} */ @@ -183,6 +187,11 @@ public EffectorBody newStartEffectorTask() { public Void call(ConfigBag parameters) { Collection locations = null; + Boolean isSkipInstallation = parameters.get(StartSoftwareParameters.SKIP_INSTALLATION); + if (isSkipInstallation != null && isSkipInstallation) { + entity().config().set(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION, isSkipInstallation); + } + Object locationsRaw = parameters.getStringKey(LOCATIONS.getName()); locations = Locations.coerceToCollection(entity().getManagementContext(), locationsRaw); @@ -203,6 +212,11 @@ private class StartEffectorBody extends EffectorBody { public Void call(ConfigBag parameters) { Collection locations = null; + Boolean isSkipInstallation = parameters.get(StartSoftwareParameters.SKIP_INSTALLATION); + if (isSkipInstallation != null && isSkipInstallation) { + entity().config().set(BrooklynConfigKeys.SKIP_ENTITY_INSTALLATION, isSkipInstallation); + } + Object locationsRaw = parameters.getStringKey(LOCATIONS.getName()); locations = Locations.coerceToCollection(entity().getManagementContext(), locationsRaw);