Skip to content

Commit

Permalink
Parameterize the start effector
Browse files Browse the repository at this point in the history
- Customize phase will be skipped (as the install phase), if 
  skipInstallation is true
  • Loading branch information
ygy committed Jan 6, 2016
1 parent cd504e2 commit 002937d
Show file tree
Hide file tree
Showing 3 changed files with 60 additions and 38 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -124,48 +124,49 @@ public void start() {
Optional<Boolean> 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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,13 @@ private ChildStartableMode(boolean isDisabled, boolean isBackground, boolean isL

AttributeSensor<String> PID_FILE = Sensors.newStringSensor("softwareprocess.pid.file", "PID file");

@Beta
public static class StartSoftwareParameters {
@Beta /** @since 0.9.0 */
public static final ConfigKey<Boolean> 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 */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -140,7 +141,10 @@ public void attachLifecycleEffectors(Entity entity) {
* the behaviour in this lifecycle class instance.
*/
public Effector<Void> newStartEffector() {
return Effectors.effector(Startable.START).impl(newStartEffectorTask()).build();
return Effectors.effector(Startable.START)
.parameter(StartSoftwareParameters.SKIP_INSTALLATION)
.impl(newStartEffectorTask())
.build();
}

/** @see {@link #newStartEffector()} */
Expand Down Expand Up @@ -183,6 +187,11 @@ public EffectorBody<Void> newStartEffectorTask() {
public Void call(ConfigBag parameters) {
Collection<? extends Location> 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);

Expand All @@ -203,6 +212,11 @@ private class StartEffectorBody extends EffectorBody<Void> {
public Void call(ConfigBag parameters) {
Collection<? extends Location> 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);

Expand Down

0 comments on commit 002937d

Please sign in to comment.