[
https://issues.apache.org/jira/browse/BROOKLYN-171?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14738828#comment-14738828
]
Martin Harris commented on BROOKLYN-171:
----------------------------------------
Found the issue:
It comes down to the fact that the equals() method defined on BasicSensor
requires equality on TypeName, name, an description. Then, when the `producer`
propagator propagates the 'host.name' sensor, it's propagating a Sensor<String>
(as that's how it's defined in Attributes.HOSTNAME). However, when the
`sensorMapping` propagator is setup, the key used in the sensorMapping class is
created dynamically as a Sensor<Object>, so when the propagator tries to look
up the sensor in the map[1] the equality fails, and by default the method
returns the sourceSensor, which causes our infinite loop
The solution appears to be to change the `getDestinationSensor` method to do
the lookup on the sensor name. I'll raise a PR for this shortly
[1]:
https://github.com/apache/incubator-brooklyn/blob/6f15e8a6d61c2e648547cf7faba03fbc06716421/core/src/main/java/org/apache/brooklyn/enricher/stock/Propagator.java#L198-L200
> Mapping propagated sensor causes excessive CPU load
> ---------------------------------------------------
>
> Key: BROOKLYN-171
> URL: https://issues.apache.org/jira/browse/BROOKLYN-171
> Project: Brooklyn
> Issue Type: Bug
> Reporter: Martin Harris
>
> Mapping a propagated sensor using a second propagator will cause excessive
> CPU load, and the sensor will fail to propagate. This can be demonstrated
> using the following YAML:
> {noformat}
> location: localhost
> services:
> - type: org.apache.brooklyn.entity.stock.BasicApplication
> brooklyn.children:
> - type: org.apache.brooklyn.entity.software.base.EmptySoftwareProcess
> id: childid
> brooklyn.enrichers:
> - type: org.apache.brooklyn.enricher.stock.Propagator
> brooklyn.config:
> producer: $brooklyn:component("child", "childid")
> propagating:
> - $brooklyn:sensor("host.name")
> - type: org.apache.brooklyn.enricher.stock.Propagator
> brooklyn.config:
> sensorMapping:
> $brooklyn:sensor("host.name"): $brooklyn:sensor("host")
> {noformat}
> Running this YAML will cause CPU load on my machine to run to around 600%
> CPU, and cause the Brooklyn console to become unresponsive. The specs of my
> machine are as follows:
> Model Name: MacBook Pro
> Model Identifier: MacBookPro11,3
> Processor Name: Intel Core i7
> Processor Speed: 2.8 GHz
> Number of Processors: 1
> Total Number of Cores: 4
> L2 Cache (per Core): 256 KB
> L3 Cache: 6 MB
> Memory: 16 GB
> *Context (aka 'Why would you ever want to do this??')*:
> The Redis cluster propagates the hostname of the master RedisStore up to the
> cluster level [1]. We then added (in the YAML) a propagator with
> `sensorMapping` to map the sensor `host.name` to `host` in order for it to be
> consumed by a third party application (CloudFoundry via the
> Brooklyn-Service-Broker[2])
> In this scenario (i.e. Redis, deploying to AWS from a rBrooklyn server), the
> server web interface becomes completely unresponsive until the Brooklyn
> process is terminated and restarted
> [1]:
> https://github.com/apache/incubator-brooklyn/blob/6f15e8a6d61c2e648547cf7faba03fbc06716421/software/nosql/src/main/java/org/apache/brooklyn/entity/nosql/redis/RedisClusterImpl.java#L73-L76
> [2]: https://github.com/cloudfoundry-incubator/brooklyn-service-broker
--
This message was sent by Atlassian JIRA
(v6.3.4#6332)