brooklyn-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tbouron <...@git.apache.org>
Subject [GitHub] brooklyn-server pull request #561: better presentation for sensor publishing...
Date Thu, 16 Feb 2017 15:02:18 GMT
Github user tbouron commented on a diff in the pull request:

    https://github.com/apache/brooklyn-server/pull/561#discussion_r101535119
  
    --- Diff: core/src/main/java/org/apache/brooklyn/core/mgmt/internal/LocalSubscriptionManager.java
---
    @@ -237,42 +212,85 @@ public synchronized boolean unsubscribe(SubscriptionHandle sh) {
             if (groovyTruth(subs)) {
                 if (LOG.isTraceEnabled()) LOG.trace("sending {}, {} to {}", new Object[]
{event.getSensor().getName(), event, join(subs, ",")});
                 for (Subscription s : subs) {
    -                if (s.eventFilter!=null && !s.eventFilter.apply(event))
    -                    continue;
    -                final Subscription sAtClosureCreation = s;
    -                
    -                List<Object> tags = MutableList.builder()
    -                        .addAll(s.subscriberExtraExecTags == null ? ImmutableList.of()
: s.subscriberExtraExecTags)
    -                        .add(s.subscriberExecutionManagerTag)
    -                        .build()
    -                        .asUnmodifiable();
    -                Map<String, ?> execFlags = MutableMap.of("tags", tags);
    -                
    -                em.submit(execFlags, new Runnable() {
    -                    @Override
    -                    public String toString() {
    -                        return "LSM.publish("+event+")";
    -                    }
    -                    @Override
    -                    public void run() {
    -                        try {
    -                            int count = sAtClosureCreation.eventCount.incrementAndGet();
    -                            if (count > 0 && count % 1000 == 0) LOG.debug("{}
events for subscriber {}", count, sAtClosureCreation);
    -                            
    -                            sAtClosureCreation.listener.onEvent(event);
    -                        } catch (Throwable t) {
    -                            if (event!=null && event.getSource()!=null &&
Entities.isNoLongerManaged(event.getSource())) {
    -                                LOG.debug("Error processing subscriptions to "+this+",
after entity unmanaged: "+t, t);
    -                            } else {
    -                                LOG.warn("Error processing subscriptions to "+this+":
"+t, t);
    -                            }
    -                        }
    -                    }});
    +                submitPublishEvent(s, event, false);
    +                // excludes initial so only do it here
                     totalEventsDeliveredCount.incrementAndGet();
                 }
             }
         }
         
    +    @SuppressWarnings({ "unchecked", "rawtypes" })
    +    private void submitPublishEvent(final Subscription s, final SensorEvent<?>
event, final boolean isInitial) {
    +        if (s.eventFilter!=null && !s.eventFilter.apply(event))
    +            return;
    +        
    +        List<Object> tags = MutableList.builder()
    +            .addAll(s.subscriberExtraExecTags == null ? ImmutableList.of() : s.subscriberExtraExecTags)
    +            .add(s.subscriberExecutionManagerTag)
    +            .add(BrooklynTaskTags.SENSOR_TAG)
    +            .build()
    +            .asUnmodifiable();
    +        
    +        StringBuilder name = new StringBuilder("sensor ");
    +        StringBuilder description = new StringBuilder("Sensor ");
    +        String sensorName = s.sensor==null ? null : s.sensor.getName();
    +        String sourceName = event.getSource()==null ? null : event.getSource().getId();
    +        name.append(sourceName);
    +        name.append(":");
    +        name.append(sensorName);
    +        
    +        description.append(sensorName);
    +        description.append(" on ");
    +        description.append(sourceName);
    +        description.append(" publishing to ");
    +        description.append(s.subscriber instanceof Entity ? ((Entity)s.subscriber).getId()
: s.subscriber);
    +        
    +        if (includeDescriptionForSensorTask(event)) {
    +            name.append(" ");
    +            name.append(event.getValue());
    --- End diff --
    
    Not sure we need the value in the name as we already have it in the description


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

Mime
View raw message