brooklyn-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From henev...@apache.org
Subject [10/23] brooklyn-server git commit: include adjunct info as a subscription description
Date Fri, 06 Oct 2017 08:06:34 GMT
include adjunct info as a subscription description

description could be used for more things, exposed more broadly, but this is needed for now
to make sense of those tasks


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

Branch: refs/heads/master
Commit: b0556decc88a1d5bdc1c45500ceeb7c2eb558716
Parents: e1f948a
Author: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Authored: Tue Sep 19 14:30:19 2017 +0100
Committer: Alex Heneveld <alex.heneveld@cloudsoftcorp.com>
Committed: Wed Sep 20 10:10:25 2017 +0100

----------------------------------------------------------------------
 .../brooklyn/core/mgmt/internal/AbstractManagementContext.java  | 3 ++-
 .../core/mgmt/internal/AbstractSubscriptionManager.java         | 5 +++++
 .../brooklyn/core/mgmt/internal/LocalSubscriptionManager.java   | 5 +++++
 .../core/mgmt/internal/QueueingSubscriptionManager.java         | 1 +
 .../org/apache/brooklyn/core/mgmt/internal/Subscription.java    | 1 +
 5 files changed, 14 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b0556dec/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
index f0c9335..86d2e06 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractManagementContext.java
@@ -263,7 +263,8 @@ public abstract class AbstractManagementContext implements ManagementContextInte
     @Override
     public SubscriptionContext getSubscriptionContext(Entity e, EntityAdjunct a) {
         // BSC is a thin wrapper around SM so fine to create a new one here
-        Map<String, ?> flags = ImmutableMap.of("tags", ImmutableList.of(BrooklynTaskTags.tagForContextEntity(e),
BrooklynTaskTags.tagForContextAdjunct(a)));
+        Map<String, ?> flags = ImmutableMap.of("tags", ImmutableList.of(BrooklynTaskTags.tagForContextEntity(e),
BrooklynTaskTags.tagForContextAdjunct(a)),
+            "subscriptionDescription", "adjunct "+a.getId());
         return new BasicSubscriptionContext(flags, getSubscriptionManager(), e);
     }
 

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b0556dec/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractSubscriptionManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractSubscriptionManager.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractSubscriptionManager.java
index c15f770..e7ae59e 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractSubscriptionManager.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/AbstractSubscriptionManager.java
@@ -30,6 +30,7 @@ import org.apache.brooklyn.api.mgmt.SubscriptionManager;
 import org.apache.brooklyn.api.sensor.Sensor;
 import org.apache.brooklyn.api.sensor.SensorEvent;
 import org.apache.brooklyn.api.sensor.SensorEventListener;
+import org.apache.brooklyn.util.text.Strings;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -147,4 +148,8 @@ public abstract class AbstractSubscriptionManager implements SubscriptionManager
         return s.subscriber!=null ? s.subscriber : flags.containsKey("subscriber") ? flags.remove("subscriber")
: s.listener;
     }
 
+    protected <T> String getSubscriptionDescription(Map<String, Object> flags,
Subscription<T> s) {
+        return s.subscriptionDescription!=null ? s.subscriptionDescription : flags.containsKey("subscriptionDescription")
? Strings.toString(flags.remove("subscriptionDescription")) : null;
+    }
+
 }

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b0556dec/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManager.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManager.java
index 65e4b14..6b1a5d9 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManager.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManager.java
@@ -106,6 +106,7 @@ public class LocalSubscriptionManager extends AbstractSubscriptionManager
{
         Entity producer = s.producer;
         Sensor<T> sensor= s.sensor;
         s.subscriber = getSubscriber(flags, s);
+        s.subscriptionDescription = getSubscriptionDescription(flags, s);
         if (flags.containsKey("tags") || flags.containsKey("tag")) {
             Iterable<?> tags = (Iterable<?>) flags.get("tags");
             Object tag = flags.get("tag");
@@ -255,6 +256,10 @@ public class LocalSubscriptionManager extends AbstractSubscriptionManager
{
         description.append(sourceName==null ? "<null-source>" : sourceName);
         description.append(" publishing to ");
         description.append(s.subscriber instanceof Entity ? ((Entity)s.subscriber).getId()
: s.subscriber);
+        if (Strings.isNonBlank(s.subscriptionDescription)) {
+            description.append(", ");
+            description.append(s.subscriptionDescription);
+        }
         
         if (includeDescriptionForSensorTask(event)) {
             name.append(" ");

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b0556dec/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/QueueingSubscriptionManager.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/QueueingSubscriptionManager.java
b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/QueueingSubscriptionManager.java
index 290520d..57ad073 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/QueueingSubscriptionManager.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/QueueingSubscriptionManager.java
@@ -55,6 +55,7 @@ public class QueueingSubscriptionManager extends AbstractSubscriptionManager
{
         QueuedSubscription<T> qs = new QueuedSubscription<T>();
         qs.flags = flags;
         s.subscriber = getSubscriber(flags, s);
+        s.subscriptionDescription = getSubscriptionDescription(flags, s);
         qs.s = s;
         queuedSubscriptions.add(qs);
         return s;

http://git-wip-us.apache.org/repos/asf/brooklyn-server/blob/b0556dec/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/Subscription.java
----------------------------------------------------------------------
diff --git a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/Subscription.java b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/Subscription.java
index 5e71701..1cf0ad7 100644
--- a/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/Subscription.java
+++ b/core/src/main/java/org/apache/brooklyn/core/mgmt/internal/Subscription.java
@@ -37,6 +37,7 @@ class Subscription<T> implements SubscriptionHandle {
     public Object subscriberExecutionManagerTag;
     /** whether the tag was supplied by user, in which case we should not clear execution
semantics */
     public boolean subscriberExecutionManagerTagSupplied;
+    public String subscriptionDescription;
     public Iterable<?> subscriberExtraExecTags;
     public final Entity producer;
     public final Sensor<T> sensor;


Mime
View raw message