brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From geom...@apache.org
Subject [3/4] brooklyn-server git commit: Friendlier toString() for common service-up check.
Date Wed, 08 Mar 2017 15:12:08 GMT
Friendlier toString() for common service-up check.

Project: http://git-wip-us.apache.org/repos/asf/brooklyn-server/repo
Commit: http://git-wip-us.apache.org/repos/asf/brooklyn-server/commit/7b3aface
Tree: http://git-wip-us.apache.org/repos/asf/brooklyn-server/tree/7b3aface
Diff: http://git-wip-us.apache.org/repos/asf/brooklyn-server/diff/7b3aface

Branch: refs/heads/master
Commit: 7b3aface44f41ae497563f3e9bae0b7597e47413
Parents: 7172788
Author: Alasdair Hodge <github@alasdairhodge.co.uk>
Authored: Wed Mar 8 14:16:32 2017 +0000
Committer: Alasdair Hodge <github@alasdairhodge.co.uk>
Committed: Wed Mar 8 14:16:32 2017 +0000

----------------------------------------------------------------------
 .../org/apache/brooklyn/core/entity/Entities.java  |  5 ++---
 .../brooklyn/core/entity/EntityPredicates.java     | 17 +++++++++++++++++
 2 files changed, 19 insertions(+), 3 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b3aface/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java b/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java
index 6d68694..a2d8e47 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/Entities.java
@@ -18,7 +18,6 @@
  */
 package org.apache.brooklyn.core.entity;
 
-import static org.apache.brooklyn.core.entity.EntityPredicates.attributeEqualTo;
 import static org.apache.brooklyn.util.guava.Functionals.isSatisfied;
 
 import java.io.Closeable;
@@ -1262,9 +1261,9 @@ public class Entities {
         log.debug("Detected {} for {}", condition, entity);
     }
 
-    /** Waits until {@link Startable#SERVICE_UP} returns true. */
+    /** Waits until {@link Startable#SERVICE_UP} is true. */
     public static void waitForServiceUp(final Entity entity, Duration timeout) {
-        waitFor(entity, attributeEqualTo(Startable.SERVICE_UP, true), timeout);
+        waitFor(entity, EntityPredicates.isServiceUp(), timeout);
     }
     public static void waitForServiceUp(final Entity entity, long duration, TimeUnit units)
{
         waitForServiceUp(entity, Duration.of(duration, units));

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/7b3aface/core/src/main/java/org/apache/brooklyn/core/entity/EntityPredicates.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/entity/EntityPredicates.java b/core/src/main/java/org/apache/brooklyn/core/entity/EntityPredicates.java
index 60cd8cc..4b85724 100644
--- a/core/src/main/java/org/apache/brooklyn/core/entity/EntityPredicates.java
+++ b/core/src/main/java/org/apache/brooklyn/core/entity/EntityPredicates.java
@@ -30,6 +30,7 @@ import org.apache.brooklyn.api.sensor.AttributeSensor;
 import org.apache.brooklyn.config.ConfigKey;
 import org.apache.brooklyn.config.ConfigKey.HasConfigKey;
 import org.apache.brooklyn.core.config.ConfigKeys;
+import org.apache.brooklyn.core.entity.trait.Startable;
 import org.apache.brooklyn.core.sensor.Sensors;
 import org.apache.brooklyn.util.collections.CollectionFunctionals;
 import org.apache.brooklyn.util.guava.SerializablePredicate;
@@ -503,4 +504,20 @@ public class EntityPredicates {
         };
     }
 
+    public static Predicate<Entity> isServiceUp() {
+        return new IsServiceUp();
+    }
+
+    /** Common test, provide short friendly toString(). */
+    protected static class IsServiceUp implements SerializablePredicate<Entity> {
+        @Override
+        public boolean apply(Entity input) {
+            return Boolean.TRUE.equals(input.sensors().get(Startable.SERVICE_UP));
+        }
+        @Override
+        public String toString() {
+            return "SERVICE_UP";
+        }
+    };
+
 }


Mime
View raw message