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 2015/12/10 10:40:52 UTC
[5/5] incubator-brooklyn git commit: review comments for
DynamicCluster, now checking ClusterOneAndAllMembersUpCallable
review comments for DynamicCluster, now checking ClusterOneAndAllMembersUpCallable
Project: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/commit/dc17ddca
Tree: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/tree/dc17ddca
Diff: http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/diff/dc17ddca
Branch: refs/heads/master
Commit: dc17ddcae20be79e9a5ed9e0cfcd0bbb20c53f1c
Parents: f456d48
Author: Alex Heneveld <al...@cloudsoftcorp.com>
Authored: Thu Dec 10 09:38:21 2015 +0000
Committer: Alex Heneveld <al...@cloudsoftcorp.com>
Committed: Thu Dec 10 09:38:21 2015 +0000
----------------------------------------------------------------------
.../brooklyn/entity/group/DynamicCluster.java | 4 ++--
.../entity/group/DynamicClusterImpl.java | 25 +++++++++++++-------
2 files changed, 18 insertions(+), 11 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc17ddca/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
index f6e3068..f528db7 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicCluster.java
@@ -179,8 +179,8 @@ public interface DynamicCluster extends AbstractGroup, Cluster, MemberReplaceabl
AttributeSensor<Entity> CLUSTER = Sensors.newSensor(Entity.class,
"cluster.entity", "The cluster an entity is a member of");
- AttributeSensor<Boolean> ALL_MEMBERS_UP = Sensors.newBooleanSensor(
- "all.members.up", "True if all members' service.isUp is true");
+ AttributeSensor<Boolean> CLUSTER_ONE_AND_ALL_MEMBERS_UP = Sensors.newBooleanSensor(
+ "cluster.one_and_all.members.up", "True cluster is running, there is on member, and all members are service.isUp");
/**
* Changes the cluster size by the given number.
http://git-wip-us.apache.org/repos/asf/incubator-brooklyn/blob/dc17ddca/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
index 8435850..756f665 100644
--- a/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
+++ b/core/src/main/java/org/apache/brooklyn/entity/group/DynamicClusterImpl.java
@@ -35,6 +35,7 @@ import javax.annotation.Nullable;
import org.apache.brooklyn.api.entity.Entity;
import org.apache.brooklyn.api.entity.EntitySpec;
+import org.apache.brooklyn.api.entity.Group;
import org.apache.brooklyn.api.location.Location;
import org.apache.brooklyn.api.location.MachineProvisioningLocation;
import org.apache.brooklyn.api.mgmt.Task;
@@ -100,7 +101,7 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
private static final AttributeSensor<Supplier<Integer>> NEXT_CLUSTER_MEMBER_ID = Sensors.newSensor(new TypeToken<Supplier<Integer>>() {},
"next.cluster.member.id", "Returns the ID number of the next member to be added");
- private volatile FunctionFeed allMembersUp;
+ private volatile FunctionFeed clusterOneAndAllMembersUp;
// TODO better mechanism for arbitrary class name to instance type coercion
static {
@@ -205,26 +206,32 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
}
private void connectAllMembersUp() {
- allMembersUp = FunctionFeed.builder()
+ clusterOneAndAllMembersUp = FunctionFeed.builder()
.entity(this)
.period(Duration.FIVE_SECONDS)
- .poll(new FunctionPollConfig<Boolean, Boolean>(ALL_MEMBERS_UP)
+ .poll(new FunctionPollConfig<Boolean, Boolean>(CLUSTER_ONE_AND_ALL_MEMBERS_UP)
.onException(Functions.constant(Boolean.FALSE))
- .callable(new AllMembersUpCallable()))
+ .callable(new ClusterOneAndAllMembersUpCallable(this)))
.build();
}
- private class AllMembersUpCallable implements Callable<Boolean> {
+ private static class ClusterOneAndAllMembersUpCallable implements Callable<Boolean> {
+ private final Group cluster;
+
+ public ClusterOneAndAllMembersUpCallable(Group cluster) {
+ this.cluster = cluster;
+ }
+
@Override
public Boolean call() throws Exception {
- if (DynamicClusterImpl.this.getMembers().isEmpty())
+ if (cluster.getMembers().isEmpty())
return false;
- if (Lifecycle.RUNNING != DynamicClusterImpl.this.sensors().get(SERVICE_STATE_ACTUAL))
+ if (Lifecycle.RUNNING != cluster.sensors().get(SERVICE_STATE_ACTUAL))
return false;
- for (Entity member : DynamicClusterImpl.this.getMembers())
+ for (Entity member : cluster.getMembers())
if (!Boolean.TRUE.equals(member.sensors().get(SERVICE_UP)))
return false;
@@ -491,7 +498,7 @@ public class DynamicClusterImpl extends AbstractGroupImpl implements DynamicClus
ServiceStateLogic.setExpectedState(this, Lifecycle.ON_FIRE);
throw Exceptions.propagate(e);
} finally {
- if (allMembersUp != null) allMembersUp.stop();
+ if (clusterOneAndAllMembersUp != null) clusterOneAndAllMembersUp.stop();
}
}