You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by sv...@apache.org on 2016/10/26 09:50:52 UTC
[1/5] brooklyn-server git commit: Add a stop latch to SoftwareProcess.
Repository: brooklyn-server
Updated Branches:
refs/heads/master 0fe1e5d9c -> 34eab1776
Add a stop latch to SoftwareProcess.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/c5118e9b
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/c5118e9b
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/c5118e9b
Branch: refs/heads/master
Commit: c5118e9b5c86c6783f173b6d73599ad95d1952b4
Parents: 16ebd0c
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Authored: Wed Oct 19 13:00:54 2016 +0100
Committer: Geoff Macartney <ge...@cloudsoftcorp.com>
Committed: Wed Oct 19 13:21:42 2016 +0100
----------------------------------------------------------------------
.../core/entity/BrooklynConfigKeys.java | 1 +
.../entity/software/base/SoftwareProcess.java | 3 ++
.../MachineLifecycleEffectorTasks.java | 6 ++-
.../base/SoftwareProcessEntityLatchTest.java | 46 +++++++++++++++++---
4 files changed, 47 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5118e9b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
index 4070a35..ec5f34c 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
@@ -179,6 +179,7 @@ public class BrooklynConfigKeys {
public static final ConfigKey<Boolean> PROVISION_LATCH = newBooleanConfigKey("provision.latch", "Latch for blocking location provision until ready");
public static final ConfigKey<Boolean> START_LATCH = newBooleanConfigKey("start.latch", "Latch for blocking start until ready");
+ public static final ConfigKey<Boolean> STOP_LATCH = newBooleanConfigKey("stop.latch", "Latch for blocking stop until a condition is met");
public static final ConfigKey<Boolean> SETUP_LATCH = newBooleanConfigKey("setup.latch", "Latch for blocking setup until ready");
public static final ConfigKey<Boolean> PRE_INSTALL_RESOURCES_LATCH = newBooleanConfigKey("resources.preInstall.latch", "Latch for blocking pre-install resources until ready");
public static final ConfigKey<Boolean> INSTALL_RESOURCES_LATCH = newBooleanConfigKey("resources.install.latch", "Latch for blocking install resources until ready");
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5118e9b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
index d28bdc6..e612d1e 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
@@ -73,6 +73,9 @@ public interface SoftwareProcess extends Entity, Startable {
@SetFromFlag("startLatch")
ConfigKey<Boolean> START_LATCH = BrooklynConfigKeys.START_LATCH;
+ @SetFromFlag("stopLatch")
+ ConfigKey<Boolean> STOP_LATCH = BrooklynConfigKeys.STOP_LATCH;
+
@SetFromFlag("setupLatch")
ConfigKey<Boolean> SETUP_LATCH = BrooklynConfigKeys.SETUP_LATCH;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5118e9b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
index fda9ad6..fc738b1 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
@@ -604,7 +604,7 @@ public abstract class MachineLifecycleEffectorTasks {
// Opportunity to block startup until other dependent components are available
Object val = entity().getConfig(SoftwareProcess.START_LATCH);
- if (val != null) log.debug("{} finished waiting for start-latch; continuing...", entity(), val);
+ if (val != null) log.debug("{} finished waiting for start-latch {}; continuing...", entity(), val);
}
protected Map<String, Object> obtainProvisioningFlags(final MachineProvisioningLocation<?> location) {
@@ -951,7 +951,9 @@ public abstract class MachineLifecycleEffectorTasks {
* Throw if stop should be aborted.
*/
protected void preStopConfirmCustom() {
- // nothing needed here
+ // Opportunity to block stop() until other dependent components are ready for it
+ Object val = entity().getConfig(SoftwareProcess.STOP_LATCH);
+ if (val != null) log.debug("{} finished waiting for stop-latch {}; continuing...", entity(), val);
}
protected void preStopCustom() {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/c5118e9b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
index 20bc6a6..937e4c5 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
@@ -18,24 +18,27 @@
*/
package org.apache.brooklyn.entity.software.base;
+import static org.apache.brooklyn.core.mgmt.BrooklynTaskTags.getEffectorName;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.List;
+import java.util.Set;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.location.LocationSpec;
import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
import org.apache.brooklyn.core.sensor.DependentConfiguration;
+import org.apache.brooklyn.core.sensor.Sensors;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
import org.apache.brooklyn.entity.software.base.SoftwareProcessEntityTest.MyService;
import org.apache.brooklyn.entity.software.base.SoftwareProcessEntityTest.SimulatedDriver;
import org.apache.brooklyn.entity.stock.BasicEntity;
@@ -51,7 +54,6 @@ import org.apache.brooklyn.util.time.Duration;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -116,14 +118,36 @@ public class SoftwareProcessEntityLatchTest extends BrooklynAppUnitTestSupport {
runTestLatchBlocks(SoftwareProcess.LAUNCH_LATCH, ImmutableList.of("setup", "copyInstallResources", "install", "customize", "copyRuntimeResources"));
}
+ @Test
+ public void testStopLatchBlocks() throws Exception {
+ final AttributeSensor<Boolean> stopper = Sensors.newBooleanSensor("stop.now");
+ final BasicEntity triggerEntity = app.createAndManageChild(EntitySpec.create(BasicEntity.class));
+ final MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class)
+ .configure(SoftwareProcess.STOP_LATCH, DependentConfiguration.attributeWhenReady(app, stopper)));
+
+ final Task<Void> startTask = Entities.invokeEffector(app, app, MyService.START, ImmutableMap.of("locations", ImmutableList.of(loc)));
+ ((EntityLocal)triggerEntity).sensors().set(Attributes.SERVICE_UP, true);
+ startTask.get(Duration.THIRTY_SECONDS);
+
+ final Task<Void> stopTask = Entities.invokeEffector(app, app, MyService.STOP);
+
+ assertEffectorBlockingDetailsEventually(entity, MyService.STOP.getName(), "Waiting for config " + SoftwareProcess.STOP_LATCH.getName());
+
+ app.sensors().set(stopper, true);
+ stopTask.get(Duration.THIRTY_SECONDS);
+
+ assertDriverEventsEquals(entity, ImmutableList.of("setup", "copyInstallResources", "install", "customize", "copyRuntimeResources", "launch", "stop"));
+ }
+
+
protected void runTestLatchBlocks(final ConfigKey<Boolean> latch, List<String> preLatchEvents) throws Exception {
final BasicEntity triggerEntity = app.createAndManageChild(EntitySpec.create(BasicEntity.class));
final MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class)
.configure(latch, DependentConfiguration.attributeWhenReady(triggerEntity, Attributes.SERVICE_UP)));
-
+
final Task<Void> task = Entities.invokeEffector(app, app, MyService.START, ImmutableMap.of("locations", ImmutableList.of(loc)));
-
- assertEffectorBlockingDetailsEventually(entity, "Waiting for config "+latch.getName());
+
+ assertEffectorBlockingDetailsEventually(entity, MyService.START.getName(), "Waiting for config " + latch.getName());
assertDriverEventsEquals(entity, preLatchEvents);
assertFalse(task.isDone());
@@ -137,10 +161,18 @@ public class SoftwareProcessEntityLatchTest extends BrooklynAppUnitTestSupport {
assertEquals(events, expectedEvents, "events="+events);
}
- private void assertEffectorBlockingDetailsEventually(final Entity entity, final String blockingDetailsSnippet) {
+ private void assertEffectorBlockingDetailsEventually(final Entity entity, final String effectorName, final String blockingDetailsSnippet) {
Asserts.succeedsEventually(new Runnable() {
@Override public void run() {
- Task<?> entityTask = Iterables.getOnlyElement(mgmt.getExecutionManager().getTasksWithAllTags(ImmutableList.of(BrooklynTaskTags.EFFECTOR_TAG, BrooklynTaskTags.tagForContextEntity(entity))));
+ final Set<Task<?>> tasksWithAllTags = mgmt.getExecutionManager().getTasksWithAllTags(ImmutableList.of(BrooklynTaskTags.EFFECTOR_TAG, BrooklynTaskTags.tagForContextEntity(entity)));
+ Task<?> entityTask = null;
+ for (Task<?> item : tasksWithAllTags) {
+ final String itemName = getEffectorName(item);
+ entityTask = itemName.equals(effectorName) ? item : entityTask;
+ }
+ if (entityTask == null) {
+ Asserts.fail("Could not find task for effector " + effectorName);
+ }
String blockingDetails = getBlockingDetails(entityTask);
assertTrue(blockingDetails.contains(blockingDetailsSnippet));
}});
[5/5] brooklyn-server git commit: Closes #388
Posted by sv...@apache.org.
Closes #388
Add a stop latch to SoftwareProcess
Adds the ability to delay stop of a software process until an appropriate
sensor is published on some entity that depends on that process.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/34eab177
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/34eab177
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/34eab177
Branch: refs/heads/master
Commit: 34eab17767e2edfc297baa67568fdd38db4ae4d9
Parents: 0fe1e5d 248c6f0
Author: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Authored: Wed Oct 26 12:49:53 2016 +0300
Committer: Svetoslav Neykov <sv...@cloudsoftcorp.com>
Committed: Wed Oct 26 12:49:53 2016 +0300
----------------------------------------------------------------------
.../core/entity/BrooklynConfigKeys.java | 5 +++
.../entity/software/base/SoftwareProcess.java | 3 ++
.../MachineLifecycleEffectorTasks.java | 6 ++-
.../base/SoftwareProcessEntityLatchTest.java | 46 +++++++++++++++++---
4 files changed, 51 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
[3/5] brooklyn-server git commit: Add a stop latch to SoftwareProcess.
Posted by sv...@apache.org.
Add a stop latch to SoftwareProcess.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/1a875982
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/1a875982
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/1a875982
Branch: refs/heads/master
Commit: 1a875982ffebaad3a43c0302649dddbc0df78925
Parents: 0b474bb
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Authored: Wed Oct 19 13:00:54 2016 +0100
Committer: Geoff Macartney <ge...@cloudsoftcorp.com>
Committed: Tue Oct 25 14:49:55 2016 +0100
----------------------------------------------------------------------
.../core/entity/BrooklynConfigKeys.java | 5 +++
.../entity/software/base/SoftwareProcess.java | 3 ++
.../MachineLifecycleEffectorTasks.java | 6 ++-
.../base/SoftwareProcessEntityLatchTest.java | 46 +++++++++++++++++---
4 files changed, 51 insertions(+), 9 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/1a875982/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
index 4070a35..a97a5d9 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
@@ -23,6 +23,7 @@ import static org.apache.brooklyn.core.config.ConfigKeys.newConfigKey;
import static org.apache.brooklyn.core.config.ConfigKeys.newConfigKeyWithPrefix;
import static org.apache.brooklyn.core.config.ConfigKeys.newStringConfigKey;
+import com.google.common.annotations.Beta;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.BasicConfigInheritance;
@@ -179,6 +180,10 @@ public class BrooklynConfigKeys {
public static final ConfigKey<Boolean> PROVISION_LATCH = newBooleanConfigKey("provision.latch", "Latch for blocking location provision until ready");
public static final ConfigKey<Boolean> START_LATCH = newBooleanConfigKey("start.latch", "Latch for blocking start until ready");
+
+ @Beta // on stop DSLs time out after a minute and unblock; may be easier to fix after https://github.com/apache/brooklyn-server/pull/390
+ public static final ConfigKey<Boolean> STOP_LATCH = newBooleanConfigKey("stop.latch", "Latch for blocking stop until a condition is met; will block for at most 1 minute and then time out");
+
public static final ConfigKey<Boolean> SETUP_LATCH = newBooleanConfigKey("setup.latch", "Latch for blocking setup until ready");
public static final ConfigKey<Boolean> PRE_INSTALL_RESOURCES_LATCH = newBooleanConfigKey("resources.preInstall.latch", "Latch for blocking pre-install resources until ready");
public static final ConfigKey<Boolean> INSTALL_RESOURCES_LATCH = newBooleanConfigKey("resources.install.latch", "Latch for blocking install resources until ready");
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/1a875982/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
index d28bdc6..e612d1e 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/SoftwareProcess.java
@@ -73,6 +73,9 @@ public interface SoftwareProcess extends Entity, Startable {
@SetFromFlag("startLatch")
ConfigKey<Boolean> START_LATCH = BrooklynConfigKeys.START_LATCH;
+ @SetFromFlag("stopLatch")
+ ConfigKey<Boolean> STOP_LATCH = BrooklynConfigKeys.STOP_LATCH;
+
@SetFromFlag("setupLatch")
ConfigKey<Boolean> SETUP_LATCH = BrooklynConfigKeys.SETUP_LATCH;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/1a875982/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
----------------------------------------------------------------------
diff --git a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
index fda9ad6..fc738b1 100644
--- a/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
+++ b/software/base/src/main/java/org/apache/brooklyn/entity/software/base/lifecycle/MachineLifecycleEffectorTasks.java
@@ -604,7 +604,7 @@ public abstract class MachineLifecycleEffectorTasks {
// Opportunity to block startup until other dependent components are available
Object val = entity().getConfig(SoftwareProcess.START_LATCH);
- if (val != null) log.debug("{} finished waiting for start-latch; continuing...", entity(), val);
+ if (val != null) log.debug("{} finished waiting for start-latch {}; continuing...", entity(), val);
}
protected Map<String, Object> obtainProvisioningFlags(final MachineProvisioningLocation<?> location) {
@@ -951,7 +951,9 @@ public abstract class MachineLifecycleEffectorTasks {
* Throw if stop should be aborted.
*/
protected void preStopConfirmCustom() {
- // nothing needed here
+ // Opportunity to block stop() until other dependent components are ready for it
+ Object val = entity().getConfig(SoftwareProcess.STOP_LATCH);
+ if (val != null) log.debug("{} finished waiting for stop-latch {}; continuing...", entity(), val);
}
protected void preStopCustom() {
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/1a875982/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
index 20bc6a6..ba62208 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
@@ -18,24 +18,27 @@
*/
package org.apache.brooklyn.entity.software.base;
+import static org.apache.brooklyn.core.mgmt.BrooklynTaskTags.getEffectorName;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertTrue;
import java.util.List;
+import java.util.Set;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntityLocal;
import org.apache.brooklyn.api.entity.EntitySpec;
import org.apache.brooklyn.api.location.LocationSpec;
import org.apache.brooklyn.api.mgmt.Task;
+import org.apache.brooklyn.api.sensor.AttributeSensor;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.entity.Attributes;
import org.apache.brooklyn.core.entity.Entities;
import org.apache.brooklyn.core.mgmt.BrooklynTaskTags;
import org.apache.brooklyn.core.sensor.DependentConfiguration;
+import org.apache.brooklyn.core.sensor.Sensors;
import org.apache.brooklyn.core.test.BrooklynAppUnitTestSupport;
-import org.apache.brooklyn.entity.software.base.SoftwareProcess;
import org.apache.brooklyn.entity.software.base.SoftwareProcessEntityTest.MyService;
import org.apache.brooklyn.entity.software.base.SoftwareProcessEntityTest.SimulatedDriver;
import org.apache.brooklyn.entity.stock.BasicEntity;
@@ -51,7 +54,6 @@ import org.apache.brooklyn.util.time.Duration;
import com.google.common.collect.ImmutableList;
import com.google.common.collect.ImmutableMap;
-import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
@@ -116,14 +118,36 @@ public class SoftwareProcessEntityLatchTest extends BrooklynAppUnitTestSupport {
runTestLatchBlocks(SoftwareProcess.LAUNCH_LATCH, ImmutableList.of("setup", "copyInstallResources", "install", "customize", "copyRuntimeResources"));
}
+ @Test
+ public void testStopLatchBlocks() throws Exception {
+ final AttributeSensor<Boolean> stopper = Sensors.newBooleanSensor("stop.now");
+ final BasicEntity triggerEntity = app.createAndManageChild(EntitySpec.create(BasicEntity.class));
+ final MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class)
+ .configure(SoftwareProcess.STOP_LATCH, DependentConfiguration.attributeWhenReady(app, stopper)));
+
+ final Task<Void> startTask = Entities.invokeEffector(app, app, MyService.START, ImmutableMap.of("locations", ImmutableList.of(loc)));
+ ((EntityLocal)triggerEntity).sensors().set(Attributes.SERVICE_UP, true);
+ startTask.get(Duration.THIRTY_SECONDS);
+
+ final Task<Void> stopTask = Entities.invokeEffector(app, app, MyService.STOP);
+
+ assertEffectorBlockingDetailsEventually(entity, MyService.STOP.getName(), "Waiting for config " + SoftwareProcess.STOP_LATCH.getName());
+
+ app.sensors().set(stopper, true);
+ stopTask.get(Asserts.DEFAULT_LONG_TIMEOUT);
+
+ assertDriverEventsEquals(entity, ImmutableList.of("setup", "copyInstallResources", "install", "customize", "copyRuntimeResources", "launch", "stop"));
+ }
+
+
protected void runTestLatchBlocks(final ConfigKey<Boolean> latch, List<String> preLatchEvents) throws Exception {
final BasicEntity triggerEntity = app.createAndManageChild(EntitySpec.create(BasicEntity.class));
final MyService entity = app.createAndManageChild(EntitySpec.create(MyService.class)
.configure(latch, DependentConfiguration.attributeWhenReady(triggerEntity, Attributes.SERVICE_UP)));
-
+
final Task<Void> task = Entities.invokeEffector(app, app, MyService.START, ImmutableMap.of("locations", ImmutableList.of(loc)));
-
- assertEffectorBlockingDetailsEventually(entity, "Waiting for config "+latch.getName());
+
+ assertEffectorBlockingDetailsEventually(entity, MyService.START.getName(), "Waiting for config " + latch.getName());
assertDriverEventsEquals(entity, preLatchEvents);
assertFalse(task.isDone());
@@ -137,10 +161,18 @@ public class SoftwareProcessEntityLatchTest extends BrooklynAppUnitTestSupport {
assertEquals(events, expectedEvents, "events="+events);
}
- private void assertEffectorBlockingDetailsEventually(final Entity entity, final String blockingDetailsSnippet) {
+ private void assertEffectorBlockingDetailsEventually(final Entity entity, final String effectorName, final String blockingDetailsSnippet) {
Asserts.succeedsEventually(new Runnable() {
@Override public void run() {
- Task<?> entityTask = Iterables.getOnlyElement(mgmt.getExecutionManager().getTasksWithAllTags(ImmutableList.of(BrooklynTaskTags.EFFECTOR_TAG, BrooklynTaskTags.tagForContextEntity(entity))));
+ final Set<Task<?>> tasksWithAllTags = mgmt.getExecutionManager().getTasksWithAllTags(ImmutableList.of(BrooklynTaskTags.EFFECTOR_TAG, BrooklynTaskTags.tagForContextEntity(entity)));
+ Task<?> entityTask = null;
+ for (Task<?> item : tasksWithAllTags) {
+ final String itemName = getEffectorName(item);
+ entityTask = itemName.equals(effectorName) ? item : entityTask;
+ }
+ if (entityTask == null) {
+ Asserts.fail("Could not find task for effector " + effectorName);
+ }
String blockingDetails = getBlockingDetails(entityTask);
assertTrue(blockingDetails.contains(blockingDetailsSnippet));
}});
[4/5] brooklyn-server git commit: Close #388
Posted by sv...@apache.org.
Close #388
Add a stop latch to SoftwareProcess.
Adds the ability to delay stop of a software process until an appropriate
sensor is published on some entity that depends on that process.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/248c6f0c
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/248c6f0c
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/248c6f0c
Branch: refs/heads/master
Commit: 248c6f0c72f3d02ea2a1971911a82955beba3e16
Parents: 0559ff0 1a87598
Author: Svetoslav Neykov <sv...@neykov.name>
Authored: Tue Oct 25 16:51:33 2016 +0300
Committer: Svetoslav Neykov <sv...@neykov.name>
Committed: Tue Oct 25 16:51:33 2016 +0300
----------------------------------------------------------------------
.../brooklyn/camp/brooklyn/AppYamlTest.java | 2 +-
.../camp/brooklyn/ByonLocationsYamlTest.java | 2 +-
.../brooklyn/ConfigInheritanceYamlTest.java | 2 +-
.../ConfigLocationInheritanceYamlTest.java | 2 +-
.../camp/brooklyn/ConfigParametersYamlTest.java | 2 +-
.../brooklyn/camp/brooklyn/ConfigYamlTest.java | 2 +-
core/pom.xml | 13 +
.../core/entity/EntityTypeSnapshot.java | 10 +-
.../mgmt/internal/BrooklynGarbageCollector.java | 2 +-
.../apache/brooklyn/core/sensor/Sensors.java | 4 +
.../InvokeEffectorOnCollectionSensorChange.java | 197 ++++++++++++++
.../mgmt/persist/XmlMementoSerializerTest.java | 2 +-
...ectorOnCollectionSensorChangeRebindTest.java | 93 +++++++
...okeEffectorOnCollectionSensorChangeTest.java | 270 +++++++++++++++++++
.../util/core/file/ArchiveUtilsTest.java | 2 +-
karaf/features/src/main/feature/feature.xml | 1 -
launcher/pom.xml | 4 -
parent/pom.xml | 5 -
pom.xml | 5 +-
.../rest/resources/LocationResourceTest.java | 2 +-
20 files changed, 595 insertions(+), 27 deletions(-)
----------------------------------------------------------------------
[2/5] brooklyn-server git commit: Review comment updates.
Posted by sv...@apache.org.
Review comment updates.
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/0559ff08
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/0559ff08
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/0559ff08
Branch: refs/heads/master
Commit: 0559ff08919ad09ca2333fd6f6cf3c9ddaab8197
Parents: c5118e9
Author: Geoff Macartney <ge...@cloudsoftcorp.com>
Authored: Tue Oct 25 13:51:47 2016 +0100
Committer: Geoff Macartney <ge...@cloudsoftcorp.com>
Committed: Tue Oct 25 13:51:47 2016 +0100
----------------------------------------------------------------------
.../org/apache/brooklyn/core/entity/BrooklynConfigKeys.java | 6 +++++-
.../entity/software/base/SoftwareProcessEntityLatchTest.java | 2 +-
2 files changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0559ff08/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
index ec5f34c..a97a5d9 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/BrooklynConfigKeys.java
@@ -23,6 +23,7 @@ import static org.apache.brooklyn.core.config.ConfigKeys.newConfigKey;
import static org.apache.brooklyn.core.config.ConfigKeys.newConfigKeyWithPrefix;
import static org.apache.brooklyn.core.config.ConfigKeys.newStringConfigKey;
+import com.google.common.annotations.Beta;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.config.ConfigKey;
import org.apache.brooklyn.core.config.BasicConfigInheritance;
@@ -179,7 +180,10 @@ public class BrooklynConfigKeys {
public static final ConfigKey<Boolean> PROVISION_LATCH = newBooleanConfigKey("provision.latch", "Latch for blocking location provision until ready");
public static final ConfigKey<Boolean> START_LATCH = newBooleanConfigKey("start.latch", "Latch for blocking start until ready");
- public static final ConfigKey<Boolean> STOP_LATCH = newBooleanConfigKey("stop.latch", "Latch for blocking stop until a condition is met");
+
+ @Beta // on stop DSLs time out after a minute and unblock; may be easier to fix after https://github.com/apache/brooklyn-server/pull/390
+ public static final ConfigKey<Boolean> STOP_LATCH = newBooleanConfigKey("stop.latch", "Latch for blocking stop until a condition is met; will block for at most 1 minute and then time out");
+
public static final ConfigKey<Boolean> SETUP_LATCH = newBooleanConfigKey("setup.latch", "Latch for blocking setup until ready");
public static final ConfigKey<Boolean> PRE_INSTALL_RESOURCES_LATCH = newBooleanConfigKey("resources.preInstall.latch", "Latch for blocking pre-install resources until ready");
public static final ConfigKey<Boolean> INSTALL_RESOURCES_LATCH = newBooleanConfigKey("resources.install.latch", "Latch for blocking install resources until ready");
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/0559ff08/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
----------------------------------------------------------------------
diff --git a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
index 937e4c5..ba62208 100644
--- a/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
+++ b/software/base/src/test/java/org/apache/brooklyn/entity/software/base/SoftwareProcessEntityLatchTest.java
@@ -134,7 +134,7 @@ public class SoftwareProcessEntityLatchTest extends BrooklynAppUnitTestSupport {
assertEffectorBlockingDetailsEventually(entity, MyService.STOP.getName(), "Waiting for config " + SoftwareProcess.STOP_LATCH.getName());
app.sensors().set(stopper, true);
- stopTask.get(Duration.THIRTY_SECONDS);
+ stopTask.get(Asserts.DEFAULT_LONG_TIMEOUT);
assertDriverEventsEquals(entity, ImmutableList.of("setup", "copyInstallResources", "install", "customize", "copyRuntimeResources", "launch", "stop"));
}