You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by ha...@apache.org on 2015/08/01 17:46:13 UTC
[20/21] incubator-brooklyn git commit: Delete deprecated code from
SoftwareProcessImpl
Delete deprecated code from SoftwareProcessImpl
- SoftwareProcessImpl.doStart/doStop/doRestart
- STOP_MACHINE config (replaced by STOP_MACHINE_MODE)
- MachineLifecycleEffectorTasks.restart()/stop() - now always take
ConfigBag arg.
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/2f336084
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/2f336084
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/2f336084
Branch: refs/heads/master
Commit: 2f336084dd4dcc55d2637c77704a7e16af049193
Parents: d9715b4
Author: Aled Sage <al...@gmail.com>
Authored: Wed Jul 29 17:42:17 2015 +0100
Committer: Aled Sage <al...@gmail.com>
Committed: Sat Aug 1 00:16:52 2015 +0100
----------------------------------------------------------------------
.../entity/basic/SameServerEntityImpl.java | 2 +-
.../brooklyn/entity/basic/SoftwareProcess.java | 11 ---
.../entity/basic/SoftwareProcessImpl.java | 90 +++-----------------
.../software/MachineLifecycleEffectorTasks.java | 39 ---------
...ctSoftwareProcessRestartIntegrationTest.java | 2 +-
.../entity/basic/SoftwareProcessEntityTest.java | 4 +-
.../test/entity/TestJavaWebAppEntity.java | 3 +-
7 files changed, 18 insertions(+), 133 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java b/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java
index 9b00836..fcd687e 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SameServerEntityImpl.java
@@ -99,7 +99,7 @@ public class SameServerEntityImpl extends AbstractEntity implements SameServerEn
* {@link DynamicTasks#queue(String, java.util.concurrent.Callable)}.
*/
protected void doStop() {
- LIFECYCLE_TASKS.stop();
+ LIFECYCLE_TASKS.stop(ConfigBag.EMPTY);
}
/**
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/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 1570355..5144a2b 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcess.java
@@ -339,17 +339,6 @@ public interface SoftwareProcess extends Entity, Startable {
"ALWAYS will try to stop the machine even if the entity is marked as stopped, " +
"IF_NOT_STOPPED stops the machine only if the entity is not marked as stopped, " +
"NEVER doesn't stop the machine.", StopMode.IF_NOT_STOPPED);
-
- /** @since 0.7.0 semantics of parameters to restart being explored
- * @deprecated since 0.7.0 use {@link #STOP_MACHINE_MODE} instead */
- @Beta
- @Deprecated
- public static final ConfigKey<Boolean> STOP_MACHINE = ConfigKeys.newBooleanConfigKey("stopMachine",
- "Whether to stop the machine provisioned for this entity: 'true', or 'false' are supported, " +
- "with the default being 'true'." +
- " 'true' is equivalent to " + STOP_MACHINE_MODE.getName() + " = " + StopMode.IF_NOT_STOPPED.name() + "." +
- " 'false' is equivalent to " + STOP_MACHINE_MODE.getName() + " = " + StopMode.NEVER.name() + ".", true);
-
}
// NB: the START, STOP, and RESTART effectors themselves are (re)defined by MachineLifecycleEffectorTasks
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
index 9daed4c..79275b2 100644
--- a/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
+++ b/software/base/src/main/java/brooklyn/entity/basic/SoftwareProcessImpl.java
@@ -40,7 +40,6 @@ import brooklyn.entity.basic.Lifecycle.Transition;
import brooklyn.entity.basic.ServiceStateLogic.ServiceNotUpLogic;
import brooklyn.entity.drivers.DriverDependentEntity;
import brooklyn.entity.drivers.EntityDriverManager;
-import brooklyn.entity.effector.EffectorBody;
import brooklyn.event.SensorEvent;
import brooklyn.event.SensorEventListener;
import brooklyn.event.feed.function.FunctionFeed;
@@ -50,7 +49,6 @@ import brooklyn.location.MachineLocation;
import brooklyn.location.MachineProvisioningLocation;
import brooklyn.location.PortRange;
import brooklyn.location.basic.LocationConfigKeys;
-import brooklyn.location.basic.Machines;
import brooklyn.location.cloud.CloudLocationConfig;
import brooklyn.management.Task;
import brooklyn.policy.EnricherSpec;
@@ -394,30 +392,6 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
Entities.waitForServiceUp(this, Duration.of(duration, units));
}
- /** @deprecated since 0.7.0, this isn't a general test for modifiability, and was hardly ever used (now never used) */
- @Deprecated
- public void checkModifiable() {
- Lifecycle state = getAttribute(SERVICE_STATE_ACTUAL);
- if (getAttribute(SERVICE_STATE_ACTUAL) == Lifecycle.RUNNING) return;
- if (getAttribute(SERVICE_STATE_ACTUAL) == Lifecycle.STARTING) return;
- throw new IllegalStateException("Cannot configure entity "+this+" in state "+state);
- }
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void startInLocation(Collection<? extends Location> locations) {}
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void startInLocation(Location location) {}
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void startInLocation(final MachineProvisioningLocation<?> location) {}
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void startInLocation(MachineLocation machine) {}
-
- /** @deprecated since 0.6.0 use/override method in {@link SoftwareProcessDriverLifecycleEffectorTasks} */
- protected final void callStartHooks() {}
-
protected Map<String,Object> obtainProvisioningFlags(MachineProvisioningLocation location) {
ConfigBag result = ConfigBag.newInstance(location.getProvisioningFlags(ImmutableList.of(getClass().getName())));
result.putAll(getConfig(PROVISIONING_PROPERTIES));
@@ -476,11 +450,6 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
return ports;
}
- /** @deprecated since 0.6.0 use {@link Machines#findSubnetHostname(Entity)} */ @Deprecated
- public String getLocalHostname() {
- return Machines.findSubnetHostname(this).get();
- }
-
protected void initDriver(MachineLocation machine) {
SoftwareProcessDriver newDriver = doInitDriver(machine);
if (newDriver == null) {
@@ -555,20 +524,22 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
}
/**
- * If custom behaviour is required by sub-classes, consider overriding {@link #doStart(Collection)})}.
+ * If custom behaviour is required by sub-classes, consider overriding {@link #preStart()} or {@link #postStart()})}.
+ * Also consider adding additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
*/
@Override
public final void start(final Collection<? extends Location> locations) {
if (DynamicTasks.getTaskQueuingContext() != null) {
- doStart(locations);
+ getLifecycleEffectorTasks().start(locations);
} else {
- Task<?> task = Tasks.builder().name("start (sequential)").body(new Runnable() { public void run() { doStart(locations); } }).build();
+ Task<?> task = Tasks.builder().name("start (sequential)").body(new Runnable() { public void run() { getLifecycleEffectorTasks().start(locations); } }).build();
Entities.submit(this, task).getUnchecked();
}
}
/**
- * If custom behaviour is required by sub-classes, consider overriding {@link #doStop()}.
+ * If custom behaviour is required by sub-classes, consider overriding {@link #preStop()} or {@link #postStop()}.
+ * Also consider adding additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
*/
@Override
public final void stop() {
@@ -581,64 +552,27 @@ public abstract class SoftwareProcessImpl extends AbstractEntity implements Soft
// or do a SERVICE_STATE check before setting SERVICE_UP to true in a feed (?).
if (DynamicTasks.getTaskQueuingContext() != null) {
- doStop();
+ getLifecycleEffectorTasks().stop(ConfigBag.EMPTY);
} else {
- Task<?> task = Tasks.builder().name("stop").body(new Runnable() { public void run() { doStop(); } }).build();
+ Task<?> task = Tasks.builder().name("stop").body(new Runnable() { public void run() { getLifecycleEffectorTasks().stop(ConfigBag.EMPTY); } }).build();
Entities.submit(this, task).getUnchecked();
}
}
/**
- * If custom behaviour is required by sub-classes, consider overriding {@link #doRestart()}.
+ * If custom behaviour is required by sub-classes, consider overriding {@link #preRestart()} or {@link #postRestart()}.
+ * Also consider adding additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
*/
@Override
public final void restart() {
if (DynamicTasks.getTaskQueuingContext() != null) {
- doRestart(ConfigBag.EMPTY);
+ getLifecycleEffectorTasks().restart(ConfigBag.EMPTY);
} else {
- Task<?> task = Tasks.builder().name("restart").body(new Runnable() { public void run() { doRestart(ConfigBag.EMPTY); } }).build();
+ Task<?> task = Tasks.builder().name("restart").body(new Runnable() { public void run() { getLifecycleEffectorTasks().restart(ConfigBag.EMPTY); } }).build();
Entities.submit(this, task).getUnchecked();
}
}
- /**
- * To be overridden instead of {@link #start(Collection)}; sub-classes should call {@code super.doStart(locations)} and should
- * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
- * @deprecated since 0.7.0 override {@link #preStart()} or {@link #postStart()},
- * or define a {@link SoftwareProcessDriverLifecycleEffectorTasks} subclass if more complex behaviour needed
- * (this method is no longer invoked by the {@link EffectorBody} call path,
- * hence deprecating it and marking it final to highlight incompatibilities at compile time)
- */
- @Deprecated
- protected final void doStart(Collection<? extends Location> locations) {
- getLifecycleEffectorTasks().start(locations);
- }
-
- /**
- * To be overridden instead of {@link #stop()}; sub-classes should call {@code super.doStop()} and should
- * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
- * @deprecated since 0.7.0 override {@link #preStop()} or {@link #postStop()}; see note on {@link #doStart(Collection)} for more information
- */
- @Deprecated
- protected final void doStop() {
- getLifecycleEffectorTasks().stop();
- }
-
- /**
- * To be overridden instead of {@link #restart()}; sub-classes should call {@code super.doRestart(ConfigBag)} and should
- * add do additional work via tasks, executed using {@link DynamicTasks#queue(String, Callable)}.
- * @deprecated since 0.7.0; see note on {@link #doStart(Collection)} for more information
- */
- @Deprecated
- protected final void doRestart(ConfigBag parameters) {
- getLifecycleEffectorTasks().restart(parameters);
- }
-
- @Deprecated /** @deprecated since 0.7.0 see {@link #doRestart(ConfigBag)} */
- protected final void doRestart() {
- doRestart(ConfigBag.EMPTY);
- }
-
protected SoftwareProcessDriverLifecycleEffectorTasks getLifecycleEffectorTasks() {
return getConfig(LIFECYCLE_EFFECTOR_TASKS);
}
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
index 48bb6a4..6ce7d1c 100644
--- a/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/brooklyn/entity/software/MachineLifecycleEffectorTasks.java
@@ -543,12 +543,6 @@ public abstract class MachineLifecycleEffectorTasks {
// nothing by default
}
- /** @deprecated since 0.7.0 use {@link #restart(ConfigBag)} */
- @Deprecated
- public void restart() {
- restart(ConfigBag.EMPTY);
- }
-
/**
* whether when 'auto' mode is specified, the machine should be stopped when the restart effector is called
* <p>
@@ -635,12 +629,6 @@ public abstract class MachineLifecycleEffectorTasks {
throw new IllegalArgumentException("Invalid value '"+isRestartChildren+"' for "+RestartSoftwareParameters.RESTART_CHILDREN.getName());
}
- /** @deprecated since 0.7.0 use {@link #stop(ConfigBag)} */
- @Deprecated
- public void stop() {
- stop(ConfigBag.EMPTY);
- }
-
/**
* Default stop implementation for an entity.
* <p>
@@ -778,22 +766,7 @@ public abstract class MachineLifecycleEffectorTasks {
}
public static StopMode getStopMachineMode(ConfigBag parameters) {
- @SuppressWarnings("deprecation")
- final boolean hasStopMachine = parameters.containsKey(StopSoftwareParameters.STOP_MACHINE);
- @SuppressWarnings("deprecation")
- final Boolean isStopMachine = parameters.get(StopSoftwareParameters.STOP_MACHINE);
-
- final boolean hasStopMachineMode = parameters.containsKey(StopSoftwareParameters.STOP_MACHINE_MODE);
final StopMode stopMachineMode = parameters.get(StopSoftwareParameters.STOP_MACHINE_MODE);
-
- if (hasStopMachine && isStopMachine != null) {
- checkCompatibleMachineModes(isStopMachine, hasStopMachineMode, stopMachineMode);
- if (isStopMachine) {
- return StopMode.IF_NOT_STOPPED;
- } else {
- return StopMode.NEVER;
- }
- }
return stopMachineMode;
}
@@ -807,18 +780,6 @@ public abstract class MachineLifecycleEffectorTasks {
stopMode == StopMode.IF_NOT_STOPPED && !isStopped;
}
- @SuppressWarnings("deprecation")
- private static void checkCompatibleMachineModes(Boolean isStopMachine, boolean hasStopMachineMode, StopMode stopMachineMode) {
- if (hasStopMachineMode &&
- (isStopMachine && stopMachineMode != StopMode.IF_NOT_STOPPED ||
- !isStopMachine && stopMachineMode != StopMode.NEVER)) {
- throw new IllegalStateException("Incompatible values for " +
- StopSoftwareParameters.STOP_MACHINE.getName() + " (" + isStopMachine + ") and " +
- StopSoftwareParameters.STOP_MACHINE_MODE.getName() + " (" + stopMachineMode + "). " +
- "Use only one of the parameters.");
- }
- }
-
/**
* Override to check whether stop can be executed.
* Throw if stop should be aborted.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java b/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
index c2c7291..d70ed76 100644
--- a/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
+++ b/software/base/src/test/java/brooklyn/entity/basic/AbstractSoftwareProcessRestartIntegrationTest.java
@@ -73,7 +73,7 @@ public abstract class AbstractSoftwareProcessRestartIntegrationTest extends Broo
// Stop the process
Entities.invokeEffector(app, entity, SoftwareProcess.STOP, ImmutableMap.of(
- StopSoftwareParameters.STOP_MACHINE.getName(), false))
+ StopSoftwareParameters.STOP_MACHINE_MODE.getName(), StopSoftwareParameters.StopMode.NEVER))
.get();
EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_UP, false);
EntityTestUtils.assertAttributeEqualsEventually(entity, SoftwareProcess.SERVICE_STATE_ACTUAL, Lifecycle.STOPPED);
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
index b770293..4d2e7fd 100644
--- a/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
+++ b/software/base/src/test/java/brooklyn/entity/basic/SoftwareProcessEntityTest.java
@@ -262,7 +262,7 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport {
d.events.clear();
TaskAdaptable<Void> t1 = Entities.submit(entity, Effectors.invocation(entity, Startable.STOP,
- ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_MACHINE, true)));
+ ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_MACHINE_MODE, StopSoftwareParameters.StopMode.IF_NOT_STOPPED)));
t1.asTask().get();
assertEquals(d.events, ImmutableList.of("stop"));
@@ -279,7 +279,7 @@ public class SoftwareProcessEntityTest extends BrooklynAppUnitTestSupport {
d.events.clear();
TaskAdaptable<Void> t1 = Entities.submit(entity, Effectors.invocation(entity, Startable.STOP,
- ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_MACHINE, false)));
+ ConfigBag.newInstance().configure(StopSoftwareParameters.STOP_MACHINE_MODE, StopSoftwareParameters.StopMode.NEVER)));
t1.asTask().get(10, TimeUnit.SECONDS);
assertEquals(d.events, ImmutableList.of("stop"));
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/2f336084/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java
----------------------------------------------------------------------
diff --git a/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java b/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java
index 003d81c..3fa4015 100644
--- a/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java
+++ b/software/webapp/src/test/java/brooklyn/test/entity/TestJavaWebAppEntity.java
@@ -32,6 +32,7 @@ import brooklyn.entity.java.VanillaJavaApp;
import brooklyn.entity.proxying.ImplementedBy;
import brooklyn.entity.webapp.WebAppService;
import brooklyn.location.Location;
+import brooklyn.util.config.ConfigBag;
/**
* Mock web application server entity for testing.
@@ -64,7 +65,7 @@ public interface TestJavaWebAppEntity extends VanillaJavaApp, WebAppService {
}
@Override
- public void stop() {
+ public void stop(ConfigBag parameters) {
ServiceStateLogic.setExpectedState(entity(), Lifecycle.STOPPING);
LOG.trace("Stopping {}", this);
entity().setAttribute(Attributes.SERVICE_UP, false);