You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@brooklyn.apache.org by Duncan Grant <du...@cloudsoftcorp.com> on 2015/04/06 12:40:45 UTC

Dynamically adding sensors to an entity

I'm extending the rabbitmq blueprint so that it will enable the management
plugin depending on a config flag.

I want to add a couple of sensors (management port and url) but don't want
to put them into the entity interface as they won't always be available.
There seems to be some functionality within brooklyn for adding a sensor
dynamically but I can't find an example of this being done in a "normal"
blueprint.

Is this a good approach to take or would I be better to add the sensors to
the entity and set them to null when they are unused?

Thanks

Duncan

Re: Dynamically adding sensors to an entity

Posted by Alex Heneveld <al...@cloudsoftcorp.com>.
Hi Duncan-

The question about whether a sensor/effector should be declared vs 
dynamic is really whether it should be discoverable before deployment.  
It's not unusual to have sensors declared on the interface which aren't 
always used.  Normally in this case I'd declare them but include in the 
description an indication of under what circumstances they'll be populated.

BTW setting a dynamic sensor is the same as a declared sensor; when 
setting an attribute there is no requirement that the sensor name be 
registered.  So just:

     setAttribute(DYNAMIC_SENSOR, value);

where the constant can be declared anywhere, or used inline:

     setAttribute(Sensors.newStringSensor("my.sensor.dynamic.1", "My 
Dynamic Sensor"), value);

Best
Alex




On 06/04/2015 11:40, Duncan Grant wrote:
> I'm extending the rabbitmq blueprint so that it will enable the management
> plugin depending on a config flag.
>
> I want to add a couple of sensors (management port and url) but don't want
> to put them into the entity interface as they won't always be available.
> There seems to be some functionality within brooklyn for adding a sensor
> dynamically but I can't find an example of this being done in a "normal"
> blueprint.
>
> Is this a good approach to take or would I be better to add the sensors to
> the entity and set them to null when they are unused?
>
> Thanks
>
> Duncan
>