You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@brooklyn.apache.org by he...@apache.org on 2016/02/01 18:49:21 UTC
[17/50] brooklyn-server git commit:
DynamicCluster.quarantineFailedEntities now defaults to true
DynamicCluster.quarantineFailedEntities now defaults to true
Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/5decba3a
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/5decba3a
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/5decba3a
Branch: refs/heads/0.6.0
Commit: 5decba3aa3fde7db24ea51e4f33e8d0c69bbd500
Parents: be4ab78
Author: Aled Sage <al...@gmail.com>
Authored: Thu Nov 7 09:59:18 2013 +0000
Committer: Aled Sage <al...@gmail.com>
Committed: Thu Nov 7 10:33:04 2013 +0000
----------------------------------------------------------------------
.../brooklyn/entity/group/DynamicCluster.java | 2 +-
.../entity/group/DynamicClusterTest.groovy | 34 +++++++++++---------
.../entity/group/DynamicFabricTest.java | 32 ++++++++++--------
3 files changed, 39 insertions(+), 29 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5decba3a/core/src/main/java/brooklyn/entity/group/DynamicCluster.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/brooklyn/entity/group/DynamicCluster.java b/core/src/main/java/brooklyn/entity/group/DynamicCluster.java
index 3f2347c..2cd4b48 100644
--- a/core/src/main/java/brooklyn/entity/group/DynamicCluster.java
+++ b/core/src/main/java/brooklyn/entity/group/DynamicCluster.java
@@ -62,7 +62,7 @@ public interface DynamicCluster extends AbstractGroup, Cluster {
@SetFromFlag("quarantineFailedEntities")
public static final ConfigKey<Boolean> QUARANTINE_FAILED_ENTITIES = new BasicConfigKey<Boolean>(
- Boolean.class, "dynamiccluster.quarantineFailedEntities", "Whether to guarantine entities that fail to start, or to try to clean them up", false);
+ Boolean.class, "dynamiccluster.quarantineFailedEntities", "Whether to quarantine entities that fail to start, or to try to clean them up", true);
public static final AttributeSensor<Lifecycle> SERVICE_STATE = Attributes.SERVICE_STATE;
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5decba3a/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy b/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy
index ae5e493..1e113d7 100644
--- a/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy
+++ b/core/src/test/java/brooklyn/entity/group/DynamicClusterTest.groovy
@@ -141,7 +141,7 @@ class DynamicClusterTest {
cluster.start([loc])
cluster.resize(1)
- Entity entity = Iterables.getOnlyElement(cluster.getChildren());
+ Entity entity = Iterables.getOnlyElement(cluster.getMembers());
assertEquals entity.count, 1
assertEquals entity.parent, cluster
assertEquals entity.application, app
@@ -312,9 +312,9 @@ class DynamicClusterTest {
cluster.start([loc])
cluster.resize(3)
assertEquals(cluster.currentSize, 2)
- assertEquals(cluster.children.size(), 2)
- cluster.children.each {
- assertFalse(((FailingEntity)it).failOnStart)
+ assertEquals(cluster.getMembers().size(), 2)
+ for (Entity member : cluster.getMembers()) {
+ assertFalse(((FailingEntity)member).failOnStart)
}
}
@@ -331,10 +331,12 @@ class DynamicClusterTest {
}));
cluster.start([loc])
+
+ // note that children include quarantine group; and quarantined nodes
assertEquals(cluster.getCurrentSize(), 1)
- assertEquals(cluster.getChildren().size(), 1)
- for (Entity child : cluster.getChildren()) {
- assertFalse(((FailingEntity)child).failOnStart)
+ assertEquals(cluster.getMembers().size(), 1)
+ for (Entity member : cluster.getMembers()) {
+ assertFalse(((FailingEntity)member).failOnStart)
}
}
@@ -359,10 +361,12 @@ class DynamicClusterTest {
throw e; // fail
}
}
+
+ // note that children include quarantine group; and quarantined nodes
assertEquals(cluster.getCurrentSize(), 1)
- assertEquals(cluster.getChildren().size(), 1)
- for (Entity child : cluster.getChildren()) {
- assertFalse(((FailingEntity)child).failOnStart)
+ assertEquals(cluster.getMembers().size(), 1)
+ for (Entity member : cluster.getMembers()) {
+ assertFalse(((FailingEntity)member).failOnStart)
}
}
@@ -382,7 +386,7 @@ class DynamicClusterTest {
cluster.resize(3)
assertEquals(cluster.currentSize, 2)
assertEquals(cluster.getMembers().size(), 2)
- assertEquals(Iterables.size(Iterables.filter(cluster.children, Predicates.instanceOf(FailingEntity.class))), 3)
+ assertEquals(Iterables.size(Iterables.filter(cluster.getChildren(), Predicates.instanceOf(FailingEntity.class))), 3)
cluster.members.each {
assertFalse(((FailingEntity)it).failOnStart)
}
@@ -410,12 +414,12 @@ class DynamicClusterTest {
cluster.resize(1)
cluster.resize(2)
assertEquals(cluster.currentSize, 2)
- assertEquals(ImmutableSet.copyOf(cluster.getChildren()), ImmutableSet.copyOf(creationOrder), "actual="+cluster.getChildren())
+ assertEquals(ImmutableSet.copyOf(cluster.getMembers()), ImmutableSet.copyOf(creationOrder), "actual="+cluster.getMembers())
// Now stop one
cluster.resize(1)
assertEquals(cluster.currentSize, 1)
- assertEquals(ImmutableList.copyOf(cluster.getChildren()), creationOrder.subList(0, 1))
+ assertEquals(ImmutableList.copyOf(cluster.getMembers()), creationOrder.subList(0, 1))
}
@Test
@@ -441,12 +445,12 @@ class DynamicClusterTest {
cluster.start([loc])
- TestEntity child = cluster.children.get(0)
+ TestEntity child = Iterables.get(cluster.getMembers(), 0);
child.stop()
Entities.unmanage(child)
TestUtils.executeUntilSucceeds(timeout:TIMEOUT_MS) {
- assertEquals(cluster.children.size(), 0)
+ assertFalse(cluster.getChildren().contains(child), "children="+cluster.getChildren())
assertEquals(cluster.currentSize, 0)
assertEquals(cluster.members.size(), 0)
}
http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/5decba3a/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.java
----------------------------------------------------------------------
diff --git a/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.java b/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.java
index 005b09e..9c9e084 100644
--- a/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.java
+++ b/core/src/test/java/brooklyn/entity/group/DynamicFabricTest.java
@@ -20,6 +20,7 @@ import org.testng.annotations.BeforeMethod;
import org.testng.annotations.Test;
import brooklyn.entity.Entity;
+import brooklyn.entity.Group;
import brooklyn.entity.basic.ApplicationBuilder;
import brooklyn.entity.basic.Attributes;
import brooklyn.entity.basic.BasicEntity;
@@ -377,20 +378,21 @@ public class DynamicFabricTest {
app.start(ImmutableList.of(loc1));
assertEquals(fabric.getChildren().size(), 1);
- assertEquals(getChild(fabric, 0).getChildren().size(), 1);
- assertEquals(getGrandchild(fabric, 0, 0).getConfig(Attributes.HTTP_PORT.getConfigKey()), PortRanges.fromInteger(1234));
- assertEquals(((TestEntity)getGrandchild(fabric, 0, 0)).getConfigureProperties().get("a"), null);
- assertEquals(((TestEntity)getGrandchild(fabric, 0, 0)).getConfigureProperties().get("b"), "avail");
- assertEquals(((TestEntity)getGrandchild(fabric, 0, 0)).getConfigureProperties().get("fromCluster"), "passed to base entity");
- assertEquals(((TestEntity)getGrandchild(fabric, 0, 0)).getConfigureProperties().get("fromFabric"), null);
-
- ((DynamicCluster)getChild(fabric, 0)).resize(2);
- assertEquals(getChild(fabric, 0).getChildren().size(), 2);
+ DynamicCluster child = (DynamicCluster) getChild(fabric, 0);
+ assertEquals(child.getMembers().size(), 1);
+ assertEquals(getMember(child, 0).getConfig(Attributes.HTTP_PORT.getConfigKey()), PortRanges.fromInteger(1234));
+ assertEquals(((TestEntity)getMember(child, 0)).getConfigureProperties().get("a"), null);
+ assertEquals(((TestEntity)getMember(child, 0)).getConfigureProperties().get("b"), "avail");
+ assertEquals(((TestEntity)getMember(child, 0)).getConfigureProperties().get("fromCluster"), "passed to base entity");
+ assertEquals(((TestEntity)getMember(child, 0)).getConfigureProperties().get("fromFabric"), null);
+
+ child.resize(2);
+ assertEquals(child.getMembers().size(), 2);
assertEquals(getGrandchild(fabric, 0, 1).getConfig(Attributes.HTTP_PORT.getConfigKey()), PortRanges.fromInteger(1234));
- assertEquals(((TestEntity)getGrandchild(fabric, 0, 1)).getConfigureProperties().get("a"), null);
- assertEquals(((TestEntity)getGrandchild(fabric, 0, 1)).getConfigureProperties().get("b"), "avail");
- assertEquals(((TestEntity)getGrandchild(fabric, 0, 1)).getConfigureProperties().get("fromCluster"), "passed to base entity");
- assertEquals(((TestEntity)getGrandchild(fabric, 0, 1)).getConfigureProperties().get("fromFabric"), null);
+ assertEquals(((TestEntity)getMember(child, 1)).getConfigureProperties().get("a"), null);
+ assertEquals(((TestEntity)getMember(child, 1)).getConfigureProperties().get("b"), "avail");
+ assertEquals(((TestEntity)getMember(child, 1)).getConfigureProperties().get("fromCluster"), "passed to base entity");
+ assertEquals(((TestEntity)getMember(child, 1)).getConfigureProperties().get("fromFabric"), null);
}
private Entity getGrandchild(Entity entity, int childIndex, int grandchildIndex) {
@@ -401,4 +403,8 @@ public class DynamicFabricTest {
private Entity getChild(Entity entity, int childIndex) {
return Iterables.get(entity.getChildren(), childIndex);
}
+
+ private Entity getMember(Group entity, int memberIndex) {
+ return Iterables.get(entity.getMembers(), memberIndex);
+ }
}